junkaixue commented on code in PR #2752:
URL: https://github.com/apache/helix/pull/2752#discussion_r1501239299


##########
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java:
##########
@@ -419,7 +419,7 @@ void checkConnected(long timeout) {
     }
   }
 
-  void addListener(Object listener, PropertyKey propertyKey, ChangeType 
changeType,
+  public void addListener(Object listener, PropertyKey propertyKey, ChangeType 
changeType,

Review Comment:
   @Override?



##########
helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java:
##########
@@ -358,7 +358,18 @@ public void invoke(NotificationContext changeContext) 
throws Exception {
           configChangeListener.onConfigChange(configs, changeContext);
         } else if (_listener instanceof InstanceConfigChangeListener) {
           InstanceConfigChangeListener listener = 
(InstanceConfigChangeListener) _listener;
-          List<InstanceConfig> configs = preFetch(_propertyKey);
+          List<InstanceConfig> configs = Collections.emptyList();
+          if (_propertyKey.getParams().length == 0) {
+            configs = preFetch(_propertyKey);
+          } else {
+            // If there are params, that means the property key is for a 
specific instance
+            // and will not have children.
+            if (_preFetchEnabled) {
+              InstanceConfig config = _accessor.getProperty(_propertyKey);
+              configs =
+                  config != null ? Collections.singletonList(config) : 
Collections.emptyList();
+            }
+          }

Review Comment:
   Logic can be simplified as:
   
   if (_propertyKey.getParams().length > 0 && _preFetchEnabled) {
   xxxx
   } else {
      configs = preFetch(_propertyKey);
   }
   
   it can avoid two layer of if-else blocks.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to