Skip to content

Commit 40ae715

Browse files
author
Stephane Landelle
committed
Fix NPE caused by AsyncHttpClient#676, close AsyncHttpClient#678
1 parent fb1a88a commit 40ae715

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/channel/pool/DefaultChannelPool.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,21 @@ public void run(Timeout timeout) throws Exception {
198198
int closedCount = 0;
199199
int totalCount = 0;
200200

201-
for (Map.Entry<String, ConcurrentLinkedQueue<IdleChannel>> entry : poolsPerKey.entrySet()) {
201+
for (ConcurrentLinkedQueue<IdleChannel> pool : poolsPerKey.values()) {
202202

203-
String poolKey = entry.getKey();
204-
ConcurrentLinkedQueue<IdleChannel> pool = entry.getValue();
205203
// store in intermediate unsynchronized lists to minimize the impact on the ConcurrentLinkedQueue
206204
if (LOGGER.isDebugEnabled())
207205
totalCount += pool.size();
208206

209207
List<IdleChannel> closedChannels = closeChannels(expiredChannels(pool, start));
210-
pool.removeAll(closedChannels);
211-
closedCount += closedChannels.size();
212-
if (pool.isEmpty())
213-
poolsPerKey.remove(poolKey);
208+
209+
if (!closedChannels.isEmpty()) {
210+
for (IdleChannel closedChannel : closedChannels)
211+
channel2Creation.remove(closedChannel.channel);
212+
213+
pool.removeAll(closedChannels);
214+
closedCount += closedChannels.size();
215+
}
214216
}
215217

216218
long duration = millisTime() - start;

0 commit comments

Comments
 (0)