File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
main/java/org/apache/arrow/memory/util
test/java/org/apache/arrow/memory Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -87,13 +87,14 @@ public Object run() {
8787 try {
8888 addressField .setAccessible (true );
8989 maybeOffset = UNSAFE .objectFieldOffset (addressField );
90- } catch (InaccessibleObjectException e ){
90+ } catch (InaccessibleObjectException e ) {
9191 maybeOffset = -1 ;
92- logger .debug ("Cannot access the address field of java.nio.Buffer. DirectBuffer operations wont be available" , e );
92+ logger .debug (
93+ "Cannot access the address field of java.nio.Buffer. DirectBuffer operations wont be available" ,
94+ e );
9395 }
9496 BYTE_BUFFER_ADDRESS_OFFSET = maybeOffset ;
9597
96-
9798 Constructor <?> directBufferConstructor ;
9899 long address = -1 ;
99100 final ByteBuffer direct = ByteBuffer .allocateDirect (1 );
@@ -168,7 +169,7 @@ public Object run() {
168169 * @return address of the underlying memory.
169170 */
170171 public static long getByteBufferAddress (ByteBuffer buf ) {
171- if (BYTE_BUFFER_ADDRESS_OFFSET != -1 ) {
172+ if (BYTE_BUFFER_ADDRESS_OFFSET != -1 ) {
172173 return UNSAFE .getLong (buf , BYTE_BUFFER_ADDRESS_OFFSET );
173174 }
174175 throw new UnsupportedOperationException (
Original file line number Diff line number Diff line change 2020import static org .junit .jupiter .api .Assertions .assertTrue ;
2121import static org .junit .jupiter .api .condition .JRE .JAVA_16 ;
2222
23+ import org .apache .arrow .memory .util .MemoryUtil ;
2324import org .junit .jupiter .api .Test ;
2425import org .junit .jupiter .api .condition .EnabledForJreRange ;
2526
@@ -34,18 +35,15 @@ public void testMemoryUtilFailsLoudly() {
3435 Throwable e =
3536 assertThrows (
3637 Throwable .class ,
37- () -> {
38- BufferAllocator allocator = new RootAllocator ();
39- allocator .close ();
40- });
38+ () -> MemoryUtil .directBuffer (0 , 10 ));
4139 boolean found = false ;
4240 while (e != null ) {
43- e = e .getCause ();
44- if (e instanceof RuntimeException
45- && e .getMessage ().contains ("Failed to initialize MemoryUtil" )) {
41+ if (e instanceof UnsupportedOperationException
42+ && e .getMessage ().contains ("java.nio.DirectByteBuffer.<init>(long, int) not available" )) {
4643 found = true ;
4744 break ;
4845 }
46+ e = e .getCause ();
4947 }
5048 assertTrue (found , "Expected exception was not thrown" );
5149 }
You can’t perform that action at this time.
0 commit comments