tisonkun commented on code in PR #2064:
URL: https://github.com/apache/zookeeper/pull/2064#discussion_r1330461225


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java:
##########
@@ -735,10 +735,18 @@ private String getParentPathAndValidate(String path) 
throws BadArgumentsExceptio
     }
 
     private static int checkAndIncVersion(int currentVersion, int 
expectedVersion, String path) throws KeeperException.BadVersionException {
-        if (expectedVersion != -1 && expectedVersion != currentVersion) {
-            throw new KeeperException.BadVersionException(path);
+       if (expectedVersion != -1) {
+            if (expectedVersion != currentVersion) {
+                throw new KeeperException.BadVersionException(path);
+            }
+            if (expectedVersion == -2) {
+                return 0;
+            } else {
+                return currentVersion + 1;
+            }
+        } else {
+            return currentVersion + 1;

Review Comment:
   In this way, we can avoid mentioning `-2` as a new magic number. `-2` is 
special because `-1` is special - let's talk about -1 instead converged.



-- 
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: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to