Home / Function/ testUdsAbstractNamespace() — netty Function Reference

testUdsAbstractNamespace() — netty Function Reference

Architecture documentation for the testUdsAbstractNamespace() function in SockaddrInTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  89b4e5a6_b555_ab93_7daf_50593757bb66["testUdsAbstractNamespace()"]
  f542b96b_70a1_3930_b104_0cabb6a71e80["SockaddrInTest"]
  89b4e5a6_b555_ab93_7daf_50593757bb66 -->|defined in| f542b96b_70a1_3930_b104_0cabb6a71e80
  style 89b4e5a6_b555_ab93_7daf_50593757bb66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java lines 137–176

    @Test
    public void testUdsAbstractNamespace() throws Exception {
        CleanableDirectBuffer cleanableDirectBuffer = allocateDirectBufferWithNativeOrder(
                Native.SIZEOF_SOCKADDR_UN);
        ByteBuffer buffer = cleanableDirectBuffer.buffer();
        try {
            // Abstract namespace socket: starts with null byte
            String abstractName = "\0test-abstract-socket";
            DomainSocketAddress address = new DomainSocketAddress(abstractName);
            byte[] nameBytes = abstractName.getBytes(StandardCharsets.UTF_8);

            // For abstract sockets, length should NOT include an extra null terminator
            int expectedLength = Native.SOCKADDR_UN_OFFSETOF_SUN_PATH + nameBytes.length;
            int actualLength = SockaddrIn.setUds(buffer, address);

            assertEquals(expectedLength, actualLength,
                    "Address length should be exact for abstract socket (no extra null terminator)");

            // Verify sun_family is set correctly
            int position = buffer.position();
            short family = buffer.getShort(position + Native.SOCKADDR_UN_OFFSETOF_SUN_FAMILY);
            assertEquals(Native.AF_UNIX, family, "sun_family should be AF_UNIX");

            // Verify name is written correctly (including the leading null byte)
            byte[] writtenName = new byte[nameBytes.length];
            buffer.position(position + Native.SOCKADDR_UN_OFFSETOF_SUN_PATH);
            buffer.get(writtenName);
            assertArrayEquals(nameBytes, writtenName, "Abstract socket name should match exactly");

            // Verify first byte is null (abstract namespace indicator)
            assertEquals(0, writtenName[0], "Abstract socket should start with null byte");

            // Verify that the returned length matches exactly what we wrote
            // (no extra null terminator beyond what's in the name)
            assertEquals(Native.SOCKADDR_UN_OFFSETOF_SUN_PATH + nameBytes.length, actualLength,
                    "Returned length should be exact: offsetof(sun_path) + name_length");
        } finally {
            cleanableDirectBuffer.clean();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testUdsAbstractNamespace() do?
testUdsAbstractNamespace() is a function in the netty codebase, defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java.
Where is testUdsAbstractNamespace() defined?
testUdsAbstractNamespace() is defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/SockaddrInTest.java at line 137.

Analyze Your Own Codebase

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

Try Supermodel Free