Skip to content

Commit 5862903

Browse files
committed
fix #467 - call shutdown on ThreadSafeClientConnManager (the HTTP connection pool) to avoid any lingering connections in CLOSE_WAIT
(cherry picked from commit e9499fd) (cherry picked from commit 62f3bfc)
1 parent d69d502 commit 5862903

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/com/marklogic/client/impl/JerseyServices.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public void verify(String hostname, String[] cns, String[] subjectAlts)
189189

190190
private DatabaseClient databaseClient;
191191
private String database = null;
192+
private ThreadSafeClientConnManager connMgr;
192193
private ApacheHttpClient4 client;
193194
private WebResource connection;
194195
private boolean released = false;
@@ -281,6 +282,10 @@ private void connect(String host, int port, String database, String user, String
281282

282283
if (connection != null)
283284
connection = null;
285+
if (connMgr != null) {
286+
connMgr.shutdown();
287+
connMgr = null;
288+
}
284289
if (client != null) {
285290
client.destroy();
286291
client = null;
@@ -353,7 +358,7 @@ private void connect(String host, int port, String database, String user, String
353358
* maxRouteConnections);
354359
*/
355360
// start 4.1
356-
ThreadSafeClientConnManager connMgr = new ThreadSafeClientConnManager(
361+
connMgr = new ThreadSafeClientConnManager(
357362
schemeRegistry);
358363
connMgr.setMaxTotal(maxTotalConnections);
359364
connMgr.setDefaultMaxPerRoute(maxRouteConnections);
@@ -470,6 +475,8 @@ public void release() {
470475
logger.debug("Releasing connection");
471476

472477
connection = null;
478+
connMgr.shutdown();
479+
connMgr = null;
473480
client.destroy();
474481
client = null;
475482
}

0 commit comments

Comments
 (0)