Commits

Anonymous committed de27456

WW-2996 Fix memory Leak when SlashesInActionNames is enabled and wildcards are used in actionnames

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

  • Participants
  • Parent commits d152dd2

Comments (0)

Files changed (4)

src/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java

     protected void doBeforeInvocation(ActionInvocation invocation) throws Exception {
         Object action = invocation.getAction();
         ActionProxy proxy = invocation.getProxy();
-        String context = proxy.getActionName();
+        //use the name from the config, instead of the action name
+        //otherwise actions with patterns in the name won't be cached, see WW-2996
+        String context = proxy.getConfig().getName();
         String method = proxy.getMethod();
 
         if (log.isDebugEnabled()) {

src/test/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor2Test.java

 
 import com.opensymphony.xwork2.*;
 import com.opensymphony.xwork2.config.entities.InterceptorConfig;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.validator.ValidationInterceptor;
 import org.easymock.MockControl;
 
 		ActionProxy actionProxy = (ActionProxy) actionProxyControl.getMock();
 		actionProxy.getMethod();
 		actionProxyControl.expectAndDefaultReturn(null, "execute");
-		
-		
-		MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
+
+        ActionConfig config = new ActionConfig.Builder("", "action", "").build();
+
+        MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
 		ActionInvocation actionInvocation = (ActionInvocation) actionInvocationControl.getMock();
 		actionInvocation.invoke();
 		actionInvocationControl.expectAndDefaultReturn(null, "test");
 		actionInvocationControl.expectAndDefaultReturn(null, actionProxy);
 		actionInvocation.getAction();
 		actionInvocationControl.expectAndDefaultReturn(null, action);
-		actionProxy.getActionName();
-		actionProxyControl.expectAndDefaultReturn(null, "action");
-		
+		actionProxy.getConfig();
+		actionProxyControl.expectAndDefaultReturn(null, config);
+
 		actionInvocationControl.replay();
 		actionProxyControl.replay();
 		
 		ActionProxy actionProxy = (ActionProxy) actionProxyControl.getMock();
 		actionProxy.getMethod();
 		actionProxyControl.expectAndDefaultReturn(null, "execute");
-		
+
+        ActionConfig config = new ActionConfig.Builder("", "action", "").build();
 		
 		MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
 		ActionInvocation actionInvocation = (ActionInvocation) actionInvocationControl.getMock();
 		actionInvocationControl.expectAndDefaultReturn(null, actionProxy);
 		actionInvocation.getAction();
 		actionInvocationControl.expectAndDefaultReturn(null, action);
-		actionProxy.getActionName();
-                actionProxyControl.expectAndDefaultReturn(null, "action");
+		actionProxy.getConfig();
+        actionProxyControl.expectAndDefaultReturn(null, config);
 		
 		actionInvocationControl.replay();
 		actionProxyControl.replay();

src/test/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java

 import com.mockobjects.dynamic.Mock;
 import com.opensymphony.xwork2.*;
 import com.opensymphony.xwork2.config.entities.InterceptorConfig;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.validator.ValidationInterceptor;
 
 import java.util.HashMap;
     private Action action;
     private ActionProxy proxy;
     private Mock proxyMock;
+    private ActionConfig config;
 
 
     public void testInvokesActionInvocationIfNoErrors() throws Exception {
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         
         final String result = "testing123";
         proxyMock.expectAndReturn("getMethod", "execute");
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("invoke", result);
         
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
-        proxyMock.expectAndReturn("getActionName", "name");
+        proxyMock.expectAndReturn("getConfig", config);
         proxyMock.expectAndReturn("getMethod", "execute");
         invocationMock.expectAndReturn("getAction", action);
         invocationMock.expectAndReturn("getProxy", proxy);
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        config = new ActionConfig.Builder("", "name", "").build();
         actionMock = new Mock(ValidateAction.class);
         action = (ValidateAction) actionMock.proxy();
         invocationMock = new Mock(ActionInvocation.class);

src/test/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java

 
 import com.opensymphony.xwork2.*;
 import com.opensymphony.xwork2.config.entities.InterceptorConfig;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.validator.ValidationInterceptor;
 import org.easymock.MockControl;
 
 		controlAction.setVoidCallable(1);
 		mockAction.validate();
 		controlAction.setVoidCallable();
+
+        ActionConfig config = new ActionConfig.Builder("", "action", "").build();
 		
 		MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
 		ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
 		mockActionProxy.getMethod();
 		controlActionProxy.setDefaultReturnValue("save");
-		mockActionProxy.getActionName();
-		controlActionProxy.setDefaultReturnValue("something");
+		mockActionProxy.getConfig();
+		controlActionProxy.setDefaultReturnValue(config);
 		
 		MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
 		ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
 		controlAction.setVoidCallable(1);
 		mockAction.validate();
 		controlAction.setVoidCallable();
+
+        ActionConfig config = new ActionConfig.Builder("", "action", "").build();
 		
 		MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
 		ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
 		mockActionProxy.getMethod();
 		controlActionProxy.setDefaultReturnValue("submit");
-		mockActionProxy.getActionName();
-                controlActionProxy.setDefaultReturnValue("something");
+		mockActionProxy.getConfig();
+        controlActionProxy.setDefaultReturnValue(config);
 		
 		MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
 		ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();