diff --git a/java/maven/module-info-compiler-maven-plugin/pom.xml b/java/maven/module-info-compiler-maven-plugin/pom.xml index ce598fc7f0f87..99a3a34e38730 100644 --- a/java/maven/module-info-compiler-maven-plugin/pom.xml +++ b/java/maven/module-info-compiler-maven-plugin/pom.xml @@ -125,6 +125,4 @@ </plugin> </plugins> </build> - - -</project> \ No newline at end of file +</project> diff --git a/java/memory/memory-core/pom.xml b/java/memory/memory-core/pom.xml index 08527016e8ef9..5194248a2b9a9 100644 --- a/java/memory/memory-core/pom.xml +++ b/java/memory/memory-core/pom.xml @@ -54,7 +54,7 @@ <profiles> <profile> - <id>error-prone-jdk11+</id> + <id>jdk11+</id> <activation> <jdk>[11,]</jdk> <property> diff --git a/java/memory/memory-core/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java b/java/memory/memory-core/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java index f90e221421540..535d5c15e8916 100644 --- a/java/memory/memory-core/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java +++ b/java/memory/memory-core/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java @@ -442,79 +442,79 @@ public ArrowBuf empty() { @Test public void testRootAllocator_listeners() throws Exception { - CountingAllocationListener l1 = new CountingAllocationListener(); - Assert.assertEquals(0, l1.getNumPreCalls()); - Assert.assertEquals(0, l1.getNumCalls()); - Assert.assertEquals(0, l1.getNumReleaseCalls()); - Assert.assertEquals(0, l1.getNumChildren()); - Assert.assertEquals(0, l1.getTotalMem()); - CountingAllocationListener l2 = new CountingAllocationListener(); - Assert.assertEquals(0, l2.getNumPreCalls()); - Assert.assertEquals(0, l2.getNumCalls()); - Assert.assertEquals(0, l2.getNumReleaseCalls()); - Assert.assertEquals(0, l2.getNumChildren()); - Assert.assertEquals(0, l2.getTotalMem()); + CountingAllocationListener listener1 = new CountingAllocationListener(); + Assert.assertEquals(0, listener1.getNumPreCalls()); + Assert.assertEquals(0, listener1.getNumCalls()); + Assert.assertEquals(0, listener1.getNumReleaseCalls()); + Assert.assertEquals(0, listener1.getNumChildren()); + Assert.assertEquals(0, listener1.getTotalMem()); + CountingAllocationListener listener2 = new CountingAllocationListener(); + Assert.assertEquals(0, listener2.getNumPreCalls()); + Assert.assertEquals(0, listener2.getNumCalls()); + Assert.assertEquals(0, listener2.getNumReleaseCalls()); + Assert.assertEquals(0, listener2.getNumChildren()); + Assert.assertEquals(0, listener2.getTotalMem()); // root and first-level child share the first listener // second-level and third-level child share the second listener - try (final RootAllocator rootAllocator = new RootAllocator(l1, MAX_ALLOCATION)) { + try (final RootAllocator rootAllocator = new RootAllocator(listener1, MAX_ALLOCATION)) { try (final BufferAllocator c1 = rootAllocator.newChildAllocator("c1", 0, MAX_ALLOCATION)) { - Assert.assertEquals(1, l1.getNumChildren()); + Assert.assertEquals(1, listener1.getNumChildren()); final ArrowBuf buf1 = c1.buffer(16); assertNotNull("allocation failed", buf1); - Assert.assertEquals(1, l1.getNumPreCalls()); - Assert.assertEquals(1, l1.getNumCalls()); - Assert.assertEquals(0, l1.getNumReleaseCalls()); - Assert.assertEquals(16, l1.getTotalMem()); + Assert.assertEquals(1, listener1.getNumPreCalls()); + Assert.assertEquals(1, listener1.getNumCalls()); + Assert.assertEquals(0, listener1.getNumReleaseCalls()); + Assert.assertEquals(16, listener1.getTotalMem()); buf1.getReferenceManager().release(); - try (final BufferAllocator c2 = c1.newChildAllocator("c2", l2, 0, MAX_ALLOCATION)) { - Assert.assertEquals(2, l1.getNumChildren()); // c1 got a new child, so c1's listener (l1) is notified - Assert.assertEquals(0, l2.getNumChildren()); + try (final BufferAllocator c2 = c1.newChildAllocator("c2", listener2, 0, MAX_ALLOCATION)) { + Assert.assertEquals(2, listener1.getNumChildren()); // c1 got a new child, so listener1 is notified. + Assert.assertEquals(0, listener2.getNumChildren()); final ArrowBuf buf2 = c2.buffer(32); assertNotNull("allocation failed", buf2); - Assert.assertEquals(1, l1.getNumCalls()); - Assert.assertEquals(16, l1.getTotalMem()); - Assert.assertEquals(1, l2.getNumPreCalls()); - Assert.assertEquals(1, l2.getNumCalls()); - Assert.assertEquals(0, l2.getNumReleaseCalls()); - Assert.assertEquals(32, l2.getTotalMem()); + Assert.assertEquals(1, listener1.getNumCalls()); + Assert.assertEquals(16, listener1.getTotalMem()); + Assert.assertEquals(1, listener2.getNumPreCalls()); + Assert.assertEquals(1, listener2.getNumCalls()); + Assert.assertEquals(0, listener2.getNumReleaseCalls()); + Assert.assertEquals(32, listener2.getTotalMem()); buf2.getReferenceManager().release(); try (final BufferAllocator c3 = c2.newChildAllocator("c3", 0, MAX_ALLOCATION)) { - Assert.assertEquals(2, l1.getNumChildren()); - Assert.assertEquals(1, l2.getNumChildren()); + Assert.assertEquals(2, listener1.getNumChildren()); + Assert.assertEquals(1, listener2.getNumChildren()); final ArrowBuf buf3 = c3.buffer(64); assertNotNull("allocation failed", buf3); - Assert.assertEquals(1, l1.getNumPreCalls()); - Assert.assertEquals(1, l1.getNumCalls()); - Assert.assertEquals(1, l1.getNumReleaseCalls()); - Assert.assertEquals(16, l1.getTotalMem()); - Assert.assertEquals(2, l2.getNumPreCalls()); - Assert.assertEquals(2, l2.getNumCalls()); - Assert.assertEquals(1, l2.getNumReleaseCalls()); - Assert.assertEquals(32 + 64, l2.getTotalMem()); + Assert.assertEquals(1, listener1.getNumPreCalls()); + Assert.assertEquals(1, listener1.getNumCalls()); + Assert.assertEquals(1, listener1.getNumReleaseCalls()); + Assert.assertEquals(16, listener1.getTotalMem()); + Assert.assertEquals(2, listener2.getNumPreCalls()); + Assert.assertEquals(2, listener2.getNumCalls()); + Assert.assertEquals(1, listener2.getNumReleaseCalls()); + Assert.assertEquals(32 + 64, listener2.getTotalMem()); buf3.getReferenceManager().release(); } - Assert.assertEquals(2, l1.getNumChildren()); - Assert.assertEquals(0, l2.getNumChildren()); // third-level child removed + Assert.assertEquals(2, listener1.getNumChildren()); + Assert.assertEquals(0, listener2.getNumChildren()); // third-level child removed } - Assert.assertEquals(1, l1.getNumChildren()); // second-level child removed - Assert.assertEquals(0, l2.getNumChildren()); + Assert.assertEquals(1, listener1.getNumChildren()); // second-level child removed + Assert.assertEquals(0, listener2.getNumChildren()); } - Assert.assertEquals(0, l1.getNumChildren()); // first-level child removed + Assert.assertEquals(0, listener1.getNumChildren()); // first-level child removed - Assert.assertEquals(2, l2.getNumReleaseCalls()); + Assert.assertEquals(2, listener2.getNumReleaseCalls()); } } @Test public void testRootAllocator_listenerAllocationFail() throws Exception { - CountingAllocationListener l1 = new CountingAllocationListener(); - Assert.assertEquals(0, l1.getNumCalls()); - Assert.assertEquals(0, l1.getTotalMem()); + CountingAllocationListener listener1 = new CountingAllocationListener(); + Assert.assertEquals(0, listener1.getNumCalls()); + Assert.assertEquals(0, listener1.getTotalMem()); // Test attempts to allocate too much from a child whose limit is set to half of the max // allocation. The listener's callback triggers, expanding the child allocator's limit, so then // the allocation succeeds. try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - try (final BufferAllocator c1 = rootAllocator.newChildAllocator("c1", l1, 0, + try (final BufferAllocator c1 = rootAllocator.newChildAllocator("c1", listener1, 0, MAX_ALLOCATION / 2)) { try { c1.buffer(MAX_ALLOCATION); @@ -522,14 +522,14 @@ public void testRootAllocator_listenerAllocationFail() throws Exception { } catch (OutOfMemoryException e) { // expected } - Assert.assertEquals(0, l1.getNumCalls()); - Assert.assertEquals(0, l1.getTotalMem()); + Assert.assertEquals(0, listener1.getNumCalls()); + Assert.assertEquals(0, listener1.getTotalMem()); - l1.setExpandOnFail(c1, MAX_ALLOCATION); + listener1.setExpandOnFail(c1, MAX_ALLOCATION); ArrowBuf arrowBuf = c1.buffer(MAX_ALLOCATION); assertNotNull("allocation failed", arrowBuf); - Assert.assertEquals(1, l1.getNumCalls()); - Assert.assertEquals(MAX_ALLOCATION, l1.getTotalMem()); + Assert.assertEquals(1, listener1.getNumCalls()); + Assert.assertEquals(MAX_ALLOCATION, listener1.getTotalMem()); arrowBuf.getReferenceManager().release(); } } diff --git a/java/memory/memory-unsafe/src/test/java/org/apache/arrow/memory/unsafe/TestUnsafeAllocationManager.java b/java/memory/memory-unsafe/src/test/java/org/apache/arrow/memory/unsafe/TestUnsafeAllocationManager.java index 5d74c398e2665..77233e73cb303 100644 --- a/java/memory/memory-unsafe/src/test/java/org/apache/arrow/memory/unsafe/TestUnsafeAllocationManager.java +++ b/java/memory/memory-unsafe/src/test/java/org/apache/arrow/memory/unsafe/TestUnsafeAllocationManager.java @@ -22,9 +22,9 @@ import org.apache.arrow.memory.AllocationManager; import org.apache.arrow.memory.ArrowBuf; +import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.BufferLedger; import org.apache.arrow.memory.RootAllocator; -import org.apache.arrow.memory.unsafe.UnsafeAllocationManager; import org.junit.Test; /** @@ -32,7 +32,7 @@ */ public class TestUnsafeAllocationManager { - private RootAllocator createUnsafeAllocator() { + private BufferAllocator createUnsafeAllocator() { return new RootAllocator(RootAllocator.configBuilder().allocationManagerFactory(UnsafeAllocationManager.FACTORY) .build()); } @@ -56,7 +56,7 @@ private void readWriteArrowBuf(ArrowBuf buffer) { @Test public void testBufferAllocation() { final long bufSize = 4096L; - try (RootAllocator allocator = createUnsafeAllocator(); + try (BufferAllocator allocator = createUnsafeAllocator(); ArrowBuf buffer = allocator.buffer(bufSize)) { assertTrue(buffer.getReferenceManager() instanceof BufferLedger); BufferLedger bufferLedger = (BufferLedger) buffer.getReferenceManager();