From 2f316878448d0056b5c4ced6ce0819349eaf466e Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 14 Aug 2015 13:54:32 +1000 Subject: Use uv::async in HTTPAndroidRequest to ensure the correct thread deletes request object Fixes #2058 --- .../src/main/java/com/mapbox/mapboxgl/http/HTTPContext.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'android') 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); } -- cgit v1.2.1