Skip to content

Commit 13bf833

Browse files
committed
Remove anonymous inner class from ExpiringLruCache to fix agent class injection
1 parent 8695dd2 commit 13bf833

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

source/java/src/org/lucee/extension/debugger/util/ExpiringLruCache.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,9 @@ public ExpiringLruCache(int maxSize, long expireAfterWrite, TimeUnit unit) {
4444
this.maxSize = maxSize;
4545
this.expireAfterWriteMillis = unit.toMillis(expireAfterWrite);
4646
// accessOrder=true means iteration order is from least-recently-accessed to most-recently-accessed
47-
this.map = new LinkedHashMap<K, Entry<V>>(16, 0.75f, true) {
48-
@Override
49-
protected boolean removeEldestEntry(Map.Entry<K, Entry<V>> eldest) {
50-
return size() > ExpiringLruCache.this.maxSize;
51-
}
52-
};
47+
// Note: We inline the eldest entry removal logic in put() to avoid anonymous inner class issues
48+
// with the agent's class injection mechanism
49+
this.map = new LinkedHashMap<K, Entry<V>>(16, 0.75f, true);
5350
}
5451

5552
/**
@@ -86,6 +83,11 @@ public void put(K key, V value) {
8683
lock.lock();
8784
try {
8885
map.put(key, new Entry<>(value));
86+
// Evict eldest entries if over capacity
87+
while (map.size() > maxSize) {
88+
K eldest = map.keySet().iterator().next();
89+
map.remove(eldest);
90+
}
8991
}
9092
finally {
9193
lock.unlock();

0 commit comments

Comments
 (0)