Skip to content

Commit bc56709

Browse files
committed
Release semaphores when only maxConnectionsPerHost is enabled, closed AsyncHttpClient#920
1 parent 56ef075 commit bc56709

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/com/ning/http/client/providers/netty/channel/ChannelManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ public ChannelManager(final AsyncHttpClientConfig config, NettyAsyncHttpProvider
130130
maxTotalConnectionsEnabled = config.getMaxConnections() > 0;
131131
maxConnectionsPerHostEnabled = config.getMaxConnectionsPerHost() > 0;
132132

133-
if (maxTotalConnectionsEnabled) {
133+
if (maxTotalConnectionsEnabled || maxConnectionsPerHostEnabled) {
134134
openChannels = new CleanupChannelGroup("asyncHttpClient") {
135135
@Override
136136
public boolean remove(Object o) {
137137
boolean removed = super.remove(o);
138138
if (removed) {
139-
freeChannels.release();
139+
if (maxTotalConnectionsEnabled)
140+
freeChannels.release();
140141
if (maxConnectionsPerHostEnabled) {
141142
Object partitionKey = channelId2PartitionKey.remove(Channel.class.cast(o).getId());
142143
if (partitionKey != null) {

0 commit comments

Comments
 (0)