Skip to content

Commit 1b0ec7a

Browse files
authored
CAMEL-23267: Remove outdated changes on compress (#22500)
1 parent c4d7139 commit 1b0ec7a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

core/camel-support/src/main/java/org/apache/camel/support/cache/SimpleLRUCache.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private Entry<K, ValueHolder<V>> nextOldestChange() {
383383
}
384384

385385
/**
386-
* Removes duplicates from the queue of changes if the queue is full.
386+
* Removes duplicates and entries that no longer exist from the queue of changes if the queue is full.
387387
*/
388388
private void compressChangesIfNeeded() {
389389
if (isQueueFull()) {
@@ -392,7 +392,8 @@ private void compressChangesIfNeeded() {
392392
Set<K> keys = new HashSet<>();
393393
Entry<K, ValueHolder<V>> entry;
394394
while ((entry = currentChanges.pollLast()) != null) {
395-
if (keys.add(entry.getKey())) {
395+
K key = entry.getKey();
396+
if (delegate.containsKey(key) && keys.add(key)) {
396397
newChanges.addFirst(entry);
397398
}
398399
}

0 commit comments

Comments
 (0)