浏览代码

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 年之前
父节点
当前提交
0313a0e0b6
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/java/main/org/apache/zookeeper/server/command/FourLetterCommands.java

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

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