ezoerner commented on a change in pull request #6877:
URL: https://github.com/apache/geode/pull/6877#discussion_r718742250



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisKeyCommandsFunctionExecutor.java
##########
@@ -135,12 +137,22 @@ public void restore(RedisKey key, long ttl, byte[] data, 
RestoreOptions options)
   }
 
   @Override
-  public boolean rename(RedisKey oldKey, RedisKey newKey) {
+  public boolean rename(RedisKey oldKey, RedisKey newKey, boolean 
ifTargetNotExists) {
     List<RedisKey> lockOrdering = Arrays.asList(oldKey, newKey);
 
     return stripedExecute(oldKey, lockOrdering,
-        () -> 
getRedisData(oldKey).rename(getRegionProvider().getLocalDataRegion(), oldKey,
-            newKey));
+        () -> {
+          RedisData sourceData = getRedisData(oldKey);
+          // nonexistent source takes priority over nonexistent target
+          if (!sourceData.exists()) {
+            return false;
+          }
+          if (ifTargetNotExists && getRedisData(newKey).exists()) {

Review comment:
       We still need to check for the existence of the source key first because 
that takes priority over the target key.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to