jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1382041 - in /jackrabbit/oak/trunk: oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/ oak-core/src/test/resources/org/apache/jackrabbit/oak/query/
Date Fri, 07 Sep 2012 14:22:11 GMT
Author: mduerig
Date: Fri Sep  7 14:22:10 2012
New Revision: 1382041

URL: http://svn.apache.org/viewvc?rev=1382041&view=rev
Log:
OAK-296: PathUtils.isAncestor("/", "/") should return false but returns true

Modified:
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
    jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java?rev=1382041&r1=1382040&r2=1382041&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
Fri Sep  7 14:22:10 2012
@@ -16,10 +16,11 @@
  */
 package org.apache.jackrabbit.oak.commons;
 
-import javax.annotation.Nonnull;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import javax.annotation.Nonnull;
+
 /**
  * Utility methods to parse a path.
  * <p/>
@@ -288,7 +289,12 @@ public class PathUtils {
         if (ancestor.isEmpty() || path.isEmpty()) {
             return false;
         }
-        if (!denotesRoot(ancestor)) {
+        if (denotesRoot(ancestor)) {
+            if (denotesRoot(path)) {
+                return false;
+            }
+        }
+        else {
             ancestor += "/";
         }
         return path.startsWith(ancestor);

Modified: jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java?rev=1382041&r1=1382040&r2=1382041&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
(original)
+++ jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
Fri Sep  7 14:22:10 2012
@@ -196,6 +196,9 @@ public class PathTest extends TestCase {
         assertEquals(false, PathUtils.isAbsolute(parent + "/" + child));
 
         // isAncestor
+        assertFalse(PathUtils.isAncestor("/", "/"));
+        assertFalse(PathUtils.isAncestor("/" + parent, "/" + parent));
+        assertFalse(PathUtils.isAncestor(parent, parent));
         assertTrue(PathUtils.isAncestor("/", "/" + parent));
         assertTrue(PathUtils.isAncestor(parent, parent + "/" + child));
         assertFalse(PathUtils.isAncestor("/", parent + "/" + child));

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt?rev=1382041&r1=1382040&r2=1382041&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
Fri Sep  7 14:22:10 2012
@@ -109,7 +109,6 @@ select * from [nt:base] as b where local
 /test/resource
 
 select * from [nt:base] as x where isdescendantnode(x, '/') and not isdescendantnode(x, '/jcr:system')
-/
 /jcr:system
 /oak-index
 /oak-index/indexes



Mime
View raw message