Nic Ferrier wrote:
>
> > "Christopher K. St. John" <[EMAIL PROTECTED]> 02-Nov-00 3:07:02 PM
> >
> > Is it legal to block in destroy()
> > until the socket conversation is over? Presumbably not.
>
> Yes... it's legal. That's what it's for. Think about SQL/JDBC which
> was much in vogue when Servlet destory's were first being used. In
> that case the JDBC Connection (a Socket generally) has to be cleaned
> up... it might be in the middle of something so you synchronize it.
>

 There's a difference. Waiting for a conversation on the
socket to finish is potentially an unbounded wait. Waiting
for the socket, or a db connection, to close is (presumably)
a bounded wait.

 Having an unbounded wait in a destroy()/contextDestroyed()
call would have to be considered a pretty hostile thing
to do, especially since java's thread handling weakness
means there's little the container can do about it.

 Whether it's ok to just close() the socket unconditionally
during destroy() depends on what sort of protocol the client
and server are using. If it's not OK, then you're hosed.

 Not allowing for the edge cases, no matter how unlikely
they seem, is a bad thing, especially in a multithreading
context.

 Example: On shutdown, the version of Tomcat I'm running
calls all the servlet destroy() methods in order, in the
same thread. A servlet with an unbounded wait in destroy()
will delay the shutdown calls to all the other servlets.
Coding the container to allow for that possibility is a
royal pain, especially since I suspect there's no 100%
pure java solution that will solve the problem.

 I think this gets back to the difference between servlets-
as-http-front-ends and servlets-as-self-contained-webapps.
A webapp shouldn't contain resources that have a different
lifetime than the webapp itself.


-cks

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to