Hi all,
When I follow the last section about OkHttp in http://github-api.kohsuke.org/ to use pluggable connector with OkHttp. I sometimes see warning message in log:
15:53:14,467 WARNING [com.squareup.okhttp.OkHttpClient] (OkHttp ConnectionPool) A connection to https://api.github.com/ was leaked. Did you forget to close a response body?
Basically, I think it is caused by some intermittent internet failures to retrieve data from GitHub, once a sub-task (let's say get Pull Request) reaches timeout in Future get() method due to network difficulty, I can catch a CancellationException, I think in that case I should somehow close a response body as pointed by the warning message and also in https://github.com/square/okhttp/issues/2311. But I did not see where I can do it. After I configure the connector as:
Cache cache = new Cache(cacheFile, size * 1024 * 1024); // default 20MB cache
}
RepositoryConfig config = ...
GitHub github = new GitHubBuilder()
.withOAuthToken(config.getPassword(), config.getUsername())
.withConnector(new OkHttpConnector(new OkUrlFactory(new OkHttpClient().setCache(cache))))
.build();
I have no other place to deal with the OkHttpConnector and OkHttpClient, it only calls github.getXXX() method to retrieve data from GitHub without any response body I can access to close off.
Any idea how can I fix the potential leak here ?
versions I use:
okhttp-urlconnection version 2.7.5
github-api version 1.77