question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

okhttp 3.4.1will go endless loop,when there is a IOException("shutdown")

See original GitHub issue

here 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:closed
  • Created 7 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
swankjessecommented, Nov 4, 2016

Released as 3.4.2.

3reactions
dave-r12commented, Sep 14, 2016

@fabioCollini yup, although that snippet is an older version. I’m working on a fix.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found