diff --git a/geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisList.java b/geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisList.java index 72c5f62e244b..c82a2aecc6ba 100644 --- a/geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisList.java +++ b/geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisList.java @@ -221,17 +221,18 @@ public List lrange(int start, int stop) { */ public int lrem(int count, byte[] element, Region region, RedisKey key) { List removedIndexes; - byte version; + byte newVersion; synchronized (this) { removedIndexes = elementList.remove(element, count); - version = incrementAndGetVersion(); - } + if (removedIndexes.isEmpty()) { + return 0; + } - if (!removedIndexes.isEmpty()) { - storeChanges(region, key, - new RemoveElementsByIndex(version, removedIndexes)); + newVersion = incrementAndGetVersion(); } + storeChanges(region, key, + new RemoveElementsByIndex(newVersion, removedIndexes)); return removedIndexes.size(); }