jbonofre opened a new pull request, #1465:
URL: https://github.com/apache/arrow-java/pull/1465

   ## What's Changed
   
   Found while reviewing #1422. This change is independent of it and based on 
`main`.
   
   **Load the new validity buffer before releasing the old one.** Every 
`loadFieldBuffers` that loads a validity buffer released the current one first, 
then called `BitVectorHelper.loadValidityBuffer`. If that call failed (for 
example `OutOfMemoryException`), the vector kept pointing at the released 
buffer, and closing it failed with `RefCnt has gone negative`. The new buffer 
is now created first in `BaseFixedWidthVector`, `BaseVariableWidthVector`, 
`BaseLargeVariableWidthVector`, `BaseVariableWidthViewVector`, `ListVector`, 
`LargeListVector`, `ListViewVector`, `LargeListViewVector`, 
`FixedSizeListVector` and `StructVector`, so a failure leaves the vector 
unchanged.
   
   **Handle a missing validity buffer in `BitVectorHelper.loadValidityBuffer`.**
   - With the unknown null count `-1`, a missing (NULL or empty) validity 
buffer is now read as all valid, like null count `0`. Before, it was kept as 
is: a `NullPointerException` for a NULL C Data buffer, or an empty validity 
buffer for IPC that `isNull(i)` then read past.
   - A missing validity buffer is now rejected with `IllegalArgumentException` 
when the null count says that only some values are null, instead of being kept.
   
   Tests: `TestLoadFieldBuffers` covers all ten vector types (a failed load 
followed by `close()` with no double release or leak), and 
`TestBitVectorHelper` covers the two `loadValidityBuffer` cases. All of them 
fail without the fix. The full `vector` test suite passes.
   
   Closes #1464.
   


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