Author: lukaszlenart
Date: Wed Aug  1 07:11:09 2012
New Revision: 1367870

URL: http://svn.apache.org/viewvc?rev=1367870&view=rev
Log:
WW-3857 changes RestActionMapper to return null if it cannot determine action 
mapping, adds comment to API

Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java
    
struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
    
struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java?rev=1367870&r1=1367869&r2=1367870&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapper.java
 Wed Aug  1 07:11:09 2012
@@ -21,10 +21,10 @@
 
 package org.apache.struts2.dispatcher.mapper;
 
-import javax.servlet.http.HttpServletRequest;
-
 import com.opensymphony.xwork2.config.ConfigurationManager;
 
+import javax.servlet.http.HttpServletRequest;
+
 /**
  * <!-- START SNIPPET: javadoc -->
  *
@@ -51,7 +51,7 @@ public interface ActionMapper {
      *
      * @param request The servlet request
      * @param configManager The current configuration manager
-     * @return The appropriate action mapping
+     * @return The appropriate action mapping or null if mapping cannot be 
determined
      */
     ActionMapping getMapping(HttpServletRequest request, ConfigurationManager 
configManager);
 

Modified: 
struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java?rev=1367870&r1=1367869&r2=1367870&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
 (original)
+++ 
struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
 Wed Aug  1 07:11:09 2012
@@ -289,9 +289,10 @@ public class RestActionMapper extends De
             }
 
             mapping.setName(fullName);
+            return mapping;
         }
-
-        return mapping;
+        // if action name isn't specified, it can be a normal request, to 
static resource, return null to allow handle that case
+        return null;
     }
 
     private void handleDynamicMethodInvocation(ActionMapping mapping, String 
name) {

Modified: 
struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java?rev=1367870&r1=1367869&r2=1367870&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
 Wed Aug  1 07:11:09 2012
@@ -57,6 +57,15 @@ public class RestActionMapperTest extend
         };
     }
 
+    public void testRootMapping() throws Exception {
+        req.setRequestURI("/myapp/");
+        req.setServletPath("/");
+
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertNull(mapping);
+    }
+
     public void testGetMapping() throws Exception {
         req.setRequestURI("/myapp/animals/dog");
         req.setServletPath("/animals/dog");


Reply via email to