diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java index d62da32197..c7864571f1 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java +++ b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java @@ -77,15 +77,19 @@ public ActionContext bind() { return this; } - @Override public ActionContext withActionInvocation(ActionInvocation actionInvocation) { + return withActionInvocation((org.apache.struts2.ActionInvocation) actionInvocation); + } + + @Override + public ActionContext withActionInvocation(org.apache.struts2.ActionInvocation actionInvocation) { super.withActionInvocation(actionInvocation); return this; } @Override public ActionInvocation getActionInvocation() { - return super.getActionInvocation(); + return ActionInvocation.adapt(super.getActionInvocation()); } @Override diff --git a/core/src/main/java/org/apache/struts2/ActionContext.java b/core/src/main/java/org/apache/struts2/ActionContext.java index 8f155cc068..bfde35f124 100644 --- a/core/src/main/java/org/apache/struts2/ActionContext.java +++ b/core/src/main/java/org/apache/struts2/ActionContext.java @@ -18,8 +18,6 @@ */ package org.apache.struts2; -import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.conversion.impl.ConversionData; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.util.ValueStack; diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java index 9678b600eb..0319ca7ccb 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java @@ -403,6 +403,7 @@ public void testActionWithoutExecuteResult_clearTagStateSet() throws Exception { public void testExecuteButResetReturnSameInvocation() throws Exception { Mock mockActionInv = new Mock(ActionInvocation.class); + mockActionInv.matchAndReturn("invoke", "TEST"); ActionTag tag = new ActionTag(); tag.setPageContext(pageContext); tag.setNamespace(""); @@ -419,7 +420,7 @@ public void testExecuteButResetReturnSameInvocation() throws Exception { ActionComponent component = (ActionComponent) tag.getComponent(); tag.doEndTag(); - assertSame(oldInvocation, ActionContext.getContext().getActionInvocation()); + assertEquals(oldInvocation.invoke(), ActionContext.getContext().getActionInvocation().invoke()); // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag(). ActionTag freshTag = new ActionTag(); @@ -432,6 +433,7 @@ public void testExecuteButResetReturnSameInvocation() throws Exception { public void testExecuteButResetReturnSameInvocation_clearTagStateSet() throws Exception { Mock mockActionInv = new Mock(ActionInvocation.class); + mockActionInv.matchAndReturn("invoke", "TEST"); ActionTag tag = new ActionTag(); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. tag.setPageContext(pageContext); @@ -450,7 +452,7 @@ public void testExecuteButResetReturnSameInvocation_clearTagStateSet() throws Ex ActionComponent component = (ActionComponent) tag.getComponent(); tag.doEndTag(); - assertTrue(oldInvocation == ActionContext.getContext().getActionInvocation()); + assertEquals(oldInvocation.invoke(), ActionContext.getContext().getActionInvocation().invoke()); // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag(). ActionTag freshTag = new ActionTag();