Home / Function/ testShutdownInputClosureByServerCausesStreamStopped() — netty Function Reference

testShutdownInputClosureByServerCausesStreamStopped() — netty Function Reference

Architecture documentation for the testShutdownInputClosureByServerCausesStreamStopped() function in QuicStreamShutdownTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  87b6acf8_1a82_813a_0a39_1298befea5f9["testShutdownInputClosureByServerCausesStreamStopped()"]
  8f0deefd_ac73_09cd_1ee0_413b4ec84595["QuicStreamShutdownTest"]
  87b6acf8_1a82_813a_0a39_1298befea5f9 -->|defined in| 8f0deefd_ac73_09cd_1ee0_413b4ec84595
  style 87b6acf8_1a82_813a_0a39_1298befea5f9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamShutdownTest.java lines 87–153

    @ParameterizedTest
    @MethodSource("newSslTaskExecutors")
    public void testShutdownInputClosureByServerCausesStreamStopped(Executor executor) throws Throwable {
        Channel server = null;
        Channel channel = null;
        CountDownLatch latch = new CountDownLatch(2);
        AtomicReference<Throwable> errorRef = new AtomicReference<>();
        try {
            server = QuicTestUtils.newServer(executor, new ChannelInboundHandlerAdapter(),
                    new ChannelInboundHandlerAdapter() {
                        @Override
                        public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
                            QuicStreamChannel streamChannel = (QuicStreamChannel) ctx.channel();
                            streamChannel.shutdownInput()
                                    .addListener(f -> {
                                        ByteBuf buffer = (ByteBuf) msg;
                                        if (!f.isSuccess()) {
                                            errorRef.compareAndSet(null, f.cause());
                                            latch.countDown();
                                            buffer.release();
                                        } else {
                                            ctx.writeAndFlush(buffer).addListener(channelFuture -> {
                                                if (!channelFuture.isSuccess()) {
                                                    errorRef.compareAndSet(null, channelFuture.cause());
                                                }
                                                latch.countDown();
                                            });
                                        }
                                    });
                        }
                    });

            channel = QuicTestUtils.newClient(executor);
            QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(new ChannelInboundHandlerAdapter())
                    .streamHandler(new ChannelInboundHandlerAdapter())
                    .remoteAddress(server.localAddress())
                    .connect()
                    .get();

            QuicStreamChannel streamChannel = quicChannel.createStream(QuicStreamType.BIDIRECTIONAL,
                    new ByteToMessageDecoder() {
                        @Override
                        protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) {
                            if (in.readableBytes() == 4) {
                                latch.countDown();
                                ctx.close();
                            }
                        }
                    }).sync().getNow();

            streamChannel.writeAndFlush(Unpooled.buffer().writeInt(4)).sync();

            if (!latch.await(5, TimeUnit.SECONDS)) {
                fail("Timeout while waiting for completion", errorRef.get());
            }
            Throwable error = errorRef.get();
            if (error != null) {
                fail("Failure during execution", error);
            }
        } finally {
            QuicTestUtils.closeIfNotNull(channel);
            QuicTestUtils.closeIfNotNull(server);

            shutdown(executor);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testShutdownInputClosureByServerCausesStreamStopped() do?
testShutdownInputClosureByServerCausesStreamStopped() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamShutdownTest.java.
Where is testShutdownInputClosureByServerCausesStreamStopped() defined?
testShutdownInputClosureByServerCausesStreamStopped() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicStreamShutdownTest.java at line 87.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free