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); } }