jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1492648 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
Date Thu, 13 Jun 2013 12:44:51 GMT
Author: mreutegg
Date: Thu Jun 13 12:44:51 2013
New Revision: 1492648

URL: http://svn.apache.org/r1492648
Log:
OAK-870: Session.getNode/Property/Item() with relative path throws IllegalArgumentException

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1492648&r1=1492647&r2=1492648&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Thu Jun 13 12:44:51 2013
@@ -106,7 +106,11 @@ public class SessionImpl implements Jack
 
     @Nonnull
     private String getOakPathOrThrow(String absPath) throws RepositoryException {
-        return sessionContext.getOakPathOrThrow(absPath);
+        String p = sessionContext.getOakPathOrThrow(absPath);
+        if (!PathUtils.isAbsolute(p)) {
+            throw new RepositoryException("Not an absolute path: " + absPath);
+        }
+        return p;
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java?rev=1492648&r1=1492647&r2=1492648&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
Thu Jun 13 12:44:51 2013
@@ -123,5 +123,37 @@ public class CRUDTest extends AbstractRe
             s.getRootNode().addNode("a", "nt:folder").addNode("b");
             s.save();        
     }
-    
+
+    @Test
+    public void getNodeWithRelativePath() throws RepositoryException {
+        Session s = getAdminSession();
+        try {
+            s.getNode("some-relative-path");
+            fail("Session.getNode() with relative path must throw a RepositoryException");
+        } catch (RepositoryException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void getPropertyWithRelativePath() throws RepositoryException {
+        Session s = getAdminSession();
+        try {
+            s.getProperty("some-relative-path");
+            fail("Session.getProperty() with relative path must throw a RepositoryException");
+        } catch (RepositoryException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void getItemWithRelativePath() throws RepositoryException {
+        Session s = getAdminSession();
+        try {
+            s.getItem("some-relative-path");
+            fail("Session.getItem() with relative path must throw a RepositoryException");
+        } catch (RepositoryException e) {
+            // expected
+        }
+    }
 }



Mime
View raw message