Skip to content

Commit 4a70e66

Browse files
committed
NettyConnector connection close
Signed-off-by: Maxim Nesen <[email protected]>
1 parent bb56997 commit 4a70e66

File tree

1 file changed

+8
-1
lines changed
  • connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector

1 file changed

+8
-1
lines changed

connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ protected void initChannel(SocketChannel ch) throws Exception {
261261
if (th == null) {
262262
ch.pipeline().addLast(INACTIVE_POOLED_CONNECTION_HANDLER, new IdleStateHandler(0, 0, maxPoolIdle));
263263
ch.pipeline().addLast(PRUNE_INACTIVE_POOL, new PruneIdlePool(connections, key));
264+
boolean added = true;
264265
synchronized (connections) {
265266
ArrayList<Channel> conns1 = connections.get(key);
266267
if (conns1 == null) {
@@ -271,10 +272,16 @@ protected void initChannel(SocketChannel ch) throws Exception {
271272
synchronized (conns1) {
272273
if (conns1.size() < maxPoolSize) {
273274
conns1.add(ch);
274-
} // else do not add the Channel to the idle pool
275+
} else { // else do not add the Channel to the idle pool
276+
added = false;
277+
}
275278
}
276279
}
277280
}
281+
282+
if (!added) {
283+
ch.close();
284+
}
278285
} else {
279286
ch.close();
280287
// if responseAvailable has been completed, no-op: jersey will encounter IOException while reading response body

0 commit comments

Comments
 (0)