UberHandlerTest: Delegate close to TcpHandler, close when running is false
@@ -2,6 +2,7 @@ package net.openhft.chronicle.network;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.core.Jvm;
+import net.openhft.chronicle.core.io.Closeable;
import net.openhft.chronicle.core.io.IORuntimeException;
import net.openhft.chronicle.core.util.ThrowingFunction;
import net.openhft.chronicle.network.api.TcpHandler;
@@ -199,6 +200,7 @@ public class UberHandlerTest extends NetworkTestCommon {
public void onRead(@NotNull WireIn inWire, @NotNull WireOut outWire) {
throwExceptionIfClosed();
if (!running.get()) {
+ close();
flagComplete();
return;
}
@@ -246,6 +248,7 @@ public class UberHandlerTest extends NetworkTestCommon {
public void onWrite(WireOut outWire) {
throwExceptionIfClosed();
if (!running.get()) {
+ close();
flagComplete();
return;
}
@@ -269,6 +272,16 @@ public class UberHandlerTest extends NetworkTestCommon {
initiator = wire.read("initiator").bool();
}
+ @Override
+ public boolean isClosed() {
+ return closable().isClosed();
+ }
+
+ @Override
+ public void close() {
+ Closeable.closeQuietly(closable());
+ }
+
private void flagComplete() {
if (!flaggedComplete) {
stopped.incrementAndGet();
