diff --git a/gradle.properties b/gradle.properties index dd0b3a3ae8..54f32e840a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ POM_DEVELOPER_NAME=Sam Judd POM_DEVELOPER_EMAIL=judds@google.com ANDROID_SUPPORT_VERSION=27.0.2 VOLLEY_VERSION=1.0.0 -OK_HTTP_VERSION=3.9.0 +OK_HTTP_VERSION=3.9.1 ANDROID_GRADLE_VERSION=3.0.1 DAGGER_VERSION=2.11 diff --git a/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java b/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java index 7855929053..2b6a69b38d 100644 --- a/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java +++ b/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java @@ -1,6 +1,5 @@ package com.bumptech.glide.integration.okhttp3; -import android.os.Build; import android.support.annotation.NonNull; import android.util.Log; import com.bumptech.glide.Priority; @@ -10,7 +9,6 @@ import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.util.ContentLengthInputStream; import com.bumptech.glide.util.Preconditions; -import com.bumptech.glide.util.Synthetic; import java.io.IOException; import java.io.InputStream; import java.util.Map; @@ -26,10 +24,12 @@ public class OkHttpStreamFetcher implements DataFetcher, okhttp3.Ca private static final String TAG = "OkHttpFetcher"; private final Call.Factory client; private final GlideUrl url; - @SuppressWarnings("WeakerAccess") @Synthetic InputStream stream; - @SuppressWarnings("WeakerAccess") @Synthetic ResponseBody responseBody; - private volatile Call call; + private InputStream stream; + private ResponseBody responseBody; private DataCallback callback; + // call may be accessed on the main thread while the object is in use on other threads. All other + // accesses to variables may occur on different threads, but only one at a time. + private volatile Call call; // Public API. @SuppressWarnings("WeakerAccess") @@ -50,21 +50,7 @@ public void loadData(@NonNull Priority priority, this.callback = callback; call = client.newCall(request); - if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) { - call.enqueue(this); - } else { - try { - // Calling execute instead of enqueue is a workaround for #2355, where okhttp throws a - // ClassCastException on O. - onResponse(call, call.execute()); - } catch (IOException e) { - onFailure(call, e); - } catch (ClassCastException e) { - // It's not clear that this catch is necessary, the error may only occur even on O if - // enqueue is used. - onFailure(call, new IOException("Workaround for framework bug on O", e)); - } - } + call.enqueue(this); } @Override