From 2d27d56e592270e8cf6453ed4399b6710fde87a8 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 30 Jul 2007 13:41:59 +0000 Subject: [PATCH] - Fix for the xmpp transport needed du to recently added stop() synchronization. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@560979 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/tcp/TcpTransport.java | 21 ++++++++++++------- .../transport/xmpp/XmppTransport.java | 14 ++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java b/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java index 33969416cf..80b514abf4 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java @@ -137,14 +137,7 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S log.trace("TCP consumer thread starting"); try { while (!isStopped()) { - try { - Object command = readCommand(); - doConsume(command); - } - catch (SocketTimeoutException e) { - } - catch (InterruptedIOException e) { - } + doRun(); } } catch (IOException e) { stoppedLatch.get().countDown(); @@ -154,6 +147,18 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S } } + + protected void doRun() throws IOException { + try { + Object command = readCommand(); + doConsume(command); + } + catch (SocketTimeoutException e) { + } + catch (InterruptedIOException e) { + } + } + protected Object readCommand() throws IOException { return wireFormat.unmarshal(dataIn); } diff --git a/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java b/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java index 6d3ac5f2bc..02fb1eb483 100644 --- a/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java +++ b/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java @@ -144,9 +144,8 @@ public class XmppTransport extends TcpTransport { } @Override - public void run() { + public void doRun() throws IOException { log.debug("XMPP consumer thread starting"); - try { XMLInputFactory xif = XMLInputFactory.newInstance(); xif.setXMLReporter(new XMLReporter() { @@ -196,17 +195,8 @@ public class XmppTransport extends TcpTransport { } } } - catch (XMLStreamException e) { - log.error("XMPP Reader thread caught: " + e, e); - } catch (Exception e) { - log.error("XMPP Reader thread caught: " + e, e); - } - try { - stop(); - } - catch (Exception e) { - log.error("Failed to stop XMPP transport: " + e, e); + throw IOExceptionSupport.create(e); } }