rymurr commented on a change in pull request #7347:
URL: https://github.com/apache/arrow/pull/7347#discussion_r446920091



##########
File path: 
java/memory/src/main/java/org/apache/arrow/memory/util/MemoryUtil.java
##########
@@ -95,4 +143,26 @@ public static long getByteBufferAddress(ByteBuffer buf) {
 
   private MemoryUtil() {
   }
+
+  /**
+   * Create nio byte buffer.
+   */
+  public static ByteBuffer directBuffer(long address, int capacity) {
+    if (DIRECT_BUFFER_CONSTRUCTOR != null) {
+      if (capacity < 0) {
+        throw new IllegalArgumentException("Capacity is negative, has to be 
positive or 0");
+      }
+      try {
+        return (ByteBuffer) DIRECT_BUFFER_CONSTRUCTOR.newInstance(address, 
capacity);
+      } catch (Throwable cause) {
+        // Not expected to ever throw!
+        if (cause instanceof Error) {
+          throw (Error) cause;

Review comment:
       None, only that it was how the netty developers wrote it. I thought I 
would copy their lead. However, I have simplified it now,




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to