DefaultRedisList.removeAll() leaves duplicate elements behind
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.
AbstractRedisCollection.removeAll()iterates over the supplied collection and callsremove()once per value.DefaultRedisList.remove(Object)callslistOps.remove(1, object).- Redis
LREMreceives count1, removing at most one matching occurrence.
Removing one occurrence is correct for remove(Object), but removeAll() must remove all matching elements.