sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1728136 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
Date Tue, 02 Feb 2016 14:49:01 GMT
Author: rombert
Date: Tue Feb  2 14:49:00 2016
New Revision: 1728136

URL: http://svn.apache.org/viewvc?rev=1728136&view=rev
Log:
SLING-5463 - GetStarTest fails with "Invalid name or path"

Revert to using a try-catch around getItem and getItemOrNull calls, since some
calls with invalid JCR paths propagate to the JcrItemResourceFactory.

This might hide repository errors which are not related to a path being
invalid, but

1. This was the previous behaviour
2. We are expecting Oak to introduce use a fine-grained exception for
invalid paths ( no Jira issue yet )

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java?rev=1728136&r1=1728135&r2=1728136&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
Tue Feb  2 14:49:00 2016
@@ -171,22 +171,26 @@ public class JcrItemResourceFactory {
     }
 
     Item getItemOrNull(String path) throws RepositoryException {
-        Item item;
         // Check first if the path is absolute. If it isn't, then we return null because
the previous itemExists method,
         // which was replaced by this method, would have returned null as well (instead of
throwing an exception).
         if (path.isEmpty() || path.charAt(0) != '/') {
-            item = null;
+            return null;
         }
-        // Use fast getItemOrNull if session is a JackrabbitSession
-        else if (session instanceof JackrabbitSession) {
-            item = ((JackrabbitSession) session).getItemOrNull(path);
-        }
-        // Fallback to slower itemExists & getItem pattern
-        else if (session.itemExists(path)) {
-            item = session.getItem(path);
-        } else {
-            item = null;
+
+        Item item = null;
+        try {
+         // Use fast getItemOrNull if session is a JackrabbitSession
+            if (session instanceof JackrabbitSession) {
+                item = ((JackrabbitSession) session).getItemOrNull(path);
+            }
+            // Fallback to slower itemExists & getItem pattern
+            else if (session.itemExists(path)) {
+                item = session.getItem(path);
+            }
+        } catch (RepositoryException e) {
+            log.debug("Unable to access item at " + path + ", possibly invalid path", e);
         }
+
         return item;
     }
 



Mime
View raw message