User: simone
Date: 00/10/25 03:03:58
Modified: src/main/org/jboss/util LRUCachePolicy.java
Log:
Fixed a bug in case of cache resizing: allow insertion expanding the capacity up to
its max
Revision Changes Path
1.4 +11 -2 jboss/src/main/org/jboss/util/LRUCachePolicy.java
Index: LRUCachePolicy.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/util/LRUCachePolicy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LRUCachePolicy.java 2000/10/19 21:50:52 1.3
+++ LRUCachePolicy.java 2000/10/25 10:03:57 1.4
@@ -12,7 +12,7 @@
* Implementation of a Least Recently Used cache policy.
*
* @author Simone Bordet ([EMAIL PROTECTED])
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class LRUCachePolicy
implements CachePolicy
@@ -280,6 +280,15 @@
m_head = entry;
++m_count;
}
+ else if (m_count < m_maxCapacity)
+ {
+ entry.m_prev = null;
+ entry.m_next = m_head;
+ m_head.m_prev = entry;
+ m_head = entry;
+ ++m_count;
+ ++m_capacity;
+ }
else {throw new IllegalStateException("Attempt
to put a new cache entry on a full cache");}
}
else {} // entry is the head, do nothing
@@ -334,7 +343,7 @@
if (entry == null) {throw new IllegalArgumentException("Cannot
remove a null entry from the cache");}
if (m_count < 1) {throw new IllegalStateException("Trying to
remove an entry from an empty cache");}
-// entry.m_key = entry.m_object = null;
+ entry.m_key = entry.m_object = null;
if (m_count == 1)
{
m_head = m_tail = null;