Regression in Exchange in 3.14
See original GitHub issueHey, folks - I think I’m running into something that appears to be a regression in 3.14 around the new exchange mechanism. I can reproduce this 100% of the time in my app by creating a specific scenario.
Here’s the basic setup. We have an interceptor that does a lot of things for us, including setting headers and handling retries for auth errors. Here’s a simplified version of the code, eliding a lot of details around how the retries are triggered:
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
Request.Builder builder = originalRequest.newBuilder();
// Add headers/etc here.
Request request = builder.build();
Response response = chain.proceed(request);
if (isError(response)) {
// Grab a new auth token, etc.
response = chain.proceed(retry);
return response;
}
}
In 3.13.1, this seems to work just fine. In 3.14.0, this crashes with the following error:
03-22 11:52:21.889 E/AndroidRuntime(10135): java.lang.IllegalStateException: exchange != null
03-22 11:52:21.889 E/AndroidRuntime(10135): at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:159)
03-22 11:52:21.889 E/AndroidRuntime(10135): at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
...
It doesn’t seem to matter if you mutate the request or not. Even just using (as above) a newly built version of the request produces the same behavior.
Any ideas what’s happening here? I’m going to revert our library back to 3.13 for now to work around this, but I’m curious what could be causing this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
Yup, looks like the same bug - I’d bet that if you add
origResponse.close()
before theval newResponse
line in the auth interceptor, the problem will disappear. 😃Yeah, my assumption is that previously you would have had two response bodies open concurrently for a single call.
We should fix the exception to be more obvious about what the problem is.