sonatype-lift[bot] commented on code in PR #1891:
URL: https://github.com/apache/zookeeper/pull/1891#discussion_r888445462


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxnFactory.java:
##########
@@ -93,6 +100,63 @@ public class NIOServerCnxnFactory extends ServerCnxnFactory 
{
         directBufferBytes = 
Integer.getInteger(ZOOKEEPER_NIO_DIRECT_BUFFER_BYTES, 64 * 1024);
     }
 
+    // zookeeper skip limited ip
+    private final static String PATH_SKIP_LIMITED_IP = 
"/zookeeper/extends/skip_limited_ip";
+    // zookeeper limited ip
+    private final static String PATH_LIMITED_IP = 
"/zookeeper/extends/limited_ip";
+    private boolean isStartedUpdateLimitedIpListFromPath = false;
+    protected volatile static Map<String, String> limitedIpMap = new 
ConcurrentHashMap<>();
+
+    protected volatile static AtomicBoolean skipLimitedIp = new 
AtomicBoolean(true);
+
+    ZooKeeperServer zks;
+
+    /**
+     * Update the limitedIpMap
+     */
+    private synchronized boolean updateLimitedIpListFromPath() {
+        String limitedIpStr = EMPTY_STRING;
+
+        DataNode node = null;
+        ZKDatabase zkDatabase = zks.getZKDatabase();
+        ReentrantReadWriteLock.ReadLock rl = null;
+        if(null != zkDatabase ){
+            ReentrantReadWriteLock lock = zkDatabase.getLogLock();
+            rl = lock.readLock();
+        }
+        try {
+
+            if (null != zks && null != zkDatabase) {
+                node = zkDatabase.getNode(PATH_LIMITED_IP);
+                if (null != node && null != node.data) {
+                    limitedIpStr = new String(node.data);
+                }
+
+                rl.lock();
+                node = zkDatabase.getNode(PATH_SKIP_LIMITED_IP);
+                if (null != node && null != node.data) {
+                    if (StringConvertUtil.trimToEmpty(new 
String(node.data)).contains("false")) {
+                        skipLimitedIp = new AtomicBoolean(false);
+                    } else {
+                        skipLimitedIp = new AtomicBoolean(true);
+                    }
+                }
+
+                limitedIpMap = StringConvertUtil.parseMap(limitedIpStr, COMMA);
+                LOG.info("NIOServerCnxnFactory.skipLimitedIp: " + 
skipLimitedIp.get());
+                LOG.info("Finish updateLimitedIpListFromPath, size: " + 
limitedIpMap.size());
+
+                return true;
+            }
+        } catch (Exception e) {
+            LOG.error("Error when updateLimitedIpListFromPath: " + 
PATH_LIMITED_IP + ", error: " + e.getMessage());
+            return false;
+        } finally {
+            rl.unlock();

Review Comment:
   *NULL_DEREFERENCE:*  object `rl` last assigned on line 122 could be null and 
is dereferenced at line 155.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with 
`help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not 
relevant](https://www.sonatype.com/lift-comment-rating?comment=261971318&lift_comment_rating=1)
 ] - [ [😕 Won't 
fix](https://www.sonatype.com/lift-comment-rating?comment=261971318&lift_comment_rating=2)
 ] - [ [😑 Not critical, will 
fix](https://www.sonatype.com/lift-comment-rating?comment=261971318&lift_comment_rating=3)
 ] - [ [🙂 Critical, will 
fix](https://www.sonatype.com/lift-comment-rating?comment=261971318&lift_comment_rating=4)
 ] - [ [😊 Critical, fixing 
now](https://www.sonatype.com/lift-comment-rating?comment=261971318&lift_comment_rating=5)
 ]



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to