Skip to content

Conversation

McdullFei
Copy link

Fixes #2226

针对次bug做的一次fix
#2226

@TeslaCN
Copy link
Member

TeslaCN commented Jun 1, 2023

Could you add unit tests for your changes?

Copy link
Member

@songxiaosheng songxiaosheng left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

  • Can you change the commit content to English? This will help others search.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

  • Do you still have time to update the current PR? Maybe allow another person to raise a new PR fixing the current one?

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue with instance IP matching by improving the comparison logic from a prefix-based match to an exact match after extracting the IP portion from the instance identifier.

  • Changes IP matching logic from startsWith() to exact equality comparison
  • Extracts IP address from instance identifier using string split operation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

private boolean hasOnlineInstances(final String ip) {
for (String each : jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)) {
Copy link
Preview

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The code assumes the instance identifier always contains '@-@' delimiter, but if it doesn't, split() will return the original string. This could cause issues if the instance format is different. Consider adding validation or using a more robust parsing approach.

Suggested change
for (String each : jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)) {
for (String each : jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)) {
if (!each.contains("@-@")) {
// Skip malformed instance identifier
continue;
}

Copilot uses AI. Check for mistakes.

Comment on lines +84 to +85
String eachIp = each.split("@-@")[0];
if (eachIp.equals(ip)) {
Copy link
Preview

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

If the ip parameter is null, this will cause a NullPointerException. Consider using Objects.equals(eachIp, ip) or add null check for the ip parameter.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants