This is an automated email from the ASF dual-hosted git repository.

nkalmar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new efb2c56  ZOOKEEPER-3548: Redundant zxid check in 
SnapStream.isValidSnapshot.
efb2c56 is described below

commit efb2c56d3ab630ef571ee2abcab6f18e08c64c79
Author: Michael Han <[email protected]>
AuthorDate: Thu Sep 26 14:16:50 2019 +0200

    ZOOKEEPER-3548: Redundant zxid check in SnapStream.isValidSnapshot.
    
    `Util.getZxidFromName` is called twice in `SnapStream.isValidSnapshot`, and 
the second call is redundant: there is no way the check would return false when 
the second call of `Util.getZxidFromName` is executed as otherwise the code 
would already return false in the first call of `Util.getZxidFromName`.
    
    No test as the logic is fairly obvious (and the logic is not well testable, 
in first place).
    
    Author: Michael Han <[email protected]>
    
    Reviewers: Norbert Kalmar <[email protected]>
    
    Closes #1092 from hanm/wip
---
 .../java/org/apache/zookeeper/server/persistence/SnapStream.java   | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git 
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/SnapStream.java
 
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/SnapStream.java
index eb042ee..9f28569 100644
--- 
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/SnapStream.java
+++ 
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/SnapStream.java
@@ -181,13 +181,8 @@ public class SnapStream {
             return false;
         }
 
-        String fileName = file.getName();
-        if (Util.getZxidFromName(fileName, "snapshot") == -1) {
-            return false;
-        }
-
         boolean isValid = false;
-        switch (getStreamMode(fileName)) {
+        switch (getStreamMode(file.getName())) {
         case GZIP:
             isValid = isValidGZipStream(file);
             break;

Reply via email to