LuciferYang opened a new issue, #7701:
URL: https://github.com/apache/kyuubi/issues/7701
### Describe the bug
`JavaUtils.findLocalInetAddress()` returns `InetAddress.getLocalHost()`
unchanged unless it is loopback. When it is, the method scans network
interfaces for an address that is neither loopback nor link-local and warns
that it is substituting one. That warning reads its host name and loopback
address from the substitute rather than from the address that resolved to
loopback:
```java
LOG.warn(
"{} was resolved to a loopback address: {}, using {}",
addr.getHostName(),
addr.getHostAddress(),
strippedAddress.getHostAddress());
```
`addr` is the interface address just picked. On a host with no PTR record
for it, `addr.getHostName()` returns the numeric form and all three slots print
the same string:
```
10.0.0.5 was resolved to a loopback address: 10.0.0.5, using 10.0.0.5
```
So the line never says which host was resolved or what it resolved to. The
fallback warning in the same method, taken when no interface has a usable
address, reads from the original address, so the two warnings disagree about
their subject.
There is a second cost. `addr` carries no cached host name, so
`addr.getHostName()` goes to the resolver, and the call sits in the argument
list of the `warn` invocation, so it runs whether or not WARN is enabled.
Timings for that one call on a single host at different times: 0.9 ms, 1.8 ms,
6.5 ms, 324 ms, 1027 ms, 3147 ms, each returning the numeric form. The tail is
the problem, not the median. `InetAddress.getLocalHost()` already carries its
name, so reading from it costs nothing.
The branch is only entered on a host whose name resolves to loopback, which
is the Debian and Ubuntu default (`127.0.1.1` in `/etc/hosts`) and common on
developer machines. Hosts with a routable name never see it.
### Affects Version(s)
master (1.13.0-SNAPSHOT), 1.12, 1.11, 1.10. Introduced by the Java rewrite
in #6499; the Scala predecessor used the original address in both slots.
### 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]