@@ -244,7 +244,7 @@ private static class JaasConfiguration extends javax.security.auth.login.Configu
244244 private static final Map <String , String > BASIC_JAAS_OPTIONS = new HashMap <>();
245245 static {
246246 String jaasEnvVar = System .getenv ("HBASE_JAAS_DEBUG" );
247- if (jaasEnvVar != null && "true" .equalsIgnoreCase (jaasEnvVar )) {
247+ if ("true" .equalsIgnoreCase (jaasEnvVar )) {
248248 BASIC_JAAS_OPTIONS .put ("debug" , "true" );
249249 }
250250 }
@@ -351,7 +351,7 @@ public static boolean watchAndCheckExists(ZKWatcher zkw, String znode)
351351 throws KeeperException {
352352 try {
353353 Stat s = zkw .getRecoverableZooKeeper ().exists (znode , zkw );
354- boolean exists = s != null ? true : false ;
354+ boolean exists = s != null ;
355355 if (exists ) {
356356 LOG .debug (zkw .prefix ("Set watcher on existing znode=" + znode ));
357357 } else {
@@ -441,8 +441,7 @@ public static List<String> listChildrenAndWatchForNewChildren(
441441 ZKWatcher zkw , String znode )
442442 throws KeeperException {
443443 try {
444- List <String > children = zkw .getRecoverableZooKeeper ().getChildren (znode , zkw );
445- return children ;
444+ return zkw .getRecoverableZooKeeper ().getChildren (znode , zkw );
446445 } catch (KeeperException .NoNodeException ke ) {
447446 LOG .debug (zkw .prefix ("Unable to list children of znode " + znode + " " +
448447 "because node does not exist (not an error)" ));
@@ -1744,9 +1743,12 @@ public static String dump(ZKWatcher zkw) {
17441743 sb .append ("<<FAILED LOOKUP: " + e .getMessage () + ">>" );
17451744 }
17461745 sb .append ("\n Backup master addresses:" );
1747- for (String child : listChildrenNoWatch (zkw ,
1748- zkw .getZNodePaths ().backupMasterAddressesZNode )) {
1749- sb .append ("\n " ).append (child );
1746+ final List <String > backupMasterChildrenNoWatchList = listChildrenNoWatch (zkw ,
1747+ zkw .getZNodePaths ().backupMasterAddressesZNode );
1748+ if (backupMasterChildrenNoWatchList != null ) {
1749+ for (String child : backupMasterChildrenNoWatchList ) {
1750+ sb .append ("\n " ).append (child );
1751+ }
17501752 }
17511753 sb .append ("\n Region server holding hbase:meta: "
17521754 + new MetaTableLocator ().getMetaRegionLocation (zkw ));
@@ -1758,8 +1760,12 @@ public static String dump(ZKWatcher zkw) {
17581760 + new MetaTableLocator ().getMetaRegionLocation (zkw , i ));
17591761 }
17601762 sb .append ("\n Region servers:" );
1761- for (String child : listChildrenNoWatch (zkw , zkw .getZNodePaths ().rsZNode )) {
1762- sb .append ("\n " ).append (child );
1763+ final List <String > rsChildrenNoWatchList =
1764+ listChildrenNoWatch (zkw , zkw .getZNodePaths ().rsZNode );
1765+ if (rsChildrenNoWatchList != null ) {
1766+ for (String child : rsChildrenNoWatchList ) {
1767+ sb .append ("\n " ).append (child );
1768+ }
17631769 }
17641770 try {
17651771 getReplicationZnodesDump (zkw , sb );
@@ -1810,31 +1816,33 @@ private static void getReplicationZnodesDump(ZKWatcher zkw, StringBuilder sb)
18101816 // do a ls -r on this znode
18111817 sb .append ("\n " ).append (replicationZnode ).append (": " );
18121818 List <String > children = ZKUtil .listChildrenNoWatch (zkw , replicationZnode );
1813- Collections .sort (children );
1814- for (String child : children ) {
1815- String znode = ZNodePaths .joinZNode (replicationZnode , child );
1816- if (znode .equals (zkw .getZNodePaths ().peersZNode )) {
1817- appendPeersZnodes (zkw , znode , sb );
1818- } else if (znode .equals (zkw .getZNodePaths ().queuesZNode )) {
1819- appendRSZnodes (zkw , znode , sb );
1820- } else if (znode .equals (zkw .getZNodePaths ().hfileRefsZNode )) {
1821- appendHFileRefsZnodes (zkw , znode , sb );
1819+ if (children != null ) {
1820+ Collections .sort (children );
1821+ for (String child : children ) {
1822+ String zNode = ZNodePaths .joinZNode (replicationZnode , child );
1823+ if (zNode .equals (zkw .getZNodePaths ().peersZNode )) {
1824+ appendPeersZnodes (zkw , zNode , sb );
1825+ } else if (zNode .equals (zkw .getZNodePaths ().queuesZNode )) {
1826+ appendRSZnodes (zkw , zNode , sb );
1827+ } else if (zNode .equals (zkw .getZNodePaths ().hfileRefsZNode )) {
1828+ appendHFileRefsZNodes (zkw , zNode , sb );
1829+ }
18221830 }
18231831 }
18241832 }
18251833
1826- private static void appendHFileRefsZnodes (ZKWatcher zkw , String hfileRefsZnode ,
1834+ private static void appendHFileRefsZNodes (ZKWatcher zkw , String hFileRefsZNode ,
18271835 StringBuilder sb ) throws KeeperException {
1828- sb .append ("\n " ).append (hfileRefsZnode ).append (": " );
1829- for ( String peerIdZnode : ZKUtil . listChildrenNoWatch ( zkw , hfileRefsZnode )) {
1830- String znodeToProcess = ZNodePaths . joinZNode ( hfileRefsZnode , peerIdZnode );
1831- sb . append ( " \n " ). append ( znodeToProcess ). append ( ": " );
1832- List < String > peerHFileRefsZnodes = ZKUtil . listChildrenNoWatch ( zkw , znodeToProcess );
1833- int size = peerHFileRefsZnodes . size ( );
1834- for ( int i = 0 ; i < size ; i ++) {
1835- sb . append ( peerHFileRefsZnodes . get ( i ) );
1836- if (i != size - 1 ) {
1837- sb .append (", " );
1836+ sb .append ("\n " ).append (hFileRefsZNode ).append (": " );
1837+ final List < String > hFileRefChildrenNoWatchList =
1838+ ZKUtil . listChildrenNoWatch ( zkw , hFileRefsZNode );
1839+ if ( hFileRefChildrenNoWatchList != null ) {
1840+ for ( String peerIdZNode : hFileRefChildrenNoWatchList ) {
1841+ String zNodeToProcess = ZNodePaths . joinZNode ( hFileRefsZNode , peerIdZNode );
1842+ sb . append ( " \n " ). append ( zNodeToProcess ). append ( ": " );
1843+ List < String > peerHFileRefsZNodes = ZKUtil . listChildrenNoWatch ( zkw , zNodeToProcess );
1844+ if (peerHFileRefsZNodes != null ) {
1845+ sb .append (String . join ( ", " , peerHFileRefsZNodes ) );
18381846 }
18391847 }
18401848 }
@@ -1946,10 +1954,10 @@ private static void appendPeerState(ZKWatcher zkw, String znodeToProcess, String
19461954 * @return The array of response strings.
19471955 * @throws IOException When the socket communication fails.
19481956 */
1949- public static String [] getServerStats (String server , int timeout )
1957+ private static String [] getServerStats (String server , int timeout )
19501958 throws IOException {
19511959 String [] sp = server .split (":" );
1952- if (sp == null || sp .length == 0 ) {
1960+ if (sp .length == 0 ) {
19531961 return null ;
19541962 }
19551963
@@ -2085,7 +2093,7 @@ public static void logZKTree(ZKWatcher zkw, String root) {
20852093 * @see #logZKTree(ZKWatcher, String)
20862094 * @throws KeeperException if an unexpected exception occurs
20872095 */
2088- protected static void logZKTree (ZKWatcher zkw , String root , String prefix )
2096+ private static void logZKTree (ZKWatcher zkw , String root , String prefix )
20892097 throws KeeperException {
20902098 List <String > children = ZKUtil .listChildrenNoWatch (zkw , root );
20912099
0 commit comments