spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

DefaultRedisList.removeAll() leaves duplicate elements behind

Open ryujungkyun opened this issue 1 month ago • 0 comments

DefaultRedisList.removeAll() leaves duplicate elements behind. Calling removeAll(List.of("A")) on [A, A, B] returns true but leaves [A, B]. The expected result is [B].

Reproduction

This was reproduced against Redis with both Jedis and Lettuce using removeAllShouldRemoveAllOccurrences() in AbstractRedisListIntegrationTests, executed through RedisListIntegrationTests.

The test uses [first, first, second] across existing serialization configurations and checks that removing first leaves only second. Before the fix, one occurrence of first remained.

Cause

DefaultRedisList inherits removeAll() from the abstract class AbstractRedisCollection.

  1. AbstractRedisCollection.removeAll() iterates over the supplied collection and calls remove() once per value.
  2. DefaultRedisList.remove(Object) calls listOps.remove(1, object).
  3. Redis LREM receives count 1, removing at most one matching occurrence.

Removing one occurrence is correct for remove(Object), but removeAll() must remove all matching elements.

ryujungkyun avatar Nov 02 '26 18:11 ryujungkyun