rmaucher commented on a change in pull request #246: OpenSSLEngine improvements to guard against multiple shutdown() calls triggered by construction exception and finalize() later URL: https://github.com/apache/tomcat/pull/246#discussion_r381181675
########## File path: java/org/apache/tomcat/util/net/openssl/OpenSSLEngine.java ########## @@ -219,10 +218,14 @@ public String getNegotiatedProtocol() { * Destroys this engine. */ public synchronized void shutdown() { - if (!destroyed) { - destroyed = true; - SSL.freeBIO(networkBIO); - SSL.freeSSL(ssl); + // Guard against multiple shutdown() calls triggered by construction exception and finalize() later + if (destroyed.compareAndSet(false, true)) { + if (networkBIO != 0) { + SSL.freeBIO(networkBIO); + } + if (ssl != 0) { + SSL.freeSSL(ssl); + } Review comment: That's the best part of the change since it could take care of mysterious errors. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org