If you want to reuse the connection, then you must consume the content stream completely after each use as follows:
EntityUtils.consume(response.getEntity())
Note: you need to consume the content stream even if the status code is not 200. The following will not be done the next time you use it:
Exception in thread "main" java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection is still highlighted. Be sure to release the connection before highlighting another.
If this is a one-time use, then simply closing the connection will free up all resources associated with it.
Ayman Hussain Aug 31 '17 at 12:48 on 2017-08-31 12:48
source share