ning / async-http-client

Asynchronous Http Client for Java
135 stars 50 forks source link

"java.io.IOException: Too many connections" incorrectly thrown when using keep-alive #36

Closed twilliamson closed 14 years ago

twilliamson commented 14 years ago

NettyAsyncHttpProvider.doConnect() always calls activeConnectionsCount.getAndIncrement() (see if-statement around line 465 ). Later on, it calls lookupInCache() to see if an existing connection exists. When this succeeds, however, activeConnectionsCount is not decremented.

In general, keeping these two pieces of state in sync seems tricky and error prone. Maybe it's worth introducing a generic object pooling component?

jfarcand commented 14 years ago

Agree. Next week I will restart full time on this and this need to addressed when implementing issue 29, which is a redesign of that functionality,

jfarcand commented 14 years ago

Fixed

http://github.com/ning/async-http-client/commit/50502fe6dbdc5a35572f5a1c4ee6a8c9bf006447