emkornfield commented on a change in pull request #11182:
URL: https://github.com/apache/arrow/pull/11182#discussion_r712316073



##########
File path: 
java/memory/memory-netty/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java
##########
@@ -438,6 +441,99 @@ public ArrowBuf empty() {
         }).build());
   }
 
+  @Test
+  public void testAllocationManagerRequestedSizeAndGrantedSize1() {
+    // actual size is different from request size
+    final BaseAllocator allocator = 
createAllocatorWithFixedSizeAllocationManager(16, MAX_ALLOCATION);
+    final ArrowBuf arrowBuf = allocator.buffer(1024L);
+    assertEquals(16L, arrowBuf.getPossibleMemoryConsumed());
+    assertEquals(16L, arrowBuf.getActualMemoryConsumed());
+    assertEquals(16L, allocator.getAllocatedMemory());
+    assertDoesNotThrow(() -> AutoCloseables.close(arrowBuf, allocator));
+  }
+
+  @Test
+  public void testAllocationManagerRequestedSizeAndGrantedSize2() {
+    // actual size is larger than request size
+    final BaseAllocator allocator = 
createAllocatorWithFixedSizeAllocationManager(1024, MAX_ALLOCATION);
+    final ArrowBuf arrowBuf = allocator.buffer(16L);
+    assertEquals(1024L, arrowBuf.getPossibleMemoryConsumed());
+    assertEquals(1024L, arrowBuf.getActualMemoryConsumed());
+    assertEquals(1024L, allocator.getAllocatedMemory());
+    assertDoesNotThrow(() -> AutoCloseables.close(arrowBuf, allocator));
+  }
+
+  @Test
+  public void testAllocationManagerRequestedSizeAndGrantedSize3() {
+    // actual size is larger than request size, and is beyond allocation limit
+    final BaseAllocator allocator = 
createAllocatorWithFixedSizeAllocationManager(1024, 1023);
+    assertThrows(OutOfMemoryException.class, () -> {
+      allocator.buffer(16L); // should throw exception
+      fail();

Review comment:
       fail() should not be needed here.




-- 
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