Index: src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java =================================================================== --- src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java (revision 1137518) +++ src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java (working copy) @@ -54,11 +54,10 @@ @Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (maxConnections > 0) { - int currentCount = connections.getAndIncrement(); + int currentCount = connections.incrementAndGet(); if (currentCount > maxConnections) { ctx.getChannel().close(); - connections.decrementAndGet(); } } Index: src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java =================================================================== --- src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java (revision 1137518) +++ src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java (working copy) @@ -80,7 +80,6 @@ Integer count = atomicCount.incrementAndGet(); if (count > maxConnectionsPerIp) { ctx.getChannel().close(); - atomicCount.decrementAndGet(); } } } @@ -101,4 +100,4 @@ } super.channelClosed(ctx, e); } -} \ No newline at end of file +}