Commits

Anonymous committed 704df9d

WW-941: fix for starter-2.war provided in jira issue.
Solution requires a new "contextCleanup" option when creating an ActionProxy.
Normally the cleanup should be set to true, except for the outer-most request,
since cleanup can't happen if SiteMesh is going to be participating.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@715e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (6)

src/java/com/opensymphony/xwork/ActionProxyFactory.java

      * @param actionName
      * @param extraContext  a Map of extra parameters to be provided to the ActionProxy
      * @param executeResult flag which tells whether the result should be executed after the action
+     * @param cleanupContext
      * @return
      * @throws Exception
      */
-    public abstract ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult) throws Exception;
+    public abstract ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception;
 }

src/java/com/opensymphony/xwork/DefaultActionProxy.java

     protected String namespace;
     protected String method;
     protected boolean executeResult;
+    protected boolean cleanupContext;
 
     /**
      * This constructor is private so the builder methods (create*) should be used to create an DefaultActionProxy.
      * The reason for the builder methods is so that you can use a subclass to create your own DefaultActionProxy instance
      * (like a RMIActionProxy).
      */
-    protected DefaultActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult) throws Exception {
+    protected DefaultActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception {
+        this.cleanupContext = cleanupContext;
         if (LOG.isDebugEnabled()) {
             LOG.debug("Creating an DefaultActionProxy for namespace " + namespace + " and action name " + actionName);
         }
             retCode = invocation.invoke();
             ActionGlobalContext.getContext().setActionExecuted("Executed");
         } finally {
-            if (executed != null) {
+            if (cleanupContext && executed != null) {
                 ActionContext.setContext(nestedContext);
             }
         }

src/java/com/opensymphony/xwork/DefaultActionProxyFactory.java

      * Use this method to build an DefaultActionProxy instance.
      */
     public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext) throws Exception {
-        return new DefaultActionProxy(namespace, actionName, extraContext, true);
+        return new DefaultActionProxy(namespace, actionName, extraContext, true, true);
     }
 
     /**
      * Use this method to build an DefaultActionProxy instance.
      */
-    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult) throws Exception {
-        return new DefaultActionProxy(namespace, actionName, extraContext, executeResult);
+    public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception {
+        return new DefaultActionProxy(namespace, actionName, extraContext, executeResult, cleanupContext);
     }
 }

src/test/com/opensymphony/xwork/ChainResultTest.java

             return returnVal;
         }
 
-        public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult) throws Exception {
+        public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception {
             TestCase.assertEquals(expectedNamespace, namespace);
             TestCase.assertEquals(expectedActionName, actionName);
 

src/test/com/opensymphony/xwork/interceptor/PreResultListenerTest.java

 
 
     public void testPreResultListenersAreCalled() throws Exception {
-        ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("package", "action", new HashMap(), false);
+        ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("package", "action", new HashMap(), false, true);
         ActionInvocation invocation = proxy.getInvocation();
         Mock preResultListenerMock1 = new Mock(PreResultListener.class);
         preResultListenerMock1.expect("beforeResult", C.args(C.eq(invocation), C.eq(Action.SUCCESS)));
     }
 
     public void testPreResultListenersAreCalledInOrder() throws Exception {
-        ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("package", "action", new HashMap(), false);
+        ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("package", "action", new HashMap(), false, true);
         ActionInvocation invocation = proxy.getInvocation();
         CountPreResultListener listener1 = new CountPreResultListener();
         CountPreResultListener listener2 = new CountPreResultListener();

src/test/com/opensymphony/xwork/util/LocalizedTextUtilTest.java

         LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork/SimpleAction");
 
         try {
-            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("/", "packagelessAction", Collections.EMPTY_MAP, false);
+            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("/", "packagelessAction", Collections.EMPTY_MAP, false, true);
             proxy.execute();
         } catch (Exception e) {
             e.printStackTrace();