Copilot commented on code in PR #1291:
URL: https://github.com/apache/arrow-java/pull/1291#discussion_r3986795949
##########
vector/src/test/java/org/apache/arrow/vector/TestVariableWidthViewVector.java:
##########
@@ -2921,4 +2921,21 @@ public void testValidate() {
assertTrue(e.getMessage().contains("Not enough capacity for data
buffer"));
}
}
+
+ @Test
+ public void testValidateInvalidOffsets() {
+ try (final ViewVarCharVector vector = new ViewVarCharVector("v",
allocator)) {
+ vector.allocateNew(16, 1);
+ vector.allocateOrGetLastDataBuffer(8);
+ var offsets = vector.getDataBuffer();
+ offsets.setInt(0, 64);
Review Comment:
This value is too small to regress the allocation-order bug: the previous
implementation would allocate a 64-byte array and then throw the same
`IndexOutOfBoundsException` from `getBytes`, so this test also passes before
the fix. Use a length that cannot be allocated (or otherwise observe
allocation) so the test proves the invalid range is rejected before allocation;
`Integer.MAX_VALUE` exercises the reported failure while the new explicit
bounds check rejects it first.
--
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]