harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r1002480 - /harmony/enhanced/java/trunk/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java
Date Wed, 29 Sep 2010 05:38:27 GMT
Author: regisxu
Date: Wed Sep 29 05:38:27 2010
New Revision: 1002480

URL: http://svn.apache.org/viewvc?rev=1002480&view=rev
Log:
Apply fix for HARMONY-6662: Spin wait in StartTlsResponseImpl.java

Modified:
    harmony/enhanced/java/trunk/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java

Modified: harmony/enhanced/java/trunk/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java?rev=1002480&r1=1002479&r2=1002480&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java
Wed Sep 29 05:38:27 2010
@@ -43,6 +43,12 @@ public class StartTlsResponseImpl extend
 
     private boolean isHandshaked = false; // is handshake finished
 
+    private static class HandshakeMonitor {
+        // for identify local locks.
+    };
+
+    private HandshakeMonitor handshakeMonitor = new HandshakeMonitor();
+
     private SSLSocket negotiatedSslSocket = null; // negotiated ssl socket
 
     @Override
@@ -85,14 +91,23 @@ public class StartTlsResponseImpl extend
         sslSocket
                 .addHandshakeCompletedListener(new HandshakeCompletedListener() {
                     public void handshakeCompleted(HandshakeCompletedEvent event) {
-                        isHandshaked = true;
+                        synchronized(handshakeMonitor) {
+                            isHandshaked = true;
+                            handshakeMonitor.notify();
+                        }
                     }
                 });
 
         sslSocket.startHandshake();
 
-        while (!isHandshaked) {
-            // Wait for handshake finish.
+        synchronized(handshakeMonitor) {
+            while (!isHandshaked) {
+                try {
+                    handshakeMonitor.wait();
+                } catch (InterruptedException e) {
+                    // continue the loop
+                }
+            }
         }
 
         HostnameVerifier defaultVerifier = new HostnameVerifier() {



Mime
View raw message