This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 1b0ec7ae02b5 CAMEL-23267: Remove outdated changes on compress (#22500)
1b0ec7ae02b5 is described below

commit 1b0ec7ae02b55cdaf13d0fb3a075b3a800cc43c2
Author: Nicolas Filotto <[email protected]>
AuthorDate: Thu Apr 9 10:44:37 2026 +0200

    CAMEL-23267: Remove outdated changes on compress (#22500)
---
 .../src/main/java/org/apache/camel/support/cache/SimpleLRUCache.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/cache/SimpleLRUCache.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/cache/SimpleLRUCache.java
index 29f1884a9e46..1d06e12da1b7 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/cache/SimpleLRUCache.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/cache/SimpleLRUCache.java
@@ -383,7 +383,7 @@ public class SimpleLRUCache<K, V> implements Map<K, V> {
     }
 
     /**
-     * Removes duplicates from the queue of changes if the queue is full.
+     * Removes duplicates and entries that no longer exist from the queue of 
changes if the queue is full.
      */
     private void compressChangesIfNeeded() {
         if (isQueueFull()) {
@@ -392,7 +392,8 @@ public class SimpleLRUCache<K, V> implements Map<K, V> {
             Set<K> keys = new HashSet<>();
             Entry<K, ValueHolder<V>> entry;
             while ((entry = currentChanges.pollLast()) != null) {
-                if (keys.add(entry.getKey())) {
+                K key = entry.getKey();
+                if (delegate.containsKey(key) && keys.add(key)) {
                     newChanges.addFirst(entry);
                 }
             }

Reply via email to