mirror of https://github.com/apache/activemq.git
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:
parent
204e940809
commit
3d96abcc93
|
@ -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()) {
|
||||
// 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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue