[ https://issues.apache.org/jira/browse/NUTCH-2624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16553939#comment-16553939 ]
Sebastian Nagel commented on NUTCH-2624: ---------------------------------------- Hi [~yossi], your solution should work from the [documentation|https://square.github.io/okhttp/3.x/okhttp/okhttp3/ResponseBody.html], from the implementation: a Response.close() only calls body.close(). However, I would put the Response object into the try statement as a resource. It adds extra indentation but avoids potential leaks for the future as it makes clear you have to call close() even without calling body(). > protocol-okhttp resource leak > ----------------------------- > > Key: NUTCH-2624 > URL: https://issues.apache.org/jira/browse/NUTCH-2624 > Project: Nutch > Issue Type: Bug > Components: protocol > Affects Versions: 1.15 > Reporter: Sebastian Nagel > Priority: Major > Fix For: 1.15 > > > The protocol-okhttp leaks response streams as logged by > okhttp3.ConnectionPool: > {noformat} > WARNING: A connection to ... was leaked. Did you forget to close a response > body? > {noformat} > This has been introduced in commit > [f598db7|https://github.com/apache/nutch/commit/f598db7] - need to catch the > IOException *and* close the response, then re-throw so that FetcherThread can > handle the exception. -- This message was sent by Atlassian JIRA (v7.6.3#76005)