Skip to content
Browse files
fix: prevent potential NullPointerException in Struct with Array fiel…
…d that contains null elements (#1107)

A NullPointerException would be thrown when encoding the value to a proto if a Struct value was
constructed with an Array field that contained at least one null value, and the type of the array
field was boolArray, int64Array or float64Array.

Fixes #1106
  • Loading branch information
olavloite committed Apr 27, 2021
1 parent 3c9b4d3 commit c414abb9ec59f8200ba20e08846e442321de76bd
@@ -1550,15 +1550,15 @@ private Value getValue(int fieldIndex) {
Type elementType = fieldType.getArrayElementType();
switch (elementType.getCode()) {
case BOOL:
return Value.boolArray(value.getBooleanArray(fieldIndex));
return Value.boolArray(value.getBooleanList(fieldIndex));
case INT64:
return Value.int64Array(value.getLongArray(fieldIndex));
return Value.int64Array(value.getLongList(fieldIndex));
case STRING:
return Value.stringArray(value.getStringList(fieldIndex));
case BYTES:
return Value.bytesArray(value.getBytesList(fieldIndex));
case FLOAT64:
return Value.float64Array(value.getDoubleArray(fieldIndex));
return Value.float64Array(value.getDoubleList(fieldIndex));
return Value.numericArray(value.getBigDecimalList(fieldIndex));
case DATE:

0 comments on commit c414abb

Please sign in to comment.