spring-cloud / spring-cloud/spring-cloud-commons
InetUtils : resolving host name in combination with EurekConfigBean always fails in 1st attempt
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 751
- Forks
- 744
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
Description
During spring boot startup, the host information is fetched several times while using the class InetUtils. Thereby, the first non loopback network interface is retrieved. The retrieval of the host ip, which runs the spring boot app works fine every time. In a second step, the IP is resolved to a host name running the method InetUtils:convertAddress. Looking at the code there is a fallback for thread interruption of the executor. In case of an interrupt the host name is bound to localhost. In general, the host name resolving executor is not interrupted and everything works fine, e.g. HostEnvironmentPostProcessor.
In context of the EurekaConfigBean initialization, exactly the InetUtils.convertAddress call fails. For some reason, the host name lookup is interrupted.
Running the application in remote debugging mode, it is reproducible, that only the first attempt fails. Executing the very same call done in EurekaInstanceConfigBean via "debugger evaluate expressions" shows the first call is falling back to localhost and every subsequent call results in the proper host resolution. As InetUtils is not caching anything in local members the 2nd attempt should fail too?
Unfortunately, the issue does neither happen on Ubuntu or MacOS in local setup.
However, wouldn't it be better to use the previously initialized environment: spring.cloud.client-ipaddress instead of resolving the host several times ? Is there any additional information, we miss regarding the EurekaConfigBean initialization procedure ?
Enviroment
- Debian 4.9.210-1
- SpringBoot in version 2.2.1Release
- SpringCloud in version Hoxton.SR1
Thanks for any advice on this topic.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with InetUtils.java and its convertAddress method, then trace the EurekaInstanceConfigBean.java call during startup and compare it with HostEnvironmentPostProcessor. Reproduce the first-call failure on the reported Debian and Spring Boot/Spring Cloud versions, determine why the lookup is interrupted, and define a regression test covering the observed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100