我正在MacOSX Mavericks DP3上运行带有jdk7的tomcat7。
一切都很顺利,启动只需要500毫秒。
但突然间变慢了35秒。
日志消息显示SecureRandom是根本原因。 谷歌告诉我这是一个jre bug,并提供以下代码进行验证:
日志消息显示SecureRandom是根本原因。 谷歌告诉我这是一个jre bug,并提供以下代码进行验证:
import java.security.SecureRandom;
class JRand {
public static void main(String args[]) throws Exception {
System.out.println("Ok: " +
SecureRandom.getInstance("SHA1PRNG").nextLong());
}
}
是的,最简单的代码也需要35秒。但似乎所有相关的解决方案都对我无效。在Mac上,/dev/random和/dev/urandom都不是块设备。
cat /dev/random | hexdump -C
输出非常快!
当切换回jre6时,生成随机数非常快。下载最新的jdk8-ea,问题仍然存在。
事实上,不仅是tomcat明显变慢,Netbeans、glassfish也都受到影响。 经过几个小时的奋斗,我最终放弃了。
今天早上,当我来到办公室,插上以太网,猜猜发生了什么? 它恢复了!
所以我的问题是,背后发生了什么?这真的很奇怪。
谢谢。
java.net.Inet6AddressImpl.lookupAllHostAddr(hostname)
来自java.net.InetAddress.getLocalHost() :'( - outersky