diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java index 7ce1236b2ec..072a12aa045 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java @@ -53,7 +53,6 @@ public BitVector(String name, BufferAllocator allocator) { public void load(ArrowFieldNode fieldNode, ArrowBuf data) { // When the vector is all nulls or all defined, the content of the buffer can be omitted if (data.readableBytes() == 0 && fieldNode.getLength() != 0) { - data.release(); int count = fieldNode.getLength(); allocateNew(count); int n = getSizeFromCount(count); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java index 9dfe8d840e4..3455efe245e 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java @@ -112,7 +112,8 @@ public void testLoadEmptyValidityBuffer() throws IOException { new Field("intNull", true, new ArrowType.Int(32, true), Collections.emptyList()) )); int count = 10; - ArrowBuf validity = allocator.getEmpty(); + // using Allocator.getEmpty() turns off ref counting + ArrowBuf validity = allocator.buffer(10).slice(0, 0); ArrowBuf values = allocator.buffer(count * 4); // integers for (int i = 0; i < count; i++) { values.setInt(i * 4, i); @@ -153,6 +154,7 @@ public void testLoadEmptyValidityBuffer() throws IOException { assertFalse(intDefinedVector.getAccessor().isNull(count + 10)); assertEquals(1234, intDefinedVector.getAccessor().get(count + 10)); } finally { + validity.release(); values.release(); } }