|
24 | 24 | import java.util.HashMap; |
25 | 25 | import java.util.List; |
26 | 26 | import java.util.Map; |
| 27 | +import java.util.NoSuchElementException; |
27 | 28 | import java.util.concurrent.CompletableFuture; |
28 | 29 | import java.util.concurrent.CompletionException; |
29 | 30 | import java.util.concurrent.ExecutorService; |
@@ -102,7 +103,7 @@ class NettyConnector implements Connector { |
102 | 103 | private final Integer maxPoolSizeTotal; //either from Jersey config, or default |
103 | 104 | private final Integer maxPoolIdle; // either from Jersey config, or default |
104 | 105 |
|
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"; |
106 | 107 | private static final String PRUNE_INACTIVE_POOL = "prune_inactive_pool"; |
107 | 108 | private static final String READ_TIMEOUT_HANDLER = "read_timeout_handler"; |
108 | 109 | private static final String REQUEST_HANDLER = "request_handler"; |
@@ -190,10 +191,18 @@ protected CompletableFuture<ClientResponse> execute(final ClientRequest jerseyRe |
190 | 191 | synchronized (conns) { |
191 | 192 | while (chan == null && !conns.isEmpty()) { |
192 | 193 | 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 | + } |
195 | 204 | if (!chan.isOpen()) { |
196 | | - chan = null; |
| 205 | + chan = null; |
197 | 206 | } |
198 | 207 | } |
199 | 208 | } |
|
0 commit comments