From 9b86032dc111118e217f080843fde87f87fd8421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Sun, 1 Nov 2026 06:43:49 +0100 Subject: [PATCH] GH-238: Stop TestNettyAllocator wrapping Netty's empty buffer in a 1024-byte ArrowBuf TestNettyAllocator.testMemoryUsage wrapped a 1024-byte NO_OP ArrowBuf around the memory address of PooledByteBufAllocatorL's empty buffer, whose native allocation is only a few bytes. The test only reads the address today, but any read or write through that buffer would run past the end of the native allocation, as in TestEmptyArrowBuf (#1426). The buffer isn't needed: the memory usage log the test waits for comes from the status thread that the PooledByteBufAllocatorL constructor starts when TRACE logging is enabled. Construct the allocator directly instead. Closes #238. --- .../arrow/memory/netty/TestNettyAllocator.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java b/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java index 5be42ecb08..ffbec4127f 100644 --- a/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java +++ b/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java @@ -25,8 +25,6 @@ import io.netty.buffer.PooledByteBufAllocatorL; import java.util.Collections; import java.util.stream.Collectors; -import org.apache.arrow.memory.ArrowBuf; -import org.apache.arrow.memory.ReferenceManager; import org.junit.jupiter.api.Test; import org.slf4j.LoggerFactory; @@ -43,14 +41,8 @@ public void testMemoryUsage() { logger.setLevel(Level.TRACE); logger.addAppender(memoryLogsAppender); memoryLogsAppender.start(); - try (ArrowBuf buf = - new ArrowBuf( - ReferenceManager.NO_OP, - null, - 1024, - new PooledByteBufAllocatorL().empty.memoryAddress())) { - buf.memoryAddress(); - } + // Creating the allocator with TRACE logging enabled starts the thread that logs memory usage. + new PooledByteBufAllocatorL(); boolean result = false; long startTime = System.currentTimeMillis(); while ((System.currentTimeMillis() - startTime)