Salut Jerome ;)

We just spend some days debugging some sad side-effect we had between the
ExtDirect servlet and the Restlet servlet and finally found the cause of our
nightmare.

So... I first explain the behavior of restlet, from what I understand after
reading and hacking the code :

- When a request is handled by the RestletServlet, a Message is created to
be exchanged between component
- This Message contains a Representation, in our case it's a
'InputRepresentation'
- This representation had a reference to the InputStream of the servlet
Request

If Restlet is used inside a servlet container (and not standalone) he MUST
NOT care about closing stream, because stream can be reused by the servlet
container (surely for performance reason).

But... when a Message is garbage collected, the destructor call 'release' on
the Representation... and the 'release' code of the InputRepresentation
close the stream.
I'm sure this make sense when Restlet is used in a standalone environment,
but when used in a Servlet container like tomcat -and if it's not the only
Servlet- this can create really bad side effect... like closing stream of
the other Servlet (that use a KeepAlive connection).. when the Message is
collected !

I can't provide you a patch, because I don't know as well the Restlet
architecture as you, but I suppose you can know if you are inside a
container and handling the InputRepresentation release differently ?

For the moment, the workaround we used is to create a Wrapper on the stream,
and disable the 'close' method, we are waiting for a fix in restlet before
removing that workaround.

I hope I was clear enough, feel fry to ask for more informations.

Thanks for your support, and BTW, for your fantastic framework !

Alois Cochard
http://aloiscochard.blogspot.com
http://www.twitter.com/aloiscochard

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

Reply via email to