okhttp 3.4.1will go endless loop,when there is a IOException("shutdown")
See original GitHub issuehere is how it go endless loop: in file RetryAndFollowUpInterceptor.java
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
streamAllocation = new StreamAllocation(
client.connectionPool(), createAddress(request.url()));
int followUpCount = 0;
Response priorResponse = null;
while (true) {
if (canceled) {
streamAllocation.release();
throw new IOException("Canceled");
}
Response response = null;
boolean releaseConnection = true;
try {
response = ((RealInterceptorChain) chain).proceed(request, streamAllocation, null, null);
releaseConnection = false;
} catch (RouteException e) {
// The attempt to connect via a route failed. The request will not have been sent.
if (!recover(e.getLastConnectException(), true, request)) throw e.getLastConnectException();
releaseConnection = false;
continue;
} catch (IOException e) {
// An attempt to communicate with a server failed. The request may have been sent.
if (!recover(e, false, request)) throw e;
releaseConnection = false;
continue;
} finally {
// We're throwing an unchecked exception. Release any resources.
if (releaseConnection) {
streamAllocation.streamFailed(null);
streamAllocation.release();
}
}
when there is a IOException(“shutdown”) when execute
response = ((RealInterceptorChain) chain).proceed(request, streamAllocation, null, null);
it will go into catch block,and judge if can recover,recover(e, false, request)
unfortunately recover() return true,so it will continue and go endless loop
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (8 by maintainers)
Top Results From Across the Web
okhttp 3.4.1will go endless loop,when there is a IOException ...
here is how it go endless loop: in file RetryAndFollowUpInterceptor.java public Response intercept(Chain chain) throws IOException { Request request ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released as 3.4.2.
@fabioCollini yup, although that snippet is an older version. I’m working on a fix.