The client and server are connected synchronously (#1006)

* fix : The client and server are connected synchronously

* fix : The client and server are connected synchronously

* fix : Increases the wait time for test cases when the server side is down
pull/1009/head
pizihao 2 years ago committed by GitHub
parent 1910ddc8a6
commit 190de72dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,7 +108,7 @@ public class NettyClientConnection implements ClientConnection {
}
@Override
public void close() {
public synchronized void close() {
if (this.channel == null) {
return;
}

@ -105,12 +105,13 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
}
@Override
public void close() {
public synchronized void close() {
if (port == null) {
return;
}
leader.shutdownGracefully();
worker.shutdownGracefully();
this.leader.shutdownGracefully();
this.worker.shutdownGracefully();
this.channel.close();
this.future.channel().close();
log.info("The server is shut down and no more requests are received. The release port is {}", port.getPort());
}
@ -146,4 +147,5 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
super.addFirst(handler);
return this;
}
}

@ -27,7 +27,7 @@ import java.io.IOException;
public class NettyServerSupportTest {
@Test
public void bind() throws IOException {
public synchronized void bind() throws IOException {
NettyServerSupport support = new NettyServerSupport(() -> 8891, InstanceServerLoader.class);
support.bind();
while (!support.isActive()) {
@ -35,6 +35,7 @@ public class NettyServerSupportTest {
}
Assert.assertTrue(support.isActive());
support.close();
ThreadUtil.sleep(1000L);
Assert.assertFalse(support.isActive());
}

Loading…
Cancel
Save