Copilot commented on code in PR #2227:
URL: 
https://github.com/apache/shardingsphere-elasticjob/pull/2227#discussion_r2327453156


##########
elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerService.java:
##########
@@ -81,7 +81,8 @@ public boolean isAvailableServer(final String ip) {
     
     private boolean hasOnlineInstances(final String ip) {
         for (String each : 
jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)) {
-            if (each.startsWith(ip)) {
+            String eachIp = each.split("@-@")[0];
+            if (eachIp.equals(ip)) {

Review Comment:
   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.



##########
elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/server/ServerService.java:
##########
@@ -81,7 +81,8 @@ public boolean isAvailableServer(final String ip) {
     
     private boolean hasOnlineInstances(final String ip) {
         for (String each : 
jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)) {

Review Comment:
   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.
   ```suggestion
           for (String each : 
jobNodeStorage.getJobNodeChildrenKeys(InstanceNode.ROOT)) {
               if (!each.contains("@-@")) {
                   // Skip malformed instance identifier
                   continue;
               }
   ```



-- 
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: notifications-unsubscr...@shardingsphere.apache.org

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

Reply via email to