Fix Java Network.compareAddress to compare the IPv6 scope id (#5696)#5771
Merged
bernardnormier merged 2 commits intoJun 30, 2026
Merged
Conversation
…ce#5696) compareAddress compared only the raw 16 address bytes, so two IPv6 link-local addresses differing only by their zone (e.g. fe80::1%eth0 vs fe80::1%eth1) sorted as equal even though InetAddress.equals reports them as distinct. Compare Inet6Address.getScopeId() as well, mirroring the C++ sin6_scope_id fix (zeroc-ice#5679), so compareTo is consistent with equals. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pepone
approved these changes
Jun 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR fixes Network.compareAddress in the Java Ice runtime so that two IPv6 addresses differing only by their scope id (zone), such as fe80::1%eth0 and fe80::1%eth1, are no longer treated as equal. Previously only the raw 16 address bytes from InetAddress.getAddress() were compared, omitting the scope id and creating a compareTo/equals contract inconsistency in IPEndpointI.compareTo.
Changes:
- Capture the
InetAddressoperands and compare their raw address bytes as before. - When both operands are
Inet6Address, additionally comparegetScopeId()to distinguish scoped link-local addresses.
pepone
pushed a commit
that referenced
this pull request
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Network.compareAddresscompared only the raw 16 address bytes returned byInetAddress.getAddress(), which omits the IPv6 scope id. As a result two IPv6 link-local addresses that differ only by their zone (e.g.fe80::1%eth0vsfe80::1%eth1) compared as equal undercompareAddress, even thoughInetAddress.equals(used for connection reuse) treats them as distinct — acompareTo/equalscontract inconsistency inIPEndpointI.compareTo.This now also compares
Inet6Address.getScopeId()when both operands are IPv6, mirroring the C++sin6_scope_idfix in #5679 (same comment).Fixes #5696.
🤖 Generated with Claude Code