From 3d96abcc932be04f6e1273db28cf9589eb00fa93 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Mon, 6 Mar 2006 12:12:53 +0000 Subject: [PATCH] added extra test to ensure that the transport instance is fully started before attempts are made to use the transport git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@383523 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/TransportThreadSupport.java | 9 +++++++-- .../org/apache/activemq/transport/tcp/TcpTransport.java | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/TransportThreadSupport.java b/activemq-core/src/main/java/org/apache/activemq/transport/TransportThreadSupport.java index e14c0a996b..e9d9a8ffd9 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/TransportThreadSupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/TransportThreadSupport.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport; +import org.apache.activemq.command.Command; +import org.apache.activemq.command.ShutdownInfo; import org.apache.activemq.util.ServiceStopper; import java.io.IOException; @@ -81,9 +83,12 @@ public abstract class TransportThreadSupport extends TransportSupport implements protected abstract void doStop(ServiceStopper stopper) throws Exception; - protected void checkStarted() { + protected void checkStarted(Command command) { if (!isStarted()) { - throw new IllegalStateException("The transport " + this + " of type: " + getClass().getName() + " has not been started yet!"); + // we might try to shut down the transport before it was ever started in some test cases + if (!(command instanceof ShutdownInfo)) { + throw new IllegalStateException("The transport " + this + " of type: " + getClass().getName() + " has not been started yet!"); + } } } } 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 ca2bf353e5..6735418144 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 @@ -112,6 +112,7 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S * A one way asynchronous send */ public void oneway(Command command) throws IOException { + checkStarted(command); wireFormat.marshal(command, dataOut); dataOut.flush(); }