Example usage for io.netty.channel.socket DuplexChannel shutdown

List of usage examples for io.netty.channel.socket DuplexChannel shutdown

Introduction

In this page you can find the example usage for io.netty.channel.socket DuplexChannel shutdown.

Prototype

ChannelFuture shutdown();

Source Link

Document

Will shutdown the input and output sides of this channel.

Usage

From source file:io.vertx.core.http.Http2Test.java

License:Open Source License

@Test
public void testDiscardConnectionWhenChannelBecomesInactive() throws Exception {
    AtomicInteger count = new AtomicInteger();
    server.requestHandler(req -> {//  w ww. j a va  2  s.com
        if (count.getAndIncrement() == 0) {
            Http2ServerConnection a = (Http2ServerConnection) req.connection();
            DuplexChannel channel = (DuplexChannel) a.channel();
            channel.shutdown();
        } else {
            req.response().end();
        }
    });
    startServer(testAddress);
    AtomicBoolean closed = new AtomicBoolean();
    client.request(HttpMethod.GET, testAddress, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI,
            onFailure(err -> {
            })).connectionHandler(conn -> conn.closeHandler(v -> closed.set(true))).end();
    AsyncTestBase.assertWaitUntil(closed::get);
    client.request(HttpMethod.GET, testAddress, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI,
            resp -> {
                testComplete();
            }).exceptionHandler(err -> {
                fail();
            }).end();
    await();
}