I am using the Cloudant Java SDK Version 0.5.6 to access a local CouchDb. During operation, I encountered a serialization error, which caused a retry. During the retry, the following warning appeared:
2023-09-13 12:17:21 WARN OkHttpClient:133 - A connection to http://couchdb:5984/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
To Reproduce
Try to retrieve a document such that the request fails, and then retry that request multiple times.
Expected behavior
The Response object returned from the service call should be closed properly, also when the request fails for some reason.
Must gather (please complete the following information):
SDK Version: 0.5.6
Java Version [OpenJDK Runtime Environment Temurin-20.0.2+9 (build 20.0.2+9)]
Additional context
This seems to result from not properly closing the Response resource returned by the underlying OkHttp library, as described here. In fact, a look at the method processServiceCall() in com.ibm.cloud.sdk.core.service.BaseService does not show a call to Response.close() anywhere
Describe the bug
I am using the Cloudant Java SDK Version 0.5.6 to access a local CouchDb. During operation, I encountered a serialization error, which caused a retry. During the retry, the following warning appeared:
2023-09-13 12:17:21 WARN OkHttpClient:133 - A connection to http://couchdb:5984/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
To Reproduce Try to retrieve a document such that the request fails, and then retry that request multiple times.
Expected behavior The
Response
object returned from the service call should be closed properly, also when the request fails for some reason.Must gather (please complete the following information):
Additional context
This seems to result from not properly closing the
Response
resource returned by the underlying OkHttp library, as described here. In fact, a look at the methodprocessServiceCall()
incom.ibm.cloud.sdk.core.service.BaseService
does not show a call toResponse.close()
anywhere