Jvm takes a long time to resolve ip-address for localhost
I had the same problem. Tomcat went from 15 seconds to 6 minutes to initialise spring context after the upgrade... disabling csrutils didn't solve the issue for me.
I solved the problem by adding my Mac hostname (i.e. Macbook.local, or whatever your Mac is called) on the /etc/hosts
file mapped to the 127.0.0.1
address as well as the ::1
like this:
127.0.0.1 localhost mbpro.local
::1 localhost mbpro.local
If you're interested you can find some details on the issue and solution here:
https://thoeni.io/post/macos-sierra-java/
On the post I also link to a github project to help troubleshooting the issue and validating the solution.
The problem is related (I believe) on how the localhost name resolution works and how the java.net.InetAddr class is retrieving the addresses. I verified with few colleagues and apparently it doesn't happen to everyone who upgraded to Sierra, but I'm still investigating the roots of this change.
The solution anyway was the same that antid0te implemented and worked immediately.
InetAddress.getLocalHost() slow to run (30+ seconds)
The issue can be solved by adding the following to /etc/hosts
(assuming output of hostname
command is my-macbook
:
127.0.0.1 my-macbook
::1 my-macbook
This returns the time to something more suitable (< 1 second)
JMeter - localhost - wait for local server startup completed
- Add setUp Thread Group to your Test Plan
Add While Controller to the setUp Thread Group and use the following __groovy() function as the condition:
${__groovy(!vars.get('continue').equals('false'),)}
Add HTTP Request sampler to your Test Plan and configure it like:
Add JSR223 PostProcessor as a child of the HTTP Request sampler and put the following code into "Script" area:
if (prev.isSuccessful()) {
vars.put('continue', 'false')
}That's it, While Controller will loop the HTTP Request sampler until it will be successful which means that your application is up and running.
How can I specify an IP address besides localhost?
There is a serve
variant that takes a SocketAddress
. It won't resolve the hostname for you (as it seems to be done with http4s) so you'd need to pass it a resolved address.
Http.server.serve(new java.net.InetSocketAddress("192.168.0.1", 8080), service)
Note that by default, when you simply pass ":8081"
, the server will listen on all interfaces (including localhost).
Related Topics
Overriding VS Hiding Java - Confused
Quickest Way to Find Missing Number in an Array of Numbers
Print an Integer in Binary Format in Java
When Should I Use the "Strictfp" Keyword in Java
Booleans, Conditional Operators and Autoboxing
Lambda Expression and Generic Defined Only in Method
How to Find Nth Occurrence of Character in a String
Send an Array with an Http Get
Should We @Override an Interface's Method Implementation
How to Create a Linked List Data Structure in Java
Eclipse Cannot Load Swt Libraries
Should I Return a Collection or a Stream
Java Garbage Collection Log Messages
What Happens When a Duplicate Key Is Put into a Hashmap
How to Handle Very Large Numbers in Java Without Using Java.Math.Biginteger