Index: src/main/java/org/apache/jackrabbit/core/security/authorization/acl/CachingEntryCollector.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/security/authorization/acl/CachingEntryCollector.java	(revision 1348873)
+++ src/main/java/org/apache/jackrabbit/core/security/authorization/acl/CachingEntryCollector.java	(working copy)
@@ -16,17 +16,16 @@
  */
 package org.apache.jackrabbit.core.security.authorization.acl;
 
+import javax.jcr.RepositoryException;
+
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.cache.GrowingLRUMap;
+import org.apache.jackrabbit.core.cache.ConcurrentCache;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.security.authorization.AccessControlModifications;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.RepositoryException;
-import java.util.Map;
-
 /**
  * <code>CachingEntryCollector</code> extends <code>EntryCollector</code> by
  * keeping a cache of ACEs per access controlled nodeId.
@@ -43,7 +42,7 @@
      * nodeID (key). The map only contains an entry if the corresponding Node
      * is access controlled.
      */
-    private final Map<NodeId, Entries> cache;
+    private final ConcurrentCache<NodeId, Entries> cache;
     private final Object monitor = new Object();
 
     /**
@@ -53,7 +52,6 @@
      * @param rootID The id of the root node.
      * @throws RepositoryException If an error occurs.
      */
-    @SuppressWarnings("unchecked")    
     CachingEntryCollector(SessionImpl systemSession, NodeId rootID) throws RepositoryException {
         super(systemSession, rootID);
 
@@ -69,15 +67,14 @@
 
         log.info("Creating cache with max size of: " + maxsize);
 
-        cache = new GrowingLRUMap(1024, maxsize);
+        cache = new ConcurrentCache<NodeId, Entries>("CachingEntryCollector");
+        cache.setMaxMemorySize(maxsize);
     }
 
     @Override
     protected void close() {
         super.close();
-        synchronized (monitor) {
-            cache.clear();
-        }
+        cache.clear();
     }
 
     //-----------------------------------------------------< EntryCollector >---
@@ -86,16 +83,13 @@
      */
     @Override    
     protected Entries getEntries(NodeImpl node) throws RepositoryException {
-        Entries entries;
         NodeId nodeId = node.getNodeId();
-        synchronized (monitor) {
-            entries = cache.get(nodeId);
-            if (entries == null) {
-                // fetch entries and update the cache
-                entries = updateCache(node);
-            } else {
-                log.debug("Cache hit for nodeId {}", nodeId);
-            }
+        Entries entries = cache.get(nodeId);
+        if (entries == null) {
+            // fetch entries and update the cache
+            entries = updateCache(node);
+        } else {
+            log.debug("Cache hit for nodeId {}", nodeId);
         }
         return entries;
     }
@@ -105,16 +99,13 @@
      */
     @Override
     protected Entries getEntries(NodeId nodeId) throws RepositoryException {
-        Entries entries;
-        synchronized (monitor) {
-            entries = cache.get(nodeId);
-            if (entries == null) {
-                // fetch entries and update the cache
-                NodeImpl n = getNodeById(nodeId);
-                entries = updateCache(n);
-            } else {
-                log.debug("Cache hit for nodeId {}", nodeId);
-            }
+        Entries entries = cache.get(nodeId);
+        if (entries == null) {
+            // fetch entries and update the cache
+            NodeImpl n = getNodeById(nodeId);
+            entries = updateCache(n);
+        } else {
+            log.debug("Cache hit for nodeId {}", nodeId);
         }
         return entries;
     }
@@ -128,7 +119,10 @@
      * @throws RepositoryException If an error occurs.
      */
     private Entries updateCache(NodeImpl node) throws RepositoryException {
-        Entries entries = super.getEntries(node);
+        Entries entries;
+        synchronized (monitor) {
+            entries = super.getEntries(node);
+        }
         if (!entries.isEmpty()) {
             // find the next access control ancestor in the hierarchy
             // 'null' indicates that there is no ac-controlled ancestor.
@@ -150,7 +144,7 @@
             // adjust the 'nextId' to point to the next access controlled
             // ancestor node instead of the parent and remember the entries.
             entries.setNextId(nextId);
-            cache.put(node.getNodeId(), entries);
+            cache.put(node.getNodeId(), entries, 1);
 
             log.debug("Update cache for node {}: {}", node, entries);
         } // else: not access controlled -> ignore.
@@ -190,7 +184,6 @@
             }
             NodeId nodeId = (NodeId) key;
             int type = modifications.getType(nodeId);
-            synchronized (monitor) {
                 if ((type & POLICY_ADDED) == POLICY_ADDED) {
                     // clear the complete cache since the nextAcNodeId may
                     // have changed due to the added acl.
@@ -218,7 +211,6 @@
                     cache.clear();
                     break; // no need for further processing.
                 }
-            }
         }
         super.notifyListeners(modifications);
     }
