incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1483299 - in /sling/trunk/bundles/resourceresolver/src: main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
Date Thu, 16 May 2013 11:30:33 GMT
Author: asanso
Date: Thu May 16 11:30:33 2013
New Revision: 1483299

URL: http://svn.apache.org/r1483299
Log:
SLING-2872 - StringIndexOutOfBoundsException in resource resolver:

* applied patch

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
    sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java?rev=1483299&r1=1483298&r2=1483299&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
Thu May 16 11:30:33 2013
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.resourceresolver.impl.ResourceResolverImpl;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -38,6 +39,9 @@ import org.slf4j.LoggerFactory;
  */
 public class MapEntry implements Comparable<MapEntry> {
 
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+	
     private static final Pattern[] URL_WITH_PORT_MATCH = {
         Pattern.compile("http/([^/]+)(\\.[^\\d/]+)(/.*)?$"),
         Pattern.compile("https/([^/]+)(\\.[^\\d/]+)(/.*)?$") };
@@ -265,7 +269,11 @@ public class MapEntry implements Compara
             final String[] redirects = getRedirect();
             final String[] results = new String[redirects.length];
             for (int i = 0; i < redirects.length; i++) {
-                results[i] = m.replaceFirst(redirects[i]);
+            	try{
+            		 results[i] = m.replaceFirst(redirects[i]);
+            	}catch(StringIndexOutOfBoundsException siob){
+            		log.debug("Exception while replacing, ignoring entry {} ",redirects[i],siob);
+             	}               
             }
             return results;
         }

Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java?rev=1483299&r1=1483298&r2=1483299&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
Thu May 16 11:30:33 2013
@@ -325,7 +325,7 @@ public class MockedResourceResolverImplT
         Dictionary<String, Object> properties = new Hashtable<String, Object>();
         properties.put("resource.resolver.virtual", new String[] { "/:/" });
         properties.put("resource.resolver.mapping", new String[] { "/:/",
-            "/content/:/", "/system/docroot/:/" });
+            "/content/:/", "/system/docroot/:/", "/content.html-/$" });
         properties.put("resource.resolver.allowDirect", true);
         properties.put("resource.resolver.searchpath", new String[] { "/apps",
             "/libs" });
@@ -463,6 +463,10 @@ public class MockedResourceResolverImplT
         // test path mapping without a request.
         path = resourceResolver.map("/factory/test");
         Assert.assertEquals("/factory/test", path);
+        
+        buildResource("/content", EMPTY_RESOURCE_LIST, resourceResolver, factoryResourceProvider);
+        path = resourceResolver.map("/content.html");
+        Assert.assertEquals("/content.html", path);
 
     }
 



Mime
View raw message