zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [zookeeper] branch master updated: ZOOKEEPER-2825: 1. Remove unnecessary import; 2. `contains` instead of `indexOf > -1` for more readable; 3. Standardize `StringBuilder#append` usage for CLIENT module
Date Thu, 31 Jan 2019 14:51:03 GMT
This is an automated email from the ASF dual-hosted git repository.

andor 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 cbc63db  ZOOKEEPER-2825: 1. Remove unnecessary import; 2. `contains` instead of `indexOf
> -1` for more readable; 3. Standardize `StringBuilder#append` usage for CLIENT module
cbc63db is described below

commit cbc63dbaad14fa22e8855bfdaa71c873e0796591
Author: asdf2014 <benedictjin2016@gmail.com>
AuthorDate: Thu Jan 31 15:50:59 2019 +0100

    ZOOKEEPER-2825: 1. Remove unnecessary import; 2. `contains` instead of `indexOf > -1`
for more readable; 3. Standardize `StringBuilder#append` usage for CLIENT module
    
    * Remove unnecessary import;
    * `contains` instead of `indexOf > -1` for more readable;
    * Standardize `StringBuilder#append` usage for CLIENT module
    
    Author: asdf2014 <benedictjin2016@gmail.com>
    
    Reviewers: afine@apache.org, andor@apache.org
    
    Closes #297 from asdf2014/ZOOKEEPER-2825
---
 .../src/main/java/org/apache/zookeeper/ClientCnxn.java    |  4 ++--
 .../org/apache/zookeeper/client/FourLetterWordMain.java   |  2 +-
 .../java/org/apache/zookeeper/client/HostProvider.java    |  1 -
 .../org/apache/zookeeper/client/ZooKeeperSaslClient.java  | 15 ++++++---------
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
index 5c4171a..9e4de6a 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
@@ -1180,7 +1180,7 @@ public class ClientCnxn {
                                 }
                             }
 
-                            if (sendAuthEvent == true) {
+                            if (sendAuthEvent) {
                                 eventThread.queueEvent(new WatchedEvent(
                                       Watcher.Event.EventType.None,
                                       authState,null));
@@ -1433,7 +1433,7 @@ public class ClientCnxn {
             }
 
             // 2. SASL login failed.
-            if (saslLoginFailed == true) {
+            if (saslLoginFailed) {
                 return false;
             }
 
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/client/FourLetterWordMain.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/client/FourLetterWordMain.java
index a98953f..6641e21 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/client/FourLetterWordMain.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/client/FourLetterWordMain.java
@@ -122,7 +122,7 @@ public class FourLetterWordMain {
             StringBuilder sb = new StringBuilder();
             String line;
             while((line = reader.readLine()) != null) {
-                sb.append(line + "\n");
+                sb.append(line).append("\n");
             }
             return sb.toString();
         } catch (SocketTimeoutException e) {
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/client/HostProvider.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/client/HostProvider.java
index caeedcc..dd3c656 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/client/HostProvider.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/client/HostProvider.java
@@ -21,7 +21,6 @@ package org.apache.zookeeper.client;
 import org.apache.yetus.audience.InterfaceAudience;
 
 import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
 import java.util.Collection;
 
 /**
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZooKeeperSaslClient.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZooKeeperSaslClient.java
index 8550626..34f6656 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZooKeeperSaslClient.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZooKeeperSaslClient.java
@@ -332,7 +332,7 @@ public class ZooKeeperSaslClient {
                     // TODO: introspect about e: look for GSS information.
                     final String UNKNOWN_SERVER_ERROR_TEXT =
                       "(Mechanism level: Server not found in Kerberos database (7) - UNKNOWN_SERVER)";
-                    if (e.toString().indexOf(UNKNOWN_SERVER_ERROR_TEXT) > -1) {
+                    if (e.toString().contains(UNKNOWN_SERVER_ERROR_TEXT)) {
                         error += " This may be caused by Java's being unable to resolve the
Zookeeper Quorum Member's" +
                           " hostname correctly. You may want to try to adding" +
                           " '-Dsun.net.spi.nameservice.provider.1=dns,sun' to your client's
JVMFLAGS environment.";
@@ -438,18 +438,15 @@ public class ZooKeeperSaslClient {
                 // authentication is either in progress, successful, or failed.
 
                 // 1. Authentication hasn't finished yet: we must wait for it to do so.
-                if ((isComplete() == false) &&
-                    (isFailed() == false)) {
+                if (!isComplete() && !isFailed()) {
                     return true;
                 }
 
                 // 2. SASL authentication has succeeded or failed..
-                if (isComplete() || isFailed()) {
-                    if (gotLastPacket == false) {
-                        // ..but still in progress, because there is a final SASL
-                        // message from server which must be received.
+                if (!gotLastPacket) {
+                    // ..but still in progress, because there is a final SASL
+                    // message from server which must be received.
                     return true;
-                    }
                 }
             }
             // Either client is not configured to use a tunnelled authentication
@@ -459,7 +456,7 @@ public class ZooKeeperSaslClient {
         } catch (SecurityException e) {
             // Thrown if the caller does not have permission to retrieve the Configuration.
             // In this case, simply returning false is correct.
-            if (LOG.isDebugEnabled() == true) {
+            if (LOG.isDebugEnabled()) {
                 LOG.debug("Could not retrieve login configuration: " + e);
             }
             return false;


Mime
View raw message