You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "jacob-netguardians (via GitHub)" <gi...@apache.org> on 2024/11/13 15:48:36 UTC

[I] GenericHelixControler.getLeaderController does not check for potential conrtroller's _helixMapper's nullity [helix]

jacob-netguardians opened a new issue, #2963:
URL: https://github.com/apache/helix/issues/2963

   ### Describe the bug
   Plain old NPE.
   Depending on the order of the controllers in the set of existing controllers, and especially depending on the position of the "leader" controller in the collection, some controllers prior to the "leader" one may still have their _helixMapper field set to null, resulting with an NPE while filtering for leader.
   
   ### To Reproduce
   Happens from time to time, depending on the ordering of the retrieved controllers in the collection.
   
   ### Expected behavior
   controllers without _helixMapper set cannot be leaders, so we could expect them to be filtered out during the search.
   
   Here is the code I propose to change:
   
   ```
     public static GenericHelixController getLeaderController(String clusterName) {
       if (clusterName != null) {
         ImmutableSet<GenericHelixController> controllers = _helixControllerFactory.get(clusterName);
         if (controllers != null) {
           return controllers.stream().filter(controller -> controller._helixManager.isLeader())
               .findAny().orElse(null);
         }
       }
       return null;
     }
   ```
   
   to
   
   ```
     public static GenericHelixController getLeaderController(String clusterName) {
       if (clusterName != null) {
         ImmutableSet<GenericHelixController> controllers = _helixControllerFactory.get(clusterName);
         if (controllers != null) {
           return controllers.stream().filter(controller -> controller._helixManager != null && controller._helixManager.isLeader())
               .findAny().orElse(null);
         }
       }
       return null;
     }
   ```


-- 
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: reviews-unsubscribe@helix.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [I] GenericHelixControler.getLeaderController does not check for potential conrtroller's _helixMapper's nullity [helix]

Posted by "jacob-netguardians (via GitHub)" <gi...@apache.org>.
jacob-netguardians commented on issue #2963:
URL: https://github.com/apache/helix/issues/2963#issuecomment-2483243998

   PR could be created (I don't have that sort of right, sorry, still a newbie here) from that branch here: https://github.com/jacob-netguardians/helix/tree/bugfix/2963-fix-npe-while-rebalancing-task


-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org