I've isolated a Struts 2 bug and I would like to suggest a code fix. The code
fix is in an xwork class. I'm don't fully understand the xwork/struts
distinction, but I assume I'm posting to the right list.

Here is the error scenario:

- DefaultActionInvocation calls all Interceptors which wind onto the Java
call stack. Then DefaultActionInvocation calls the actual action itself. The
action returns "success"
- DefaultActionInvocation creates result object from this result code and
executes the result
- There is a problem in my FTL template, so FreeMarker throws a
ParseException
- Call stack unwinds to ExceptionMappingInterceptor which catches the
exception, adds to OGNL value stack and returns "unhandledException"
- DefaultActionInvocation simply re-executes the already created result
object based on the original Action result.
- The caching mechanism within FreeMarker detects a current timestamp and
will either throw a FileNotFoundException (if the page isn't cached) or
returns cached and out-of-date results. In either case, the original
exception is lost and never logged. My exception action is also never
executed.

This seems to be...

A small FreeMarker bug: it should rethrow ParseException when called a
second time.
A larger Struts 2 (or xwork) bug: Struts shouldn't ignore the first
exception and simply rerun the result object. When Struts catches the
original exception from the result, it should call the defined exception
action.


I suggest that the following three lines be removed from
DefaultActionInvocation.java, line 174:

        if (result != null) {
                return result;
        }

I've tested this and I get the desired behavior. My exception action is
called for the original exception. The xwork build reports no additional
automated test failures. I got four test failures trying to build the
standard xwork 2.0.4 distribution before making any changes, however my code
change didn't affect these results. 


Version Info
Java 1.6.0_02
Struts 2.0.9
xwork 2.0.4
-- 
View this message in context: 
http://www.nabble.com/struts-xwork-patch-submission.-Please-Review.-tf4558415.html#a13008842
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to