Author: michiel
Date: 2009-06-25 22:15:52 +0200 (Thu, 25 Jun 2009)
New Revision: 36431

Modified:
   mmbase/trunk/core/src/main/java/org/mmbase/cache/implementation/LRUCache.java
Log:
if something fishy in the cache, it seems that you must be more persistent to 
get anything out

Modified: 
mmbase/trunk/core/src/main/java/org/mmbase/cache/implementation/LRUCache.java
===================================================================
--- 
mmbase/trunk/core/src/main/java/org/mmbase/cache/implementation/LRUCache.java   
    2009-06-25 19:55:31 UTC (rev 36430)
+++ 
mmbase/trunk/core/src/main/java/org/mmbase/cache/implementation/LRUCache.java   
    2009-06-25 20:15:52 UTC (rev 36431)
@@ -51,15 +51,16 @@
                     Iterator<K> i = keySet().iterator();
                     K actualEldest = i.next();
                     i.remove();
-                    if ( !( (eldest.getKey() == null && actualEldest == null) 
|| (eldest.getKey() != null && eldest.equals(actualEldest)))) {
-                        log.warn("equal: " + eldest + " != " + actualEldest);
+                    overSized = size() - LRUCache.this.maxSize;
+                    while (overSized > 0) {
+                        // if for some reason a key changed in the cache, even 
1 i.remove may not
+                        // shrink the cache.
+                        log.warn("cache didn't shrink " + eldest + " = " + 
actualEldest);
+                        i.next();
+                        i.remove();
+                        overSized = size() - LRUCache.this.maxSize;
                     }
-                    if (! (eldest.getKey() == null && actualEldest == null) || 
(eldest.getKey() != null && actualEldest != null && eldest.getKey().hashCode() 
== actualEldest.hashCode())) {
-                        log.warn("hashcodes: " + eldest + " != " + 
actualEldest);
-                    }
-                    if  (size() > LRUCache.this.maxSize) {
-                        log.warn("Size still too big!");
-                    }
+                    assert overSized <= 0;
                     return false;
                 } else {
                     log.warn("How is this possible? Oversized: " + overSized);

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to