[KYUUBI #7692][TESTS] Fix testFindLocalInetAddress on loopback-only hosts - #7693
Open
LuciferYang wants to merge 1 commit into
Open
[KYUUBI #7692][TESTS] Fix testFindLocalInetAddress on loopback-only hosts#7693LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
…only hosts The loopback branch asserted that findLocalInetAddress never returns the loopback address it started from, but a host with no other usable interface address makes the method fall back to exactly that address, so the assertion compared a loopback address against itself and failed. Branch on the resolved address instead. When a replacement was scanned off an interface, assert it belongs to one and is not link-local. Otherwise assert the original address came back unchanged, and when that address is loopback, assert no interface offered a usable one, which is what makes the fallback correct rather than a broken scan.
LuciferYang
force-pushed
the
kyuubi-util-javautest-loopback-assert
branch
from
August 30, 2026 19:59
366be52 to
d289319
Compare
Contributor
Author
|
cc @pan3793 |
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.
Why are the changes needed?
Closes #7692.
testFindLocalInetAddressbranched on whetherInetAddress.getLocalHost()was loopback and, in the loopback case, asserted thatfindLocalInetAddress()returns something else. The method has a third outcome the test did not account for: when the interface scan finds no address that is neither loopback nor link-local, it logs and returns the loopback address it started from. On such a host the assertion compares that address against itself and fails.The test now branches on the outcome rather than on the starting address alone. When a replacement was scanned off an interface, it asserts the address belongs to an interface and is not link-local. Otherwise it asserts the original address came back unchanged, and when that address is loopback it also asserts no interface offered a usable one, which is what separates a correct fallback from a scan that silently returned loopback. The helper it calls only asks whether any interface address is neither loopback nor link-local; it does not repeat the selection rules.
Three decisions inside the method still have no assertion behind them, and are left for a follow-up: the host-name and IPv6 scope stripping, the IPv4 preference within the chosen interface, and the reversal that decides which interface wins when several have candidates. Only the first is writable against the current API, and on a host that picks an IPv4 address it asserts nothing; the other two need a seam that lets a test supply the interface list.
How was this patch tested?
That run does not reach the branch this fixes, because
getLocalHost()resolves to a routable LAN address here. The fixed branch was exercised in a container that reproduces the failing host, wheregetLocalHost()andfindLocalInetAddress()are both127.0.0.1:-oworks with no network because the mounted~/.m2and the already-extractedbuild/apache-maven-*in the checkout are all it needs. Master's test fails there withexpected: not equal but was: <loopbox/127.0.0.1>; this one passes.Four mutations of
findLocalInetAddressshow the assertions are not vacuous. Each turns the test red, and the first three were reached by mapping the host name to127.0.0.1with-Djdk.net.hosts.file:!addr.isLinkLocalAddress()from the candidate filter, so the method returns a link-local address:expected: <false> but was: <true>8.8.8.8) instead ofstrippedAddress:expected: not <null>127.0.0.1and the test takes the other arm:expected: <false> but was: <true>, from the assertion that there was nothing to findif (address.isLoopbackAddress())withif (true)so the scan always runs, no hosts file needed: the pass-through assertion fails because the scanned address differs from whatgetLocalHost()returnedWhether any of this runs on CI depends on how
getLocalHost()resolves on a GitHub runner, which I did not check: a routable answer means the test takes the sameassertEqualsas master, a127.0.1.1answer means it takes the replacement arm. The fallback path is certainly not reached there, otherwise master would be failing today.Was this patch assisted by generative AI tooling?
Assisted-by: Claude Opus 5