summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2015-08-14 13:54:32 +1000
committerLeith Bade <leith@mapbox.com>2015-08-14 13:55:42 +1000
commit2f316878448d0056b5c4ced6ce0819349eaf466e (patch)
treea9113554bdfdf5679b74fe67f2f76c2523ebe425 /android
parentb312820be89b147a91a7b596d6704ae69c0ddad2 (diff)
downloadqtlocation-mapboxgl-2f316878448d0056b5c4ced6ce0819349eaf466e.tar.gz
Use uv::async in HTTPAndroidRequest to ensure the correct thread deletes request object
Fixes #2058
Diffstat (limited to 'android')
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java
index 509c79a4a5..4558bbfe34 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java
@@ -84,8 +84,15 @@ class HTTPContext {
@Override
public void onResponse(Response response) throws IOException {
- byte[] body = response.body().bytes();
- response.body().close();
+ byte[] body;
+ try {
+ body = response.body().bytes();
+ } catch (IOException e) {
+ onFailure(mRequest, e);
+ return;
+ } finally {
+ response.body().close();
+ }
nativeOnResponse(mNativePtr, response.code(), response.message(), response.header("ETag"), response.header("Last-Modified"), response.header("Cache-Control"), response.header("Expires"), body);
}