Author: vgritsenko
Date: Tue Nov 13 07:35:41 2007
New Revision: 594566

URL: http://svn.apache.org/viewvc?rev=594566&view=rev
Log:
synchronize cache table access

Modified:
    
xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java

Modified: 
xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java
URL: 
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java?rev=594566&r1=594565&r2=594566&view=diff
==============================================================================
--- 
xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java 
(original)
+++ 
xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java 
Tue Nov 13 07:35:41 2007
@@ -54,7 +54,8 @@
     /**
      * CacheKey to CacheEntry mapping
      */
-    private Map table = new WeakHashMap();
+    private final Map table = new WeakHashMap();
+
 
     private class CacheEntry {
         private final int type;
@@ -88,7 +89,10 @@
 
 
     public Entry getEntry(Collection col, Key key) {
-        CacheEntry e = (CacheEntry) table.get(new CacheKey(col, key));
+        CacheEntry e;
+        synchronized (table) {
+            e = (CacheEntry) table.get(new CacheKey(col, key));
+        }
         if (e == null) {
             return null;
         }
@@ -125,7 +129,10 @@
     }
 
     public Entry getEntryMeta(Collection col, Key key) {
-        CacheEntry e = (CacheEntry) table.get(new DocumentCache.CacheKey(col, 
key));
+        CacheEntry e;
+        synchronized (table) {
+            e = (CacheEntry) table.get(new CacheKey(col, key));
+        }
         if (e == null) {
             return null;
         }
@@ -135,11 +142,15 @@
 
     public void putEntry(Collection col, Key key, int type, Value value, Map 
meta) {
         CacheKey ckey = new CacheKey(col, key);
-        table.put(ckey, new CacheEntry(type, key, value, meta));
+        synchronized (table) {
+            table.put(ckey, new CacheEntry(type, key, value, meta));
+        }
     }
 
     public void removeEntry(Collection col, Key key) {
-        table.remove(new CacheKey(col, key));
+        synchronized (table) {
+            table.remove(new CacheKey(col, key));
+        }
     }
 
     /**


Reply via email to