Hi all,

I've updated the wiki to clarify this best practice, see the last section:
http://wiki.restlet.org/docs_2.0/285-restlet.html

The Javadocs have also been previously clarified before, saying that release() 
should rarely be called:
http://www.restlet.org/documentation/2.0/jee/api/org/restlet/representation/Representation.html#release%28%29

I've clarified this even further in SVN (2.0 and trunk) by adding this 
paragraph:
     * Note that calling this method will likely prevent the reuse of the
     * underlying persistent connection and therefore should only be called when
     * exhausting the content with {...@link #exhaust()} is too costly or when
     * further calls from the client are not welcome.

Hope this clarifies. We can update the wiki/javadocs further based on your 
experienced. If one connector such as Apache HTTP Client 4 doesn't work 
consistently with this description, we can try to fix it. 

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.o​rg
Noelios Technologies ~ http://www.noelios.com





-----Message d'origine-----
De : Rickard Öberg [mailto:[email protected]] 
Envoyé : vendredi 31 décembre 2010 03:18
À : [email protected]
Objet : Re: response.release() versus response.exhaust() in 2.0

On 2010-12-31 05.55, Tal Liron wrote:
> pool.) It's probably best to employ a try-finally paradigm, where the 
> try clause contains as little code as possible, and the finally clause 
> releases the response. See the example below.
>
> var fixture
> var resource = 
> document.external('file:///myfiles/fixture.json','application/json')
> try {
>       fixture = resource.get().text
>
> }
> finally {
>       resource.response.release()
> }

So this, combined with Jerome's reply:
>      >> 1) release() has the effect of closing the underlying TCP
>     socket, preventing persistent connection reuse. So it can't be
>     recommended to systematically call it.

basically means that we can't have persistent connection reuse on the client. 
Correct or not?

/Rickard

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2695100

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2695151

Reply via email to