Home / Function/ testHandlerAddedThrowsAndRemovedThrowsException() — netty Function Reference

testHandlerAddedThrowsAndRemovedThrowsException() — netty Function Reference

Architecture documentation for the testHandlerAddedThrowsAndRemovedThrowsException() function in DefaultChannelPipelineTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  86978bbe_8861_3902_7e79_d2656d9e2712["testHandlerAddedThrowsAndRemovedThrowsException()"]
  666d912b_4166_a807_ed10_ba12f328a7b2["DefaultChannelPipelineTest"]
  86978bbe_8861_3902_7e79_d2656d9e2712 -->|defined in| 666d912b_4166_a807_ed10_ba12f328a7b2
  a2eed25d_b7ba_1436_1910_39c9b1477519["next()"]
  86978bbe_8861_3902_7e79_d2656d9e2712 -->|calls| a2eed25d_b7ba_1436_1910_39c9b1477519
  0583b801_5c23_7c01_232e_535f987f04c2["CheckExceptionHandler()"]
  86978bbe_8861_3902_7e79_d2656d9e2712 -->|calls| 0583b801_5c23_7c01_232e_535f987f04c2
  36fce318_f10e_2b70_4def_d189ac0af1ed["execute()"]
  86978bbe_8861_3902_7e79_d2656d9e2712 -->|calls| 36fce318_f10e_2b70_4def_d189ac0af1ed
  2d2a762a_b2a7_b92f_c9a9_231778acb218["run()"]
  86978bbe_8861_3902_7e79_d2656d9e2712 -->|calls| 2d2a762a_b2a7_b92f_c9a9_231778acb218
  19bd3906_4c8c_ae23_6c05_b7a84d367379["shutdownGracefully()"]
  86978bbe_8861_3902_7e79_d2656d9e2712 -->|calls| 19bd3906_4c8c_ae23_6c05_b7a84d367379
  style 86978bbe_8861_3902_7e79_d2656d9e2712 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java lines 1351–1388

    @Test
    @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
    public void testHandlerAddedThrowsAndRemovedThrowsException() throws InterruptedException {
        final EventExecutorGroup group1 = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
        try {
            final CountDownLatch latch = new CountDownLatch(1);
            final Promise<Void> promise = group1.next().newPromise();
            final Exception exceptionAdded = new RuntimeException();
            final Exception exceptionRemoved = new RuntimeException();
            String handlerName = "foo";
            ChannelPipeline pipeline = new LocalChannel().pipeline();
            pipeline.addLast(group1, new CheckExceptionHandler(exceptionAdded, promise));
            pipeline.addFirst(handlerName, new ChannelHandlerAdapter() {
                @Override
                public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
                    throw exceptionAdded;
                }

                @Override
                public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
                    // Execute this later so we are sure the exception is handled first.
                    ctx.executor().execute(new Runnable() {
                        @Override
                        public void run() {
                            latch.countDown();
                        }
                    });
                    throw exceptionRemoved;
                }
            });
            group.register(pipeline.channel()).syncUninterruptibly();
            latch.await();
            assertNull(pipeline.context(handlerName));
            promise.syncUninterruptibly();
        } finally {
            group1.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testHandlerAddedThrowsAndRemovedThrowsException() do?
testHandlerAddedThrowsAndRemovedThrowsException() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java.
Where is testHandlerAddedThrowsAndRemovedThrowsException() defined?
testHandlerAddedThrowsAndRemovedThrowsException() is defined in transport/src/test/java/io/netty/channel/DefaultChannelPipelineTest.java at line 1351.
What does testHandlerAddedThrowsAndRemovedThrowsException() call?
testHandlerAddedThrowsAndRemovedThrowsException() calls 5 function(s): CheckExceptionHandler, execute, next, run, shutdownGracefully.

Analyze Your Own Codebase

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

Try Supermodel Free