I am using Jersey Client v2.16 (a transitive Dropwizard 0.8.0 dependency, which I also use).
I am somehow puzzled by the mechanism for closing a response when an object reads as an InputStream . The documentation says:
Also, if an object is read in an InputStream (by response.readEntity (InputStream.class)), the connection remains open until you finish reading from InputStream. In this case, the InputStream or Response must be manually closed at the end of reading from the InputStream.
However, when I get a response object using Response.readEntity(InputStream.class) , I get an instance of org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream , which, as the name implies, does not release anything below it when called close() method (I can say breaking the InputStream contract). This is the close() method:
@Override public void close() throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, LocalizationMessages.MBR_TRYING_TO_CLOSE_STREAM(reader.getClass())); } }
As a result, I end up with no HTTP connections in my pool and slowly populating the pool.
Given that it cannot be easy to get a link to the answer and that the InputStream **or** the Response should be closed manually papers indicate the InputStream **or** the Response should be closed manually , how can I actually free the physical resource?
source share