spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

InetUtils : resolving host name in combination with EurekConfigBean always fails in 1st attempt

Open chrgue opened this issue 5 years ago • 1 comments

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.

chrgue avatar Feb 25 '20 09:02 chrgue

I think moving EurekaConfigBean to use the environment values is useful.

spencergibb avatar Mar 02 '20 15:03 spencergibb