Apache PoolingHttpClientConnectionManager throwing illegal state exception

对着背影说爱祢 提交于 2019-11-28 23:22:30

This behavior is due to a bug in HC 4.3. It has already been fixed in HC 4.4a1. As of 4.4 CloseableHttpClient#close should automatically shut down the connection pool only if exclusively owned by the client

In version 4.4 the method setConnectionManagerShared was added to HttpClientBuilder. If you set it to true the client won't close the connection manager.

HttpClients.custom()
            .setConnectionManager(Util.getConnectionManager()) // shared connection manager
            .setConnectionManagerShared(true)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!