I have a patch for http://jira.opensymphony.com/browse/XW-604 and
another issue that i am experiencing. The patch somewhat changes the
behaviour of the exception flow and I would like a small review:

Problem I am fixing:
 DefaultActionInvocation.invoke() invokes entire interceptor chain and
calls invokeActionOnly with the full chain on the stack.
 invokeActionOnly returns success.
 executeResult is invoked and throws an exception (in XW-604 it is
"beforeResult" that throws an exception but with the same effect.)
 Call stack unwinds to ExceptionMappingInterceptor. 
 When ExceptionMappingInterceptor completes, executed is actually FALSE
in the DefaultActionInvocation, meaning that executeResult will be
invoked *again* (with exception again). 
 The stacktrace that flows to the top is actually from the last
exception, and the symptom is that there are no interceptors on the
stacktrace.

My patch is really very simple, i just moved executed=true to the top of
the block, like this:

                // this is needed because the result will be executed,
then control will return to the Interceptor, which will
                // return above and flow through again
                if (!executed) {
             executed = true; // Flag as executed, no matter what
happens below.  // THIS IS THE PATCH. Used to be at the bottom of the if
block.

             if (preResultListeners != null) {
                                for (Iterator iterator =
preResultListeners.iterator();
                                        iterator.hasNext();) {
                                        PreResultListener listener =
(PreResultListener) iterator.next();
                                        
                                        String
_profileKey="preResultListener: ";
                                        try {
 
UtilTimerStack.push(_profileKey);
 
listener.beforeResult(this, resultCode);
                                        }
                                        finally {
 
UtilTimerStack.pop(_profileKey);
                                        }
                                }
                        }

                        // now execute the result, if we're supposed to
             if (proxy.getExecuteResult()) {
               executeResult();
             }
          }




I believe there are no thread safety issues here. 

Comments ?

Kristian Rosenvold

Reply via email to