Skip to content

Commit 8fed3c6

Browse files
authored
NettyConnectorProvider (jersey-netty-connector) is throwing an exception with inactive_pooled_connection_handler error
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
1 parent 71a237b commit 8fed3c6

File tree

1 file changed

+13
-4
lines changed
  • connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.HashMap;
2525
import java.util.List;
2626
import java.util.Map;
27+
import java.util.NoSuchElementException;
2728
import java.util.concurrent.CompletableFuture;
2829
import java.util.concurrent.CompletionException;
2930
import java.util.concurrent.ExecutorService;
@@ -102,7 +103,7 @@ class NettyConnector implements Connector {
102103
private final Integer maxPoolSizeTotal; //either from Jersey config, or default
103104
private final Integer maxPoolIdle; // either from Jersey config, or default
104105

105-
private static final String INACTIVE_POOLED_CONNECTION_HANDLER = "inactive_pooled_connection_handler";
106+
static final String INACTIVE_POOLED_CONNECTION_HANDLER = "inactive_pooled_connection_handler";
106107
private static final String PRUNE_INACTIVE_POOL = "prune_inactive_pool";
107108
private static final String READ_TIMEOUT_HANDLER = "read_timeout_handler";
108109
private static final String REQUEST_HANDLER = "request_handler";
@@ -190,10 +191,18 @@ protected CompletableFuture<ClientResponse> execute(final ClientRequest jerseyRe
190191
synchronized (conns) {
191192
while (chan == null && !conns.isEmpty()) {
192193
chan = conns.remove(conns.size() - 1);
193-
chan.pipeline().remove(INACTIVE_POOLED_CONNECTION_HANDLER);
194-
chan.pipeline().remove(PRUNE_INACTIVE_POOL);
194+
try {
195+
chan.pipeline().remove(INACTIVE_POOLED_CONNECTION_HANDLER);
196+
chan.pipeline().remove(PRUNE_INACTIVE_POOL);
197+
} catch (NoSuchElementException e) {
198+
/*
199+
* Eat it.
200+
* It could happen that the channel was closed, pipeline cleared and
201+
* then it will fail to remove the names with this exception.
202+
*/
203+
}
195204
if (!chan.isOpen()) {
196-
chan = null;
205+
chan = null;
197206
}
198207
}
199208
}

0 commit comments

Comments
 (0)