jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r481196 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
Date Fri, 01 Dec 2006 09:21:06 GMT
Author: stefan
Date: Fri Dec  1 01:21:05 2006
New Revision: 481196

URL: http://svn.apache.org/viewvc?view=rev&rev=481196
Log:
JCR-619: applied patch cacheManager7.txt that fixes dead lock issue

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java?view=diff&rev=481196&r1=481195&r2=481196
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/MLRUItemStateCache.java
Fri Dec  1 01:21:05 2006
@@ -93,8 +93,8 @@
      * {@inheritDoc}
      */
     public ItemState retrieve(ItemId id) {
+        touch();
         synchronized (cache) {
-            touch();
             Entry entry = (Entry) cache.remove(id);
             if (entry != null) {
                 // 'touch' item, by adding at end of list
@@ -110,8 +110,8 @@
      * {@inheritDoc}
      */
     public void update(ItemId id) {
+        touch();
         synchronized (cache) {
-            touch();
             Entry entry = (Entry) cache.get(id);
             if (entry != null) {
                 totalMem -= entry.size;
@@ -125,8 +125,8 @@
      * {@inheritDoc}
      */
     public void cache(ItemState state) {
+        touch();
         synchronized (cache) {
-            touch();
             ItemId id = state.getId();
             if (cache.containsKey(id)) {
                 log.warn("overwriting cached entry " + id);
@@ -144,9 +144,12 @@
 
     private void shrinkIfRequired() {
         // remove items, if too many
-        while (totalMem > maxMem) {
-            ItemId id = (ItemId) cache.firstKey();
-            evict(id);
+        synchronized (cache) {
+            while (totalMem > maxMem) {
+                ItemId id = (ItemId) cache.firstKey();
+                Entry entry = (Entry) cache.remove(id);
+                totalMem -= entry.size;
+            }
         }
     }
 
@@ -154,8 +157,8 @@
      * {@inheritDoc}
      */
     public void evict(ItemId id) {
+        touch();
         synchronized (cache) {
-            touch();
             Entry entry = (Entry) cache.remove(id);
             if (entry != null) {
                 totalMem -= entry.size;
@@ -287,7 +290,7 @@
      */
     public void dispose() {
         synchronized (cache) {
-            if(accessListener != null) {
+            if (accessListener != null) {
                 accessListener.disposeCache(this);
             }
         }



Mime
View raw message