java - OkHttp: A connection to http://example.com/ was leaked. Did you forget to close a response body? -


this error message of okhttp v3.4.1 has been discussed few times, , each time read it, people not closing response body:

  warning: connection http://www.example.com/ leaked. did forget close response body? 

but code reads this:

  private string executerequest(request request) throws ioexception {     response response = httpclient.newcall(request).execute();      try (responsebody responsebody = response.body()) {       string string = responsebody.string();       logger.debug("result: {}", string);       return string;     }   } 

so responsebody.close() called. how come above error? configured custom jwt interceptor, don't see how cause problem:

public class jwtinterceptor implements interceptor {    private string jwt;    @override   public response intercept(chain chain) throws ioexception {     request request = chain.request();      if (jwt != null) {       request = request.newbuilder()           .addheader("authorization", "bearer " + jwt)           .build();     }      response response = chain.proceed(request);     string jwt = response.header("jwt");     if (jwt != null) {       this.jwt = jwt;     }      return chain.proceed(request);   } } 

turns out interceptor bugged:

return chain.proceed(request); 

should be:

return request; 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -