RE: [Webwork-devel] Action load error handling in ServletDispatcher...
Brought to you by:
baldree,
rickardoberg
From: <ma...@sm...> - 2002-05-23 12:47:20
|
Thanks for the clarification. Let me take a further look. -Matt On Thu, 23 May 2002, "Joel Peach" wrote > > Matt, group, et. al, > > I think this possibility to create a looping condition exists everywhere. If any action which returns an error loops back to the same action and the underlying error reason(invalid/corrupt state or what have you) has not changed, error will be continually returned. > > In fact, if I understand what you're saying correctly, you're confirming my point to some degree: that basically, when the action is instantiated by the factory, any exceptions that are generated will result in a 500-series status code being returned to the browser. The exception is for any exceptions that are thrown in setters when processed by BeanUtil in the ParametersActionFactoryProxy. These exceptions are trapped by the BeanUtil's setProperties method (all Throwable, actually.) If the exception is an IllegalArgumentException and the action is IllegalArgumentAware, the error is set to the action and processing continues, otherwise, *all* throwables are re-wrapped as IllegalArgumentException and thrown back to the ParametersActionFactoryProxy. > > The dutiful ParametersActionFactoryProxy catches any IllegalArgumentExceptions that result from BeanUtil.setProperties and rethrows the exception as a new ResultException(Action.ERROR). This exception will be trapped by the "catch(Exception ex)" block in the servlet dispatcher and generate the HTTP 500-series error code to the browser, instead of mapping back to the error view. (Or another specified view.) > > The situation you've described where the field errors work correctly in FormTest.java happens by virtue of the action being IllegalArgumentAware, not because ServletDispatcher handles ResultException in the documented fashion. > > I still think it would be valuable to provide for ResultException handling, or some mechanism that allows proxies in the action factory chain to short-circuit action excecution to return a view to the user. Not having this seems to negate much of the flexibility and extensibility the action factory proxy should allow. > > What do you think ? (Jedi-hand wave...this is a great idea) > > -Joel > > -----Original Message----- > From: Matt Baldree [mailto:ma...@sm...] > Sent: Thu 5/16/2002 11:42 PM > To: Joel Peach; web...@li... > Cc: > Subject: Re: [Webwork-devel] Action load error handling in ServletDispatcher... > > > > see comments below > > ----- Original Message ----- > From: "Joel Peach" <jp...@tr...> > To: <web...@li...> > Sent: Tuesday, May 07, 2002 9:38 AM > Subject: [Webwork-devel] Action load error handling in ServletDispatcher... > > > > Developers, > > > > I'm in the process of creating a custom action factory proxy to handle > authentication and authorization requirements in our system that can't be > serviced by container-managed auth. I've noticed a potential issue in the > way ServletDispatcher handles errors from the ActionFactoryProxy chain when > loading the action and wanted to bring it to your attention as I create a > patch. > > > > The problem with the patch is the scenario where you may be trying to go to > the action which failed to be created. For instance ERROR might map to the > action that threw the exception. The way it is now, you can map back to the > same action and everything is fine. > > > I've looked through the commit logs and the archives of this list and > haven't been able to find much in the way of how errors are to be addressed > in the ActionFactoryProxy chain. Looking at ServletDispatcher, it seems when > ActionFactory.getAction() is called, all Exceptions are trapped and a 404 > error is sent back to the browser via the servlet response. > > > > However, in ParametersActionFactoryProxy, a patch was committed (revision > 1.7) to trap IllegalArgumentException while setting the action properties > and propogate them to the ServletDispatcher as a ResultException. The > comment to the commit and in the source file for > ParametersActionFactoryProxy indicate that the ResultException is to result > in the error view getting displayed for the action. Unfortunately, with the > way ServletDispatcher is handling exceptions at this point, the expected > behavior will never occur. > > Hmm. It works. I checked in the FormTest where it throws > IllegalArgumentException instead of using doValidate(). Take a look at it. > > > > > I'm wondering if I'm missing some subtlety of exception handling for the > action factory proxy chain or if the ServletDispatcher is in need of a way > to flexibly handle errors that occur as the Action is being instantiated? > > > > As I've been working on this patch, I've encountered some difficulty > resulting from the structure of ServletDispatcher's service() method and > that the action variable in that method is declared final. As far as I can > tell the declaration of the action variable as final is to prevent code > further down in the method from overwriting the variable after it has been > loaded. Can anyone please shed light on this? > > > > Help much appreciated and I look forward to being able to help out, > > > > -Joel > > > > > > > > > > =================== > > Joel Peach > > Tracerdigital, LLC > > 7632 Choctaw Place > > Columbus, OH > > United States > > p: (614) 540-3055 > > e: jp...@tr... > > n()ފJqhᮧzج$xhyhi +ge ^ bދzaz۷ *'fⶢKjwpa۲q z՞o > > +ׯzYXXgŠu ޖX(˺~zw୆i۳ l˲q z l X)ߣo > > + > > > > |