Skip to content

Commit 6927e06

Browse files
test: fix NullPointerException in mock server (#2365)
* 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>
1 parent 6b6427a commit 6927e06

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import java.io.IOException;
8585
import java.nio.charset.StandardCharsets;
8686
import java.util.ArrayList;
87+
import java.util.Arrays;
8788
import java.util.Base64;
8889
import java.util.Collections;
8990
import java.util.List;
@@ -2950,7 +2951,7 @@ public void testStatementWithBytesArrayParameter() {
29502951
Statement.newBuilder("select id from test where b=@p1")
29512952
.bind("p1")
29522953
.toBytesArray(
2953-
ImmutableList.of(ByteArray.copyFrom("test1"), ByteArray.copyFrom("test2")))
2954+
Arrays.asList(ByteArray.copyFrom("test1"), null, ByteArray.copyFrom("test2")))
29542955
.build();
29552956
mockSpanner.putStatementResult(StatementResult.query(statement, SELECT1_RESULTSET));
29562957
DatabaseClient client =

google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,8 @@ private Statement buildStatement(
13671367
(Iterable<LazyByteArray>)
13681368
GrpcStruct.decodeArrayValue(
13691369
com.google.cloud.spanner.Type.bytes(), value.getListValue()),
1370-
LazyByteArray::getByteArray));
1370+
lazyByteArray ->
1371+
lazyByteArray == null ? null : lazyByteArray.getByteArray()));
13711372
break;
13721373
case DATE:
13731374
builder

0 commit comments

Comments
 (0)