Skip to content

Commit 9b86032

Browse files
committed
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.
1 parent 221124a commit 9b86032

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

‎memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import io.netty.buffer.PooledByteBufAllocatorL;
2626
import java.util.Collections;
2727
import java.util.stream.Collectors;
28-
import org.apache.arrow.memory.ArrowBuf;
29-
import org.apache.arrow.memory.ReferenceManager;
3028
import org.junit.jupiter.api.Test;
3129
import org.slf4j.LoggerFactory;
3230

@@ -43,14 +41,8 @@ public void testMemoryUsage() {
4341
logger.setLevel(Level.TRACE);
4442
logger.addAppender(memoryLogsAppender);
4543
memoryLogsAppender.start();
46-
try (ArrowBuf buf =
47-
new ArrowBuf(
48-
ReferenceManager.NO_OP,
49-
null,
50-
1024,
51-
new PooledByteBufAllocatorL().empty.memoryAddress())) {
52-
buf.memoryAddress();
53-
}
44+
// Creating the allocator with TRACE logging enabled starts the thread that logs memory usage.
45+
new PooledByteBufAllocatorL();
5446
boolean result = false;
5547
long startTime = System.currentTimeMillis();
5648
while ((System.currentTimeMillis() - startTime)

0 commit comments

Comments
 (0)