Skip to content

Commit

Permalink
fix: prevent potential NullPointerException in Struct with Array fiel…
Browse files Browse the repository at this point in the history
…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 c414abb
Show file tree
Hide file tree
Showing 3 changed files with 440 additions and 3 deletions.
Expand Up @@ -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));
case NUMERIC:
return Value.numericArray(value.getBigDecimalList(fieldIndex));
case DATE:
Expand Down

0 comments on commit c414abb

Please sign in to comment.