Przeglądaj źródła

ZOOKEEPER-2726 ZOOKEEPER-2693: Patch for introduces potential race condition

Synchronizing these methods prevents potential race conditions.

Author: Kyle Nusbaum <knusbaum@yahoo-inc.com>

Reviewers: Govind Menon, Kishor Patil <patik523@yahoo.com>, Michael Han <hanm@apache.org>

Closes #196 from knusbaum/ZOOKEEPER-2726-master
Kyle Nusbaum 8 lat temu
rodzic
commit
0313a0e0b6

+ 2 - 2
src/java/main/org/apache/zookeeper/server/command/FourLetterCommands.java

@@ -169,7 +169,7 @@ public class FourLetterCommands {
     private static boolean whiteListInitialized = false;
     private static boolean whiteListInitialized = false;
 
 
     // @VisibleForTesting
     // @VisibleForTesting
-    public static void resetWhiteList() {
+    public synchronized static void resetWhiteList() {
         whiteListInitialized = false;
         whiteListInitialized = false;
         whiteListedCommands.clear();
         whiteListedCommands.clear();
     }
     }
@@ -202,7 +202,7 @@ public class FourLetterCommands {
      * @param command The command string.
      * @param command The command string.
      * @return true if the specified command is enabled
      * @return true if the specified command is enabled
      */
      */
-    public static boolean isEnabled(String command) {
+    public synchronized static boolean isEnabled(String command) {
         if (whiteListInitialized) {
         if (whiteListInitialized) {
             return whiteListedCommands.contains(command);
             return whiteListedCommands.contains(command);
         }
         }