LuciferYang opened a new issue, #7692:
URL: https://github.com/apache/kyuubi/issues/7692
### Describe the bug
`JavaUtils.findLocalInetAddress()` has three outcomes. If
`InetAddress.getLocalHost()` is not loopback it comes back unchanged. If it is
loopback, the method scans `NetworkInterface.getNetworkInterfaces()` for an
address that is neither loopback nor link-local and returns a copy with the
host name stripped. If that scan finds nothing it logs `couldn't find any
external IP address!` and returns the loopback address it started from.
That third outcome is deliberate, and
`JavaUtilsTest.testFindLocalInetAddress` asserts it cannot happen. Its loopback
branch is:
```java
assertNotEquals(InetAddress.getLocalHost(),
JavaUtils.findLocalInetAddress());
```
On a host that takes the fallback, that compares the loopback address
against itself:
```
expected: not equal but was: <loopbox/127.0.0.1>
```
Two conditions have to hold together, which is why most machines and CI do
not see it. The host name has to resolve to loopback, which is common on Debian
and Ubuntu (`127.0.1.1` in `/etc/hosts`). And no interface may carry a usable
address, meaning no network at all, or only loopback and link-local. Anything
with a routable address takes one of the other two paths, where the test is
green.
### Reproducing it
```
docker run --rm --network none --hostname loopbox --add-host
loopbox:127.0.0.1 \
-v ~/.m2:/root/.m2 -v $PWD:/src -w /src eclipse-temurin:17-jdk \
build/mvn -o test -pl kyuubi-util -am -DwildcardSuites=none
-Dtest=JavaUtilsTest
```
Inside that container `getLocalHost()` and `findLocalInetAddress()` are both
`127.0.0.1`, and the test fails.
The fallback is deliberate. The bug is in the test.
### Affects Version(s)
master (1.13.0-SNAPSHOT), 1.12, 1.11, 1.10. The same assertion is on
`branch-1.12`, `branch-1.11` and `branch-1.10`; `branch-1.9` has no such test.
### Are you willing to submit PR?
Yes.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]