gpt4 book ai didi

java - SecureRandom 实例创建需要很长时间才能完成

转载 作者:行者123 更新时间:2023-11-28 22:17:54 25 4
gpt4 key购买 nike

在调查为什么我的 Ubuntu 15 上的 tomcat 8 服务器在启动时没有响应时,事实证明它花费了大量时间来尝试创建 SecureRandom 的实例。为什么会这样以及如何解决?

May 19, 2016 2:48:22 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 19, 2016 3:21:37 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
!!! ----> INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [1,994,925] milliseconds.
May 19, 2016 3:21:37 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /var/lib/tomcat8/webapps/ROOT has finished in 1,995,782 ms
May 19, 2016 3:21:37 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
May 19, 2016 3:21:37 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1995884 ms

最佳答案

根据 Javadoc

Depending on the implementation, the {@code generateSeed} and {@code nextBytes} methods may block as entropy is being gathered, for example, if they need to read from /dev/random on various Unix-like operating systems.

你能检查一下/dev/random 是否不慢,可能是 secureRandom 正在使用 NativePRNG (/dev/random)?

有关/dev/random 可能变慢的原因的更多详细信息,请参阅 /dev/random Extremely Slow?

关于java - SecureRandom 实例创建需要很长时间才能完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37328121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com