andygrove commented on code in PR #1422:
URL: https://github.com/apache/arrow-java/pull/1422#discussion_r4514454633
##########
vector/src/main/java/org/apache/arrow/vector/ipc/message/ArrowFieldNode.java:
##########
@@ -31,12 +30,14 @@ public class ArrowFieldNode implements FBSerializable {
* Constructs a new instance.
*
* @param length The number of values written.
- * @param nullCount The number of null values.
+ * @param nullCount The number of null values, or -1 if unknown.
*/
public ArrowFieldNode(long length, long nullCount) {
super();
- this.length = checkedCastToInt(length);
- this.nullCount = checkedCastToInt(nullCount);
+ Preconditions.checkArgument(length >= 0, "Expected length >= 0, got %s",
length);
Review Comment:
Added in `d5bc95194`. `ArrayImporter` now builds the `ArrowFieldNode` inside
the `try`, so a bad length or null count reports the field name. New
`RoundtripTest` cases import a flat vector, a struct and a struct child with a
length of -1, `Long.MIN_VALUE`, above INT_MAX and 2^32 - 100, and check the
error and that nothing leaks. The leak check also showed `Data.importVector`
leaking children that had already loaded when a later length was bad, so it now
closes the vector on failure.
--
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]