activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1501488 - /activemq/trunk/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
Date Tue, 09 Jul 2013 19:40:09 GMT
Author: tabish
Date: Tue Jul  9 19:40:08 2013
New Revision: 1501488

URL: http://svn.apache.org/r1501488
Log:
workaround for issue: https://issues.apache.org/jira/browse/AMQ-4307

attempt to get around the deadlock by detecting and interrupting the locked thread.  

Modified:
    activemq/trunk/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java

Modified: activemq/trunk/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java?rev=1501488&r1=1501487&r2=1501488&view=diff
==============================================================================
--- activemq/trunk/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
(original)
+++ activemq/trunk/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
Tue Jul  9 19:40:08 2013
@@ -92,6 +92,7 @@ public class HttpClientTransport extends
         return null;
     }
 
+    @Override
     public void oneway(Object command) throws IOException {
 
         if (isStopped()) {
@@ -142,6 +143,7 @@ public class HttpClientTransport extends
         }
     }
 
+    @Override
     public Object request(Object command) throws IOException {
         return null;
     }
@@ -155,6 +157,7 @@ public class HttpClientTransport extends
         }
     }
 
+    @Override
     public void run() {
 
         if (LOG.isTraceEnabled()) {
@@ -188,7 +191,7 @@ public class HttpClientTransport extends
                 } else {
                     receiveCounter++;
                     DataInputStream stream = createDataInputStream(answer);
-                    Object command = (Object)getTextWireFormat().unmarshal(stream);
+                    Object command = getTextWireFormat().unmarshal(stream);
                     if (command == null) {
                         LOG.debug("Received null command from url: " + remoteUrl);
                     } else {
@@ -236,6 +239,7 @@ public class HttpClientTransport extends
 
     // Implementation methods
     // -------------------------------------------------------------------------
+    @Override
     protected void doStart() throws Exception {
 
         if (LOG.isTraceEnabled()) {
@@ -268,7 +272,6 @@ public class HttpClientTransport extends
             }
         };
 
-
         try {
             httpClient.execute(httpMethod, new BasicResponseHandler());
             httpClient.execute(optionsMethod, handler);
@@ -279,9 +282,31 @@ public class HttpClientTransport extends
         super.doStart();
     }
 
+    @Override
     protected void doStop(ServiceStopper stopper) throws Exception {
         if (httpMethod != null) {
-            httpMethod.abort();
+            // In some versions of the JVM a race between the httpMethod and the completion
+            // of the method when using HTTPS can lead to a deadlock.  This hack attempts
to
+            // detect that and interrupt the thread that's locked so that they can complete
+            // on another attempt.
+            for (int i = 0; i < 3; ++i) {
+                Thread abortThread = new Thread(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        try {
+                            httpMethod.abort();
+                        } catch (Exception e) {
+                        }
+                    }
+                });
+
+                abortThread.start();
+                abortThread.join(2000);
+                if (!abortThread.isAlive()) {
+                    abortThread.interrupt();
+                }
+            }
         }
     }
 
@@ -325,6 +350,7 @@ public class HttpClientTransport extends
         this.trace = trace;
     }
 
+    @Override
     public int getReceiveCounter() {
         return receiveCounter;
     }



Mime
View raw message