Hi Oleg

> HttpClient keeps connections alive (open) infinitely unless told
> otherwise, as it has no way of knowing when those connections may be
> needed again. It is a responsibility of the application to make sure
> open connections get closed if they are no longer needed. The
> recommended way of doing that is by calling #closeIdleConnections()
> method on the connection manager or by shutting it down.

Thanks für your answer.
I will try to make 'my conclusions'.
Since I am using the SimpleHttpConnectionManager that is not thread safe
(in a multi thread environment as a servlet container as tomcat is) I 
correctly do use the instance of the simple http-connection manager only as a 
local
variable that will be garbage collected after my http request has been made.

But, to release ALL used internal resources it is not sufficient to allocate 
the instance
of the simple http-connection manager just locally, I also do need to use
#closeIdleConnection (after a #releaseConnection) to free these network
resources as well. (I checked this also looking into the code of the
simple http-connection manager.)
Correct?

Regards

Armin

------------------------------------
> > > My Code (simplified):
> > > this code ist executed for every single request
> > > 
> > > HttpConnectionManager connectionManager = new 
> > > SimpleHttpConnectionManager();
> > > HttpClient client = new HttpClient(clientParams, connectionManager);
> > > client.setHostConfiguration(hostConfiguration);
> > > HttpMethod method =  = new GetMethod();
> > > method.setQueryString(pairs);
> > > method.setPath(pUrl.getPath());
> > > method.setParams(methodParams);
> > > try {
> > >   client.executeMethod(method);
> > > } catch (Exception e) {
> > >   failed = true;
> > >   throw new Exception(...);
> > > } finally {
> > >   if (failed) { 
> > >                   method.abort();
> > >           method.releaseConnection();
> > >   }
> > >   
> > >   client.setHttpConnectionManager(null);
> > >   client = null;
> > > }
> > > 
> > > try {
> > >   responseString = method.getResponseBodyAsString();
> > > } catch (Exception e) {
> > >   throw new Exception(...);
> > > } finally {
> > >   method.releaseConnection();
> > >   method = null;
> > > }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to