Skip to content

Commit

Permalink
test: fix NullPointerException in mock server (#2365)
Browse files Browse the repository at this point in the history
* test: fix NullPointerException in mock server

Fix a potential NullPointerException in the mock server when a statement uses a
parameter of type ARRAY<BYTES> with a null element in the array.

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
olavloite and gcf-owl-bot[bot] authored Apr 8, 2023
1 parent 6b6427a commit 6927e06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -2950,7 +2951,7 @@ public void testStatementWithBytesArrayParameter() {
Statement.newBuilder("select id from test where b=@p1")
.bind("p1")
.toBytesArray(
ImmutableList.of(ByteArray.copyFrom("test1"), ByteArray.copyFrom("test2")))
Arrays.asList(ByteArray.copyFrom("test1"), null, ByteArray.copyFrom("test2")))
.build();
mockSpanner.putStatementResult(StatementResult.query(statement, SELECT1_RESULTSET));
DatabaseClient client =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,8 @@ private Statement buildStatement(
(Iterable<LazyByteArray>)
GrpcStruct.decodeArrayValue(
com.google.cloud.spanner.Type.bytes(), value.getListValue()),
LazyByteArray::getByteArray));
lazyByteArray ->
lazyByteArray == null ? null : lazyByteArray.getByteArray()));
break;
case DATE:
builder
Expand Down

0 comments on commit 6927e06

Please sign in to comment.