I am using HttpComponents 4.3.1 in my project and have recently run into a 
problem where PoolingHttpClientConnectionMananger is leaking HTTP connections.  
Normally this doesn't pose a problem because they are cleaned up after 60 
seconds of TIME_WAIT, however we are creating > 30k threads and this is causing 
us to pass the limit of available ports for the client machine and the threads 
start failing.

In my code I use an HttpPut to call my server.  As described in the 
documentation when I'm done, I do a reset().  Below is the stack trace that 
shows where the problem is (PrsClientHttpResponse is my class):

PoolingHttpClientConnectionManager.releaseConnection(HttpClientConnection, 
Object, long, TimeUnit) line: 280
ConnectionHolder.abortConnection() line: 132
ConnectionHolder.cancel() line: 141
HttpPut(AbstractExecutionAwareRequest).cancelExecution() line: 99
HttpPut(AbstractExecutionAwareRequest).reset() line: 167
PrsClientHttpResponse.close() line: 87

Steps:
-------

1.       ConnectionHolder line 141 calls ConnectionHolder.abortConnection()

2.       ConnectionHolder line 125 (in abortConnection) calls 
managedConn.shutdown to close the connection

3.       ConnectionHolder line 132 (in the finally of abortConnection) then 
calls manager.releaseConnection to release the connection

4.       PoolingHttpClientConnectionManager line 280 calls pool.release with 
the 2nd parameter = false (because the connection was just closed)

5.       CPool line 311 removes the entry from the list of leased connections

6.       CPool line 314 is false, so the entry is not readded to the list of 
available connections (and therefore no longer referenced by the pool to be 
cleaned up later)

I have not found any methods on the classes that allow me do anything other 
than what I have described.  Am I doing something wrong?

Thanks,
Maurice






This message and any attachments (the "message") is
intended solely for the intended addressees and is confidential. 
If you receive this message in error,or are not the intended recipient(s), 
please delete it and any copies from your systems and immediately notify
the sender. Any unauthorized view, use that does not comply with its purpose, 
dissemination or disclosure, either whole or partial, is prohibited. Since the 
internet 
cannot guarantee the integrity of this message which may not be reliable, BNP 
PARIBAS 
(and its subsidiaries) shall not be liable for the message if modified, changed 
or falsified. 
Do not print this message unless it is necessary,consider the environment.

----------------------------------------------------------------------------------------------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le "message") 
sont etablis a l'intention exclusive de ses destinataires et sont confidentiels.
Si vous recevez ce message par erreur ou s'il ne vous est pas destine,
merci de le detruire ainsi que toute copie de votre systeme et d'en avertir
immediatement l'expediteur. Toute lecture non autorisee, toute utilisation de 
ce message qui n'est pas conforme a sa destination, toute diffusion ou toute 
publication, totale ou partielle, est interdite. L'Internet ne permettant pas 
d'assurer
l'integrite de ce message electronique susceptible d'alteration, BNP Paribas 
(et ses filiales) decline(nt) toute responsabilite au titre de ce message dans 
l'hypothese
ou il aurait ete modifie, deforme ou falsifie. 
N'imprimez ce message que si necessaire, pensez a l'environnement.

Reply via email to