Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 828C410BE6 for ; Tue, 9 Jul 2013 19:40:33 +0000 (UTC) Received: (qmail 73899 invoked by uid 500); 9 Jul 2013 19:40:33 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 73847 invoked by uid 500); 9 Jul 2013 19:40:33 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 73838 invoked by uid 99); 9 Jul 2013 19:40:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jul 2013 19:40:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jul 2013 19:40:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2E49723888CD; Tue, 9 Jul 2013 19:40:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130709194009.2E49723888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; }