svn commit: r594566 - /xml/xindice/trunk/java/src/org/apache/xindice/core/cache/DocumentCacheImpl.java

[email protected]
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
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));
+        }
     }
 
     /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.