Commits

Anonymous committed 54e5da4

Fix for [CACHE-54] - session caches not being
removed completely from disk.

  • Participants
  • Parent commits cfae9b2

Comments (0)

Files changed (1)

src/core/java/com/opensymphony/oscache/base/algorithm/AbstractConcurrentReadCache.java

                 e.value = null;
 
                 /** OpenSymphony BEGIN */
-                persistRemove(e.key);
-
                 itemRemoved(e.key);
 
                 /** OpenSymphony END */
             tab[i] = null;
         }
 
+        // Clean out the entire disk cache
+        persistClear();
+
         count = 0;
         recordModification(tab);
     }
         if (persistenceListener != null) {
             try {
                 persistenceListener.remove((String) key);
-            } catch (CachePersistenceException cpe) {
-                log.error("[oscache] Exception removing from persistence: " + cpe);
+            } catch (CachePersistenceException e) {
+                log.error("[oscache] Exception removing cache entry with key '" + key + "' from persistence", e);
             }
         }
     }
             try {
                 persistenceListener.removeGroup(groupName);
             } catch (CachePersistenceException e) {
-                log.error("[oscache] Exception removing group " + groupName + ": " + e);
+                log.error("[oscache] Exception removing group " + groupName, e);
             }
         }
     }
                 entry = persistenceListener.retrieve((String) key);
             } catch (CachePersistenceException e) {
                 /**
-                 * It is normal that we get an exception occasionnaly.
+                 * It is normal that we get an exception occasionally.
                  * It happens when the item is invalidated (written or removed)
                  * during read. The logic is constructed so that read is retried.
                  */
             try {
                 return persistenceListener.retrieveGroup(groupName);
             } catch (CachePersistenceException e) {
-                log.error("[oscache] Exception retrieving group " + groupName + ": " + e);
+                log.error("[oscache] Exception retrieving group " + groupName, e);
             }
         }
 
             try {
                 persistenceListener.store((String) key, obj);
             } catch (CachePersistenceException e) {
-                log.error("[oscache] Exception persisting " + key + ": " + e);
+                log.error("[oscache] Exception persisting " + key, e);
             }
         }
     }
                     persistenceListener.storeGroup(groupName, group);
                 }
             } catch (CachePersistenceException e) {
-                log.error("[oscache] Exception persisting group " + groupName + ": " + e);
+                log.error("[oscache] Exception persisting group " + groupName, e);
+            }
+        }
+    }
+
+    /**
+     * Removes the entire cache from persistent storage.
+     */
+    protected void persistClear() {
+        if (log.isDebugEnabled()) {
+            log.debug("persistClear called");
+            ;
+        }
+
+        if (persistenceListener != null) {
+            try {
+                persistenceListener.clear();
+            } catch (CachePersistenceException e) {
+                log.error("[oscache] Exception clearing persistent cache", e);
             }
         }
     }