Browse Source

ZOOKEEPER-2379: recent commit broke findbugs qabot check (rakeshr via cnauroth)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1733679 13f79535-47bb-0310-9956-ffa450edef68
Chris Nauroth 9 years ago
parent
commit
47da027690
2 changed files with 6 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 3 1
      src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java

+ 3 - 0
CHANGES.txt

@@ -257,6 +257,9 @@ BUGFIXES:
   ZOOKEEPER-2375: Prevent multiple initialization of login object in each
   ZooKeeperSaslClient instance (yuemeng via rakeshr)
 
+  ZOOKEEPER-2379: recent commit broke findbugs qabot check
+  (rakeshr via cnauroth)
+
 IMPROVEMENTS:
   ZOOKEEPER-1660 Documentation for Dynamic Reconfiguration (Reed Wanderman-Milne via shralex)  
 

+ 3 - 1
src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java

@@ -64,6 +64,7 @@ public class ZooKeeperSaslClient {
     public static final String LOGIN_CONTEXT_NAME_KEY = "zookeeper.sasl.clientconfig";
     public static final String ENABLE_CLIENT_SASL_KEY = "zookeeper.sasl.client";
     public static final String ENABLE_CLIENT_SASL_DEFAULT = "true";
+    private static volatile boolean initializedLogin = false; 
 
     /**
      * Returns true if the SASL client is enabled. By default, the client
@@ -217,7 +218,7 @@ public class ZooKeeperSaslClient {
     private SaslClient createSaslClient(final String servicePrincipal,
                                                      final String loginContext) throws LoginException {
         try {
-            if (login == null) {
+            if (!initializedLogin) {
                 synchronized (ZooKeeperSaslClient.class) {
                     if (login == null) {
                         if (LOG.isDebugEnabled()) {
@@ -227,6 +228,7 @@ public class ZooKeeperSaslClient {
                         // in order to ensure the login is initialized only once, it must be synchronized the code snippet.
                         login = new Login(loginContext, new ClientCallbackHandler(null));
                         login.startThreadIfNeeded();
+                        initializedLogin = true;
                     }
                 }
             }