Skip to content

Conversation

@deneskelemen
Copy link

Sometimes, the clusterDescription.controller is null, and in such cases, the Cluster Overview does not appear.

We have tested this in several of our environments. We have not found any issues that this could have caused.

Copy link
Collaborator

@Bert-R Bert-R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! According to the documentation, the controller yield null, if the controller ID is not yet known.

I've added a comment with a request to improve the code quality.

Comment on lines +84 to +90
boolean isController;
try {
isController = node.id() == clusterDescription.controller.id();
} catch (Exception e) {
LOG.error("Failed to determine if node is controller",e);
isController = false;
}
Copy link
Collaborator

@Bert-R Bert-R Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For maintainability, please extract the code into a separate method that is called here:

Suggested change
boolean isController;
try {
isController = node.id() == clusterDescription.controller.id();
} catch (Exception e) {
LOG.error("Failed to determine if node is controller",e);
isController = false;
}
boolean isController = isController(node.id, clusterDescription);

In the method, check the controller rather than catching the NPE:

  private static boolean isController(int nodeId, DescribeClusterResult clusterDescription)
  {
    var controller = clusterDescription.controller;
    if (controller == null)
    {
      LOG.error("Controller ID not known yet");
      return false;
    }
    return nodeId == controller.id();
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants