You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Jammy Chen <ja...@gmail.com> on 2015/08/31 16:54:03 UTC
HttpPost object needs to be explicitly released?
Hi,
Do I need explicitly release HttpPost object?
I am using HttpClient 4.3.6 in multiple-thread environment, I read the
guide from
http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fundamentals.html#d5e74,
but it does not indicates we need call httpPost.releaseConnection() or
httpPost.close().
I know we should consume the HTTP response stream, close the stream, close
the response and also close the HTTP client instance, from the guide above,
it mentioned calling httpResponse.close() it will shutdown the http
connections already.
I am now having problem multiple-thread environment, after using
httpPost.releaseConnection() it works fine, but I am really concerned about
whether we need use it, from the the API doc of
httpPost.releaseConnection(), it says only for convenient http client 3
API.
If it is needed, where should be? after closing HTTP response or before
closing HTTP response.
Thanks for your help
Jammy
Re: HttpPost object needs to be explicitly released?
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2015-08-31 at 23:18 +0800, Jammy Chen wrote:
> Thanks Oleg.
>
> What you said is we do NOT need call httpPost.releaseConnection() and
> httpPost.close(), right?
HttpUriRequest does not have #close method so I have no idea what you
are referring to. One _must_ close the response object but not the
request object.
> if yes, when the HTTP connection will be released
> properly? if I do release, do it have negative impact?
>
> What is the propose of the API httpPost.releaseConnection()?
>
Compatibility with HC 3.x. See Javadocs. Generally one should avoid this
method.
http://hc.apache.org/httpcomponents-client-4.5.x/httpclient/xref/org/apache/http/client/methods/HttpRequestBase.html#114
Oleg
> Jammy
>
>
> 2015-08-31 23:12 GMT+08:00 Oleg Kalnichevski <ol...@apache.org>:
>
> > On Mon, 2015-08-31 at 22:54 +0800, Jammy Chen wrote:
> > > Hi,
> > >
> > > Do I need explicitly release HttpPost object?
> > >
> >
> > No, you do not.
> >
> > Oleg
> >
> > > I am using HttpClient 4.3.6 in multiple-thread environment, I read the
> > > guide from
> > >
> > http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fundamentals.html#d5e74
> > ,
> > > but it does not indicates we need call httpPost.releaseConnection() or
> > > httpPost.close().
> > >
> > > I know we should consume the HTTP response stream, close the stream,
> > close
> > > the response and also close the HTTP client instance, from the guide
> > above,
> > > it mentioned calling httpResponse.close() it will shutdown the http
> > > connections already.
> > >
> > > I am now having problem multiple-thread environment, after using
> > > httpPost.releaseConnection() it works fine, but I am really concerned
> > about
> > > whether we need use it, from the the API doc of
> > > httpPost.releaseConnection(), it says only for convenient http client 3
> > > API.
> > >
> > > If it is needed, where should be? after closing HTTP response or before
> > > closing HTTP response.
> > >
> > > Thanks for your help
> > >
> > > Jammy
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: HttpPost object needs to be explicitly released?
Posted by Jammy Chen <ja...@gmail.com>.
Thanks Oleg.
What you said is we do NOT need call httpPost.releaseConnection() and
httpPost.close(), right? if yes, when the HTTP connection will be released
properly? if I do release, do it have negative impact?
What is the propose of the API httpPost.releaseConnection()?
Jammy
2015-08-31 23:12 GMT+08:00 Oleg Kalnichevski <ol...@apache.org>:
> On Mon, 2015-08-31 at 22:54 +0800, Jammy Chen wrote:
> > Hi,
> >
> > Do I need explicitly release HttpPost object?
> >
>
> No, you do not.
>
> Oleg
>
> > I am using HttpClient 4.3.6 in multiple-thread environment, I read the
> > guide from
> >
> http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fundamentals.html#d5e74
> ,
> > but it does not indicates we need call httpPost.releaseConnection() or
> > httpPost.close().
> >
> > I know we should consume the HTTP response stream, close the stream,
> close
> > the response and also close the HTTP client instance, from the guide
> above,
> > it mentioned calling httpResponse.close() it will shutdown the http
> > connections already.
> >
> > I am now having problem multiple-thread environment, after using
> > httpPost.releaseConnection() it works fine, but I am really concerned
> about
> > whether we need use it, from the the API doc of
> > httpPost.releaseConnection(), it says only for convenient http client 3
> > API.
> >
> > If it is needed, where should be? after closing HTTP response or before
> > closing HTTP response.
> >
> > Thanks for your help
> >
> > Jammy
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Re: HttpPost object needs to be explicitly released?
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2015-08-31 at 22:54 +0800, Jammy Chen wrote:
> Hi,
>
> Do I need explicitly release HttpPost object?
>
No, you do not.
Oleg
> I am using HttpClient 4.3.6 in multiple-thread environment, I read the
> guide from
> http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fundamentals.html#d5e74,
> but it does not indicates we need call httpPost.releaseConnection() or
> httpPost.close().
>
> I know we should consume the HTTP response stream, close the stream, close
> the response and also close the HTTP client instance, from the guide above,
> it mentioned calling httpResponse.close() it will shutdown the http
> connections already.
>
> I am now having problem multiple-thread environment, after using
> httpPost.releaseConnection() it works fine, but I am really concerned about
> whether we need use it, from the the API doc of
> httpPost.releaseConnection(), it says only for convenient http client 3
> API.
>
> If it is needed, where should be? after closing HTTP response or before
> closing HTTP response.
>
> Thanks for your help
>
> Jammy
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org