Skip to content

Commit e9499fd

Browse files
committed
fix #467 - call shutdown on ThreadSafeClientConnManager (the HTTP connection pool) to avoid any lingering connections in CLOSE_WAIT
1 parent a79e9c7 commit e9499fd

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public void verify(String hostname, String[] cns, String[] subjectAlts)
193193

194194
private DatabaseClient databaseClient;
195195
private String database = null;
196+
private ThreadSafeClientConnManager connMgr;
196197
private ApacheHttpClient4 client;
197198
private WebResource connection;
198199
private boolean released = false;
@@ -285,6 +286,10 @@ private void connect(String host, int port, String database, String user, String
285286

286287
if (connection != null)
287288
connection = null;
289+
if (connMgr != null) {
290+
connMgr.shutdown();
291+
connMgr = null;
292+
}
288293
if (client != null) {
289294
client.destroy();
290295
client = null;
@@ -357,7 +362,7 @@ private void connect(String host, int port, String database, String user, String
357362
* maxRouteConnections);
358363
*/
359364
// start 4.1
360-
ThreadSafeClientConnManager connMgr = new ThreadSafeClientConnManager(
365+
connMgr = new ThreadSafeClientConnManager(
361366
schemeRegistry);
362367
connMgr.setMaxTotal(maxTotalConnections);
363368
connMgr.setDefaultMaxPerRoute(maxRouteConnections);
@@ -478,6 +483,8 @@ public void release() {
478483
logger.debug("Releasing connection");
479484

480485
connection = null;
486+
connMgr.shutdown();
487+
connMgr = null;
481488
client.destroy();
482489
client = null;
483490
}

0 commit comments

Comments
 (0)