zhztheplayer commented on a change in pull request #11800:
URL: https://github.com/apache/arrow/pull/11800#discussion_r760922907



##########
File path: 
java/memory/memory-netty/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java
##########
@@ -159,6 +159,87 @@ public void testAllocator_transferOwnership() throws 
Exception {
     }
   }
 
+  @Test
+  public void testAllocator_transferOwnershipWithDifferentListeners() throws 
Exception {
+    try (final RootAllocator rootAllocator =
+             new RootAllocator(MAX_ALLOCATION)) {
+      TestAllocationListener l1 = new TestAllocationListener();
+      TestAllocationListener l2 = new TestAllocationListener();
+      final BufferAllocator childAllocator1 =
+          rootAllocator.newChildAllocator("changeOwnership1", l1, 0, 
MAX_ALLOCATION);
+      final BufferAllocator childAllocator2 =
+          rootAllocator.newChildAllocator("changeOwnership2", l2, 0, 
MAX_ALLOCATION);
+
+      ArrowBuf buffer1 = childAllocator1.buffer(1024L);
+
+      // initial states
+      assertEquals(1, l1.getNumCalls());
+      assertEquals(0, l1.getNumReleaseCalls());
+      assertEquals(0, l2.getNumCalls());
+      assertEquals(0, l2.getNumReleaseCalls());
+
+      // do transfer
+      OwnershipTransferResult transferResult = buffer1.getReferenceManager()
+          .transferOwnership(buffer1, childAllocator2);
+      assertTrue(transferResult.getAllocationFit());
+      ArrowBuf buffer2 = transferResult.getTransferredBuffer();
+
+      // reservations from l1 should also be transferred to l2 during buffer 
transferring
+      assertEquals(1, l1.getNumCalls());
+      assertEquals(1, l1.getNumReleaseCalls());

Review comment:
       Umm... Do we have to consider the test case as a specific fix for this 
specific bug/issue?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to