-
Notifications
You must be signed in to change notification settings - Fork 3.3k
instance ip 匹配 #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
instance ip 匹配 #2227
Conversation
Could you add unit tests for your changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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.
There was a problem hiding this 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?
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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.
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.
String eachIp = each.split("@-@")[0]; | ||
if (eachIp.equals(ip)) { |
There was a problem hiding this comment.
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.
Fixes #2226
针对次bug做的一次fix
#2226