You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by as...@apache.org on 2015/07/15 11:09:08 UTC

svn commit: r1691149 - /sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java

Author: asanso
Date: Wed Jul 15 09:09:08 2015
New Revision: 1691149

URL: http://svn.apache.org/r1691149
Log:
SLING-4882 - Shared session usage in Sling MapEntries causes contention

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java?rev=1691149&r1=1691148&r2=1691149&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java Wed Jul 15 09:09:08 2015
@@ -860,12 +860,23 @@ public class MapEntries implements Event
         // sling:vanityPath (lowercase) is the property name        
         final String queryString = "SELECT sling:vanityPath, sling:redirect, sling:redirectStatus FROM sling:VanityPath WHERE sling:vanityPath ="
                 + "'"+escapeIllegalXpathSearchChars(vanityPath).replaceAll("'", "''")+"' OR sling:vanityPath ="+ "'"+escapeIllegalXpathSearchChars(vanityPath.substring(1)).replaceAll("'", "''")+"' ORDER BY sling:vanityOrder DESC";
-        final Iterator<Resource> i = resolver.findResources(queryString, "sql");
+        
+        ResourceResolver queryResolver = null;
 
-        while (i.hasNext()) {
-            final Resource resource = i.next();
-            loadVanityPath(resource, entryMap, targetPaths, true, false);
-        }        
+        try {
+            queryResolver = factory.getAdministrativeResourceResolver(null);
+            final Iterator<Resource> i = queryResolver.findResources(queryString, "sql");
+            while (i.hasNext()) {
+                final Resource resource = i.next();
+                loadVanityPath(resource, entryMap, targetPaths, true, false);
+            }
+        } catch (LoginException e) {
+            log.error("Exception while obtaining queryResolver", e);
+        } finally {
+            if (queryResolver != null) {
+                queryResolver.close();
+            }
+        }
         return entryMap;        
     }