工作几天后,我在应用程序中遇到了阻塞java.security.Provider.getService(String,String)的问题。这是subethasmtp的堆栈跟踪,但是在所有其他线程(IMAP,HTTPS等...)上都一样。
Java Monitor Blocked
at java.security.Provider.getService(String, String)
at sun.security.jca.ProviderList$ServiceList.tryGet(int)
at sun.security.jca.ProviderList$ServiceList.access$200(ProviderList$ServiceList, int)
at sun.security.jca.ProviderList$ServiceList$1.hasNext()
at javax.crypto.KeyGenerator.nextSpi(KeyGeneratorSpi, boolean)
at javax.crypto.KeyGenerator.<init>(String)
at javax.crypto.KeyGenerator.getInstance(String)
at sun.security.ssl.JsseJce.getKeyGenerator(String)
at sun.security.ssl.HandshakeMessage$Finished.getFinished(HandshakeHash, int, SecretKey)
at sun.security.ssl.HandshakeMessage$Finished.<init>(ProtocolVersion, HandshakeHash, int, SecretKey, CipherSuite)
at sun.security.ssl.ServerHandshaker.sendChangeCipherAndFinish(boolean)
at sun.security.ssl.ServerHandshaker.clientHello(HandshakeMessage$ClientHello)
at sun.security.ssl.ServerHandshaker.processMessage(byte, int)
at sun.security.ssl.Handshaker.processLoop()
at sun.security.ssl.Handshaker.process_record(InputRecord, boolean)
at sun.security.ssl.SSLSocketImpl.readRecord(InputRecord, boolean)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake()
at sun.security.ssl.SSLSocketImpl.startHandshake(boolean)
at sun.security.ssl.SSLSocketImpl.startHandshake()
at org.subethamail.smtp.command.StartTLSCommand.execute(String, Session)
at org.subethamail.smtp.server.CommandHandler.handleCommand(Session, String)
at org.subethamail.smtp.server.Session.runCommandLoop()
at org.subethamail.smtp.server.Session.run()
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker)
at java.util.concurrent.ThreadPoolExecutor$Worker.run()
at java.lang.Thread.run()
** red block on JFR snapshot image is java.security.Provider.getService block **
最佳答案
JDK中的服务提供者采用了全局锁,这导致了争用。
我将介绍一个缓存。如果对服务提供者的呼叫在第三方库中,那么我将转到另一个库。