Home / Class/ NettyBlockHoundIntegrationTest Class — netty Architecture

NettyBlockHoundIntegrationTest Class — netty Architecture

Architecture documentation for the NettyBlockHoundIntegrationTest class in NettyBlockHoundIntegrationTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  746a8721_66e8_40dd_5dc1_a4c697fa84e4["NettyBlockHoundIntegrationTest"]
  32ada944_73b7_7bad_5e08_618954df992c["NettyBlockHoundIntegrationTest.java"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|defined in| 32ada944_73b7_7bad_5e08_618954df992c
  de58add0_aede_d011_ff3b_5e732e9a3292["setUpClass()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| de58add0_aede_d011_ff3b_5e732e9a3292
  9dc95c34_c463_2185_8634_774ac23b9563["testServiceLoader()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 9dc95c34_c463_2185_8634_774ac23b9563
  1e1a3b77_1661_0699_dba9_09d98d90e34a["testBlockingCallsInNettyThreads()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 1e1a3b77_1661_0699_dba9_09d98d90e34a
  792f49d1_d055_21f0_8358_2d3033d72778["testGlobalEventExecutorTakeTask()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 792f49d1_d055_21f0_8358_2d3033d72778
  5f0bf64b_8897_5f95_70c7_c118591aab8b["testSingleThreadEventExecutorTakeTask()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 5f0bf64b_8897_5f95_70c7_c118591aab8b
  7dd063a6_8906_ff62_bbb8_8e5a2eafbf52["testEventExecutorTakeTask()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 7dd063a6_8906_ff62_bbb8_8e5a2eafbf52
  e7147b2d_39d9_4d42_fa62_e95cd65adc7e["testSingleThreadEventExecutorAddTask()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| e7147b2d_39d9_4d42_fa62_e95cd65adc7e
  d2ba84a8_eb53_37ed_60c3_d623374181d8["permittingBlockingCallsInFastThreadLocalThreadSubclass()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| d2ba84a8_eb53_37ed_60c3_d623374181d8
  230a896a_54b1_fde8_a9be_4f847699ddec["testHashedWheelTimerStartStop()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 230a896a_54b1_fde8_a9be_4f847699ddec
  35c44cbd_35c7_f6e3_60b9_1a16c160e2a9["testHandshakeWithExecutorThatExecuteDirectory()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 35c44cbd_35c7_f6e3_60b9_1a16c160e2a9
  517f6e48_a26a_f52f_aded_f5edc9ca7534["testHandshakeWithExecutorThatExecuteDirectoryTLSv13()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 517f6e48_a26a_f52f_aded_f5edc9ca7534
  8707eb4c_6720_035b_6cd8_c222fb371302["testHandshakeWithImmediateExecutor()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 8707eb4c_6720_035b_6cd8_c222fb371302
  05d45d0d_5847_424d_a5f7_f276b044a5cf["testHandshakeWithImmediateExecutorTLSv13()"]
  746a8721_66e8_40dd_5dc1_a4c697fa84e4 -->|method| 05d45d0d_5847_424d_a5f7_f276b044a5cf

Relationship Graph

Source Code

transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java lines 92–576

public class NettyBlockHoundIntegrationTest {

    @BeforeAll
    public static void setUpClass() {
        assumeFalse(PlatformDependent.javaVersion() == 26, "Fails on JDK26, possible Blockhound bug?");
        BlockHound.install();
    }

    @Test
    public void testServiceLoader() {
        for (BlockHoundIntegration integration : ServiceLoader.load(BlockHoundIntegration.class)) {
            if (integration instanceof NettyBlockHoundIntegration) {
                return;
            }
        }

        fail("NettyBlockHoundIntegration cannot be loaded with ServiceLoader");
    }

    @Test
    public void testBlockingCallsInNettyThreads() throws Exception {
        final FutureTask<Void> future = new FutureTask<>(() -> {
            Thread.sleep(0);
            return null;
        });
        GlobalEventExecutor.INSTANCE.execute(future);

        try {
            future.get(5, TimeUnit.SECONDS);
            fail("Expected an exception due to a blocking call but none was thrown");
        } catch (ExecutionException e) {
            assertInstanceOf(BlockingOperationError.class, e.getCause());
        }
    }

    @Test
    @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
    public void testGlobalEventExecutorTakeTask() throws InterruptedException {
        testEventExecutorTakeTask(GlobalEventExecutor.INSTANCE);
    }

    @Test
    @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
    public void testSingleThreadEventExecutorTakeTask() throws InterruptedException {
        SingleThreadEventExecutor executor =
                new SingleThreadEventExecutor(null, new DefaultThreadFactory("test"), true) {
                    @Override
                    protected void run() {
                        while (!confirmShutdown()) {
                            Runnable task = takeTask();
                            if (task != null) {
                                task.run();
                            }
                        }
                    }
                };
        testEventExecutorTakeTask(executor);
    }

    private static void testEventExecutorTakeTask(EventExecutor eventExecutor) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(1);
        ScheduledFuture<?> f = eventExecutor.schedule(latch::countDown, 10, TimeUnit.MILLISECONDS);
        f.sync();
        latch.await();
    }

    @Test
    @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
    public void testSingleThreadEventExecutorAddTask() throws Exception {
        TestLinkedBlockingQueue<Runnable> taskQueue = new TestLinkedBlockingQueue<>();
        SingleThreadEventExecutor executor =
                new SingleThreadEventExecutor(null, new DefaultThreadFactory("test"), true) {
                    @Override
                    protected Queue<Runnable> newTaskQueue(int maxPendingTasks) {
                        return taskQueue;
                    }

                    @Override
                    protected void run() {
                        while (!confirmShutdown()) {
                            Runnable task = takeTask();

Frequently Asked Questions

What is the NettyBlockHoundIntegrationTest class?
NettyBlockHoundIntegrationTest is a class in the netty codebase, defined in transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java.
Where is NettyBlockHoundIntegrationTest defined?
NettyBlockHoundIntegrationTest is defined in transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java at line 92.

Analyze Your Own Codebase

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

Try Supermodel Free