You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/09/30 10:59:00 UTC
[jira] [Resolved] (CAMEL-25165) camel-spring-redis - SpringRedisIdempotentRepository.remove() returns true also when the key was not in the repository
[ https://issues.apache.org/jira/browse/CAMEL-25165?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-25165.
---------------------------------
Resolution: Fixed
Fixed via https://github.com/apache/camel/pull/27121 (merged to main for 4.23.0).
_Claude Code on behalf of davsclaus_
> camel-spring-redis - SpringRedisIdempotentRepository.remove() returns true also when the key was not in the repository
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25165
> URL: https://issues.apache.org/jira/browse/CAMEL-25165
> Project: Camel
> Issue Type: Bug
> Components: camel-spring-redis
> Reporter: shashank
> Priority: Minor
> Fix For: 4.23.0
>
>
> {{SpringRedisIdempotentRepository.remove}} returns the result of {{SREM}} compared with {{null}}:
> {code:java}
> return setOperations.remove(repositoryName, key) != null;
> {code}
> {{SREM}} returns the number of members it removed, which is 0 when the key was not in the set. So {{remove}} returns {{true}} for any key. {{IdempotentRepository.remove}} documents the return value as "true if the key was removed".
> This is the same pattern as the {{SADD}} result in {{add}} (CAMEL-25155). Claus Ibsen suggested fixing {{remove}} as well in the review of apache/camel#27110.
> The Idempotent Consumer EIP and the file consumers call {{remove}} on failure and do not use the returned value, so the EIP is not affected. The value is seen by code that calls the repository directly, and by the JMX operation {{remove}}.
> h3. Proposed fix
> Return {{true}} only when {{SREM}} removed the key ({{removed != null && removed > 0}}), as the CAMEL-25155 fix does for {{add}}. Inside a pipeline or a transaction Spring Data Redis returns {{null}}, and {{remove}} returns {{false}} there as before.
> Tests: {{SpringRedisIdempotentRepositoryTest}} (mocked {{SetOperations}}): {{SREM}} returns 1 gives {{true}}, 0 gives {{false}}, {{null}} gives {{false}}. The 0 case fails without the fix ({{expected: <false> but was: <true>}}).
> The upgrade guide gets a short note, as the return value changes for a missing key.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)