davisusanibar commented on code in PR #36042:
URL: https://github.com/apache/arrow/pull/36042#discussion_r1245928459


##########
java/memory/memory-core/src/test/java/org/apache/arrow/memory/TestArrowBuf.java:
##########
@@ -138,12 +129,52 @@ public void testSetBytesBigEndian() {
     assertFalse(data.hasArray());
     assertFalse(data.isDirect());
     assertEquals(ByteOrder.BIG_ENDIAN, data.order());
-    try (ArrowBuf buf = allocator.buffer(expected.length)) {
+    try (BufferAllocator allocator = new RootAllocator(128);
+        ArrowBuf buf = allocator.buffer(expected.length)) {
       buf.setBytes(0, data);
       byte[] actual = new byte[expected.length];
       buf.getBytes(0, actual);
       assertArrayEquals(expected, actual);
     }
   }
 
+  @Test
+  /**
+   * Test that allocation history is not recorded even though
+   * assertions are enabled in tests (GH-34338).
+   */
+  public void testEnabledAssertion() {
+    ((Logger) 
LoggerFactory.getLogger("org.apache.arrow")).setLevel(Level.TRACE);
+    try (BufferAllocator allocator = new RootAllocator(128)) {
+      ArrowBuf buf = allocator.buffer(2);
+    } catch (Exception e) {
+      assertFalse(e.getMessage().contains("event log for:"));
+    } finally {
+      ((Logger) LoggerFactory.getLogger("org.apache.arrow")).setLevel(null);
+    }
+  }
+
+  @Test
+  public void testEnabledHistoricalLog() {

Review Comment:
   We could decouple our test that need to override system property but at the 
end the unique way to inject a parameter will be by reflection.
   
   By definition there is not way to share system properties between main code 
and test code, for that reason what other framework do are using reflection to 
change that at runtime.
   
   The initial scope of this test is JDK11, for another JDK17+ versions this 
test validate only the message 'java.lang.NoSuchFieldException: modifiers'



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