On Wed, 2003-04-09 at 11:23, Jason Hildebrand wrote:
> I've been poking through the CVS again. I noticed that the
> awake/respond/sleep methods are now called from
> Servlet.runTransaction(). This is great, since it makes it possible to
> throw exceptions from awake(), for example when implementing security
> policy.
>
> Anyways, the code to handle the EndResponse exception (used to implement
> sendRedirectAndEnd) got left out. I'd like to put this logic into
> Servlet.runTransaction() -- maybe it also should be in
> Application.runTransaction for backwards compat?
I think it actually makes sense in Application.runTransaction, which
also handles HTTPException. I found making Application handle
HTTPException was very helpful, as I could throw exceptions even when I
wasn't in the servlet's scope. EndResponse seems a similar situation.
A servlet could still catch EndResponse and re-raise, letting
Application get the exception in the end (or use try:finally:).
> Anyways, I wanted to discuss the policy for exception handling in the
> awake-respond-sleep cycle. The previous policy was:
>
> "During servlet
> processing, if this exception is caught during respond() then
> sleep() is called and the response is sent. If caught during
> awake() then both respond() and sleep() are skipped and the
> response is sent."
>
> I believe that sleep should be called _every_ time -- even when an
> exception was thrown from awake. Otherwise it's not possible for awake
> to set any servlet attributes if it might later on throw an exception,
> which IMO renders sleep largely useless (as a result, I've never used
> sleep, I just re-initialize all stateful servlet attributes in awake().
>
> Since we've been removing other webware warts, I thought I'd bring this
> up.
What you describe certainly sounds like the proper way to me. sleep()
becomes a sort of finally clause, which is useful.
Ian
|