diff --git a/java/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java b/java/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java index b9525d0fe9d31..d067a92a67fae 100644 --- a/java/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java +++ b/java/memory/memory-netty/src/test/java/org/apache/arrow/memory/netty/TestNettyAllocator.java @@ -52,6 +52,9 @@ public void testMemoryUsage() { boolean result = false; long startTime = System.currentTimeMillis(); while ((System.currentTimeMillis() - startTime) < 10000) { // 10 seconds maximum for time to read logs + // Pause the appender while collecting results to avoid concurrent modification exceptions + // since another thread might be using the logger. + memoryLogsAppender.stop(); result = memoryLogsAppender.list.stream() .anyMatch( log -> log.toString().contains("Memory Usage: \n") && @@ -59,6 +62,7 @@ public void testMemoryUsage() { log.toString().contains("Normal buffers outstanding: ") && log.getLevel().equals(Level.TRACE) ); + memoryLogsAppender.start(); if (result) { break; }