facebook/fresco

HTTP error response when loading image results in leaked connection

オープン

#1,983 opened on 2017/12/06

 (4 件のコメント) (0 件のリアクション) (0 人の担当者)Java (3,750 件のフォーク)batch import
buggood first issue

Repository metrics

Stars
 (17,072 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Description

I noticed a bunch of log lines like this throughout Logcat as I used my app: 19098-19147/<package> W/OkHttpClient: A connection to <my server> was leaked. Did you forget to close a response body?

I eventually narrowed it down to a single SimpleDraweeView that was causing it when I tried to set its image URI.

Using imagepipeline-okhttp3, I added an OkHTTP client and interceptor so I could inspect what was going on with the HTTP request/response. It turns out that the response was not 200, rather a 401 error. This prevented the image from loading as expected and also led to the above log lines.

I was able to fix this particular 401 error by using an interceptor to add the necessary authentication headers I was missing. However, I was wondering If there are different HTTP errors in the future, is there a general way to catch errors in such a way that it doesn't leak a connection?

Reproduction

Set an image URI on a SimpleDraweeView that results in a 401 HTTP error code response.

Additional Information

  • Fresco version: 1.5.0
  • imagepipeline-okhttp3 version: 1.5.0

コントリビューターガイド