Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ public boolean equals(Object obj) {
return true;
}

return NetUtils.isNetworkAWithinNetworkB(cidr, that.cidr);
return NetUtils.isNetworkAWithinNetworkB(
com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(cidr),
com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(that.cidr));
Comment on lines +603 to +605
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

equals is using NetUtils.isNetworkAWithinNetworkB(...), which is not symmetric (A within B does not imply B within A). That means NetworkVO.equals can violate the Java equals contract, and it is also inconsistent with hashCode() (which is based only on id). Consider switching equals/hashCode to be id-based like other VOs, or (if CIDR-based equality is truly intended) make the comparison symmetric and update hashCode accordingly (e.g., based on the same normalized CIDR(s) and trafficType).

Copilot uses AI. Check for mistakes.
Comment on lines +603 to +605
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Minor maintainability: getFirstValueFromCommaSeparatedString(...) is computed twice inline. Assign the normalized CIDRs to local variables before calling isNetworkAWithinNetworkB to avoid repeated splitting/trimming and make debugging/logging easier.

Suggested change
return NetUtils.isNetworkAWithinNetworkB(
com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(cidr),
com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(that.cidr));
final String normalizedCidr = com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(cidr);
final String normalizedThatCidr = com.cloud.utils.StringUtils.getFirstValueFromCommaSeparatedString(that.cidr);
return NetUtils.isNetworkAWithinNetworkB(normalizedCidr, normalizedThatCidr);

Copilot uses AI. Check for mistakes.
}

@Override
Expand Down
Loading