Home / Function/ testWriteFailsFastOnClosedChannel() — netty Function Reference

testWriteFailsFastOnClosedChannel() — netty Function Reference

Architecture documentation for the testWriteFailsFastOnClosedChannel() function in LocalChannelTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  84ff2132_6330_c4ab_ad3e_946db904a74c["testWriteFailsFastOnClosedChannel()"]
  d7e5442a_9b99_814d_2bd6_0be57237db65["LocalChannelTest"]
  84ff2132_6330_c4ab_ad3e_946db904a74c -->|defined in| d7e5442a_9b99_814d_2bd6_0be57237db65
  d3c8aa54_ac5d_6944_e789_c2c22ce16089["closeChannel()"]
  84ff2132_6330_c4ab_ad3e_946db904a74c -->|calls| d3c8aa54_ac5d_6944_e789_c2c22ce16089
  style 84ff2132_6330_c4ab_ad3e_946db904a74c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/local/LocalChannelTest.java lines 148–193

    @Test
    public void testWriteFailsFastOnClosedChannel() throws Exception {
        Bootstrap cb = new Bootstrap();
        ServerBootstrap sb = new ServerBootstrap();

        cb.group(group1)
                .channel(LocalChannel.class)
                .handler(new TestHandler());

        sb.group(group2)
                .channel(LocalServerChannel.class)
                .childHandler(new ChannelInitializer<LocalChannel>() {
                    @Override
                    public void initChannel(LocalChannel ch) throws Exception {
                        ch.pipeline().addLast(new TestHandler());
                    }
                });

        Channel sc = null;
        Channel cc = null;
        try {
            // Start server
            sc = sb.bind(TEST_ADDRESS).sync().channel();

            // Connect to the server
            cc = cb.connect(sc.localAddress()).sync().channel();

            // Close the channel and write something.
            cc.close().sync();
            try {
                cc.writeAndFlush(new Object()).sync();
                fail("must raise a ClosedChannelException");
            } catch (Exception e) {
                assertInstanceOf(ClosedChannelException.class, e);
                // Ensure that the actual write attempt on a closed channel was never made by asserting that
                // the ClosedChannelException has been created by AbstractUnsafe rather than transport implementations.
                if (e.getStackTrace().length > 0) {
                   assertEquals(AbstractChannel.class.getName() +
                           "$AbstractUnsafe", e.getStackTrace()[0].getClassName());
                }
            }
        } finally {
            closeChannel(cc);
            closeChannel(sc);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testWriteFailsFastOnClosedChannel() do?
testWriteFailsFastOnClosedChannel() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java.
Where is testWriteFailsFastOnClosedChannel() defined?
testWriteFailsFastOnClosedChannel() is defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java at line 148.
What does testWriteFailsFastOnClosedChannel() call?
testWriteFailsFastOnClosedChannel() calls 1 function(s): closeChannel.

Analyze Your Own Codebase

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

Try Supermodel Free