File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/main/java/com/ning/http/client/providers/netty/channel/pool Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 29
29
import java .util .ArrayList ;
30
30
import java .util .Collections ;
31
31
import java .util .List ;
32
+ import java .util .Map ;
32
33
import java .util .concurrent .ConcurrentHashMap ;
33
34
import java .util .concurrent .ConcurrentLinkedQueue ;
34
35
import java .util .concurrent .TimeUnit ;
@@ -194,15 +195,21 @@ public void run(Timeout timeout) throws Exception {
194
195
int closedCount = 0 ;
195
196
int totalCount = 0 ;
196
197
197
- for (ConcurrentLinkedQueue <IdleChannel > pool : poolsPerKey .values ()) {
198
+ for (Map .Entry <String , ConcurrentLinkedQueue <IdleChannel >> entry : poolsPerKey .entrySet ()) {
199
+
200
+ String poolKey = entry .getKey ();
201
+ ConcurrentLinkedQueue <IdleChannel > pool = entry .getValue ();
202
+
198
203
// store in intermediate unsynchronized lists to minimize the impact on the ConcurrentLinkedQueue
199
204
if (LOGGER .isDebugEnabled ())
200
205
totalCount += pool .size ();
201
206
202
207
List <IdleChannel > closedChannels = closeChannels (expiredChannels (pool , start ));
208
+
203
209
pool .removeAll (closedChannels );
204
- int poolClosedCount = closedChannels .size ();
205
- closedCount += poolClosedCount ;
210
+ closedCount += closedChannels .size ();
211
+ if (pool .isEmpty ())
212
+ poolsPerKey .remove (poolKey );
206
213
}
207
214
208
215
long duration = millisTime () - start ;
You can’t perform that action at this time.
0 commit comments