7065972: Some race condition may happen in SSLSocketImpl class
authorxuelei
Tue, 19 Jul 2011 21:47:23 -0700
changeset 10128 f505a8514bd7
parent 10127 c85d1ec57ee7
child 10129 bf705e446ca1
7065972: Some race condition may happen in SSLSocketImpl class Reviewed-by: wetmore, weijun, dgu
jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
--- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Tue Jul 19 17:45:11 2011 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Tue Jul 19 21:47:23 2011 -0700
@@ -2443,11 +2443,12 @@
             entrySet, HandshakeCompletedEvent e) {
 
             super("HandshakeCompletedNotify-Thread");
-            targets = entrySet;
+            targets = new HashSet<>(entrySet);          // clone the entry set
             event = e;
         }
 
         public void run() {
+            // Don't need to synchronize, as it only runs in one thread.
             for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
                 entry : targets) {