I just found the root of the problem.

We're using Spring's RestTemplate to make the HTTP calls, and if a response 
extractor is not specified (which is the case for a put (because by default 
there is not response) the input stream is never closed. I'm not sure how I'm 
going to fix that because it's in a method I can't just override.

Thanks for your help.

Maurice

-----Original Message-----
From: Oleg Kalnichevski [mailto:[email protected]] 
Sent: mercredi 17 décembre 2014 13:44
To: HttpClient User Discussion
Subject: Re: PoolingHttpClientConnectionManager leaking connections

On Wed, 2014-12-17 at 10:45 +0000, Maurice MILLS wrote:
> Ok, and how do I get ahold of the connection?  It's hidden deep down inside 
> the inner workings and not accessible to the outside world.
> 
> Here is what I did, but it doesn't seem right:
> 
>         PoolingHttpClientConnectionManager httpConnectionManager = new 
> PoolingHttpClientConnectionManager();
>         HttpUrlRequest httpMethod = <HttpGet / HttpPut / etc.>
>         CloseableHttpClient httpClient = HttpClientBuilder.create().build();
>         BasicHttpContext context = new BasicHttpContext();
>         CloseableHttpResponse response = httpClient.execute(httpMethod, 
> context);
>         ...  Treat the response ...
>         HttpClientConnection httpConnection = (HttpClientConnection) 
> context.getAttribute(HttpClientContext.HTTP_CONNECTION);
>         httpConnectionManager.releaseConnection(httpConnection, null, 
> 0, TimeUnit.MILLISECONDS);
> 
> Do you have a better solution?
> 

Maurice

Connections are intentionally not easily accessible. All you need to do to 
ensure proper resource deallocation is to call
CloseableHttpResponse#close() from a finally clause.

Oleg


> Thanks,
> Maurice
> 
> -----Original Message-----
> From: Stefan Magnus Landrø [mailto:[email protected]]
> Sent: mardi 16 décembre 2014 19:03
> To: HttpClient User Discussion
> Subject: Re: PoolingHttpClientConnectionManager leaking connections
> 
> Connmgr.releaseConnection
> 
> Sendt fra min iPhone
> 
> > Den 16. des. 2014 kl. 18.25 skrev Maurice MILLS 
> > <[email protected]>:
> > 
> > I don't want to put an invalid connection back into the pool.  I want to 
> > put the connection I just finished using, that should still be valid, back 
> > into the pool so I can reuse it again.
> > 
> > -----Original Message-----
> > From: Oleg Kalnichevski [mailto:[email protected]]
> > Sent: mardi 16 décembre 2014 18:06
> > To: HttpClient User Discussion
> > Subject: RE: PoolingHttpClientConnectionManager leaking connections
> > 
> >> On December 16, 2014 5:52:16 PM GMT+01:00, Maurice MILLS 
> >> <[email protected]> wrote:
> >> Hello Oleg,
> >> 
> >> I'm sorry, I misstated the problem.  The problem is that in the 
> >> sequence below, the connection is closed and not put back into the 
> >> pool for reuse (which remains open until it is closed after the 
> >> TIME_WAIT expires).
> >> 
> >> How can I just put the connection back into the list of available 
> >> connections so it can be reused?  I don't see anywhere in the 
> >> objects available to do that.
> >> 
> >> Thanks,
> >> Maurice
> >> 
> >> For additional commands, e-mail: 
> >> [email protected]
> >> 
> >> 
> >> 
> >> 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.
> > 
> > Why would you put an invalid connection back to the pool?
> > 
> > Oleg
> > Sent from my Android device with K-9 Mail. Please excuse my brevity.
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> > 
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to