Stuck thread looking up IPv6 hostname

Article ID:360035734031
1 minute readKnowledge base

Issue

A thread is stuck looking up for an IPv6 hostname with a stack like:

pool-1-thread-5446 for channel id=12367 (0x304f) state=RUNNABLE cpu=100% (running in native)
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$2.lookupAllHostAddr(Unknown Source)
    at java.net.InetAddress.getAddressesFromNameService(Unknown Source)
    at java.net.InetAddress.getLocalHost(Unknown Source)
    at net.bull.javamelody.Parameters.getHostName(Parameters.java:239)
    at net.bull.javamelody.JavaInformations.<init>(JavaInformations.java:147)
    at net.bull.javamelody.RemoteCallHelper$1.call(RemoteCallHelper.java:46)
    at net.bull.javamelody.RemoteCallHelper$1.call(RemoteCallHelper.java:38)
    at net.bull.javamelody.RemoteCallHelper$DelegatingTask.call(RemoteCallHelper.java:132)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:328)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at hudson.remoting.Engine$1$1.run(Engine.java:63)
    at java.lang.Thread.run(Unknown Source)

Resolution

If IPv6 is available on the OS you are using, then Jenkins will try to communicate using IPv6. You can force Jenkins to use IPv4 by adding -Djava.net.preferIPv4Stack=true (refer to How to add Java arguments to Jenkins?).

References