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
This commit is contained in:
James Strachan 2006-03-06 12:12:53 +00:00
parent 204e940809
commit 3d96abcc93
2 changed files with 8 additions and 2 deletions

View File

@ -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!");
}
}
}
}

View File

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