Author: cziegeler
Date: Thu Jun 25 07:30:23 2009
New Revision: 788279

URL: http://svn.apache.org/viewvc?rev=788279&view=rev
Log:
SLING-1020 : Fix endless recursion in getResourceSuperType().

Modified:
    
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
    
sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java

Modified: 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=788279&r1=788278&r2=788279&view=diff
==============================================================================
--- 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
 (original)
+++ 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
 Thu Jun 25 07:30:23 2009
@@ -347,7 +347,13 @@
         final String rtPath = resourceTypeToPath(resourceType);
         // get the resource type resource
         final Resource rtResource = resourceResolver.getResource(rtPath);
-        return (rtResource == null ? null : rtResource.getResourceSuperType());
+        // check for endless recursion
+        if ( rtResource != null ) {
+            if ( !resourceType.equals(rtResource.getResourceType()) ) {
+                return rtResource.getResourceSuperType();
+            }
+        }
+        return null;
     }
 
     /**

Modified: 
sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java?rev=788279&r1=788278&r2=788279&view=diff
==============================================================================
--- 
sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java
 (original)
+++ 
sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java
 Thu Jun 25 07:30:23 2009
@@ -260,6 +260,8 @@
             allowing(r2).getResourceType(); will(returnValue("a:c"));
             allowing(r2).getResourceResolver(); will(returnValue(resolver));
 
+            allowing(typeResource).getResourceType();
+            will(returnValue("x:y"));
             allowing(typeResource).getResourceSuperType();
             will(returnValue("t:c"));
 


Reply via email to