Преглед изворни кода

ZOOKEEPER-1864. quorumVerifier is null when creating a QuorumPeerConfig from parsing a Properties object (Michi Mutsuzaki via rakeshr)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1595443 13f79535-47bb-0310-9956-ffa450edef68
Rakesh Radhakrishnan пре 11 година
родитељ
комит
0252993977
2 измењених фајлова са 14 додато и 10 уклоњено
  1. 3 0
      CHANGES.txt
  2. 11 10
      src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java

+ 3 - 0
CHANGES.txt

@@ -648,6 +648,9 @@ BUGFIXES:
   ZOOKEEPER-1062. Net-ZooKeeper: Net::ZooKeeper consumes 100% cpu on wait
   (Botond Hejj via michim)
 
+  ZOOKEEPER-1864. quorumVerifier is null when creating a QuorumPeerConfig
+  from parsing a Properties object (Michi Mutsuzaki via rakeshr)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

+ 11 - 10
src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java

@@ -115,21 +115,12 @@ public class QuorumPeerConfig {
             FileInputStream in = new FileInputStream(configFile);
             try {
                 cfg.load(in);
+                configFileStr = path;
             } finally {
                 in.close();
             }
             
             parseProperties(cfg);
-            
-            // backward compatibility - dynamic configuration in the same file as static configuration params
-            // see writeDynamicConfig() - we change the config file to new format if reconfig happens
-            if (dynamicConfigFileStr == null) {
-                configBackwardCompatibilityMode = true;
-                configFileStr = path;                
-                quorumVerifier = parseDynamicConfig(cfg, electionAlg, true, configBackwardCompatibilityMode);
-                checkValidity();                
-            }
-
         } catch (IOException e) {
             throw new ConfigException("Error processing " + path, e);
         } catch (IllegalArgumentException e) {
@@ -288,6 +279,16 @@ public class QuorumPeerConfig {
             throw new IllegalArgumentException(
                     "minSessionTimeout must not be larger than maxSessionTimeout");
         }          
+
+        // backward compatibility - dynamic configuration in the same file as
+        // static configuration params see writeDynamicConfig() - we change the
+        // config file to new format if reconfig happens
+        if (dynamicConfigFileStr == null) {
+            configBackwardCompatibilityMode = true;
+            quorumVerifier = parseDynamicConfig(zkProp, electionAlg, true,
+                configBackwardCompatibilityMode);
+            checkValidity();
+        }
     }
     
     /**