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 9d92c634e95b CAMEL-25165: camel-spring-redis - 
SpringRedisIdempotentRepository.remove returns false for a missing key (#27121)
9d92c634e95b is described below

commit 9d92c634e95b8a3bf45eebfa8a21f7e959a25b16
Author: allthingssecurity <[email protected]>
AuthorDate: Wed Sep 30 16:27:22 2026 +0530

    CAMEL-25165: camel-spring-redis - SpringRedisIdempotentRepository.remove 
returns false for a missing key (#27121)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../SpringRedisIdempotentRepository.java           |  4 +++-
 .../SpringRedisIdempotentRepositoryTest.java       | 25 ++++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_23.adoc    |  5 +++++
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
index 6b5bb1f205b9..1418db3eeb85 100644
--- 
a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
+++ 
b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
@@ -98,7 +98,9 @@ public class SpringRedisIdempotentRepository extends 
ServiceSupport implements I
     @Override
     @ManagedOperation(description = "Remove the key from the store")
     public boolean remove(String key) {
-        return setOperations.remove(repositoryName, key) != null;
+        // SREM returns the number of members it removed, which is 0 when the 
key is not in the set
+        Long removed = setOperations.remove(repositoryName, key);
+        return removed != null && removed > 0;
     }
 
     @Override
diff --git 
a/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
 
b/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
index 31c635ce7ece..157e86d64a6e 100644
--- 
a/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
+++ 
b/components/camel-spring-parent/camel-spring-redis/src/test/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryTest.java
@@ -28,6 +28,8 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -77,6 +79,29 @@ public class SpringRedisIdempotentRepositoryTest {
         verify(setOperations).remove(REPOSITORY, KEY);
     }
 
+    @Test
+    public void shouldReturnTrueWhenKeyIsRemoved() {
+        when(setOperations.remove(REPOSITORY, KEY)).thenReturn(1L);
+
+        assertTrue(idempotentRepository.remove(KEY));
+    }
+
+    @Test
+    public void shouldReturnFalseWhenKeyIsNotInTheSet() {
+        // SREM removes nothing
+        when(setOperations.remove(REPOSITORY, KEY)).thenReturn(0L);
+
+        assertFalse(idempotentRepository.remove(KEY));
+    }
+
+    @Test
+    public void shouldReturnFalseWhenRemoveHasNoResult() {
+        // Spring Data Redis returns null inside a pipeline or a transaction
+        when(setOperations.remove(REPOSITORY, KEY)).thenReturn(null);
+
+        assertFalse(idempotentRepository.remove(KEY));
+    }
+
     @Test
     public void shouldClearRepository() {
         idempotentRepository.clear();
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
index 077eeda00e73..9164fc70f888 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
@@ -1807,6 +1807,11 @@ 
from("spring-redis://localhost:6379?command=SUBSCRIBE&channels=myChannel"
 Setting the `serializer` option to a custom `RedisSerializer` bypasses the 
filter entirely, since
 Camel then no longer controls how the payload is read.
 
+=== camel-spring-redis - SpringRedisIdempotentRepository.remove returns false 
for a missing key
+
+`SpringRedisIdempotentRepository.remove` now returns `false` when the key was 
not in the repository, as documented by
+`IdempotentRepository`. It previously returned `true` for any key. The 
Idempotent Consumer does not use the returned value.
+
 === camel-langchain4j
 
 The legacy `sse` `transportType` has been removed. It follows the support 
removal in 

Reply via email to