Skip to content

Commit 2facaef

Browse files
authored
Fix Spanner NPE when withHost called with null or empty host (#34489)
* Fix Spanner NPE * known issues
1 parent 085c0c1 commit 2facaef

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
## Known Issues
134134

135135
* (Java) Current version of protobuf has a [bug](https://github.com/protocolbuffers/protobuf/issues/20599) leading to incompatibilities with clients using older versions of Protobuf ([example issue](https://github.com/GoogleCloudPlatform/DataflowTemplates/issues/2191)). This issue has been seen in SpannerIO in particular. Tracked in [#34452](https://github.com/GoogleCloudPlatform/DataflowTemplates/issues/34452).
136+
* (Java) When constructing `SpannerConfig` for `SpannerIO`, calling `withHost` with a null or empty host will now result in a Null Pointer Exception (`java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "this.text" is null`). See https://github.com/GoogleCloudPlatform/DataflowTemplates/issues/34489 for context.
136137

137138
# [2.63.0] - 2025-02-18
138139

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ static SpannerOptions buildSpannerOptions(SpannerConfig spannerConfig) {
220220
}
221221
ValueProvider<String> host = spannerConfig.getHost();
222222
if (host != null) {
223-
builder.setHost(host.get());
223+
String hostValue = host.get();
224+
if (hostValue != null && !hostValue.trim().isEmpty()) {
225+
builder.setHost(host.get());
226+
}
224227
}
225228
ValueProvider<String> emulatorHost = spannerConfig.getEmulatorHost();
226229
if (emulatorHost != null) {

website/www/site/content/en/blog/beam-2.64.0.md

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ For more information on changes in 2.64.0, check out the [detailed release notes
6060
* Fixed checkpoint recovery and streaming behavior in Spark Classic and Portable runner's Flatten transform by replacing queueStream with SingleEmitInputDStream ([#34080](https://github.com/apache/beam/pull/34080), [#18144](https://github.com/apache/beam/issues/18144), [#20426](https://github.com/apache/beam/issues/20426))
6161
* (Java) Fixed Read caching of UnboundedReader objects to effectively cache across multiple DoFns and avoid checkpointing unstarted reader. [#34146](https://github.com/apache/beam/pull/34146) [#33901](https://github.com/apache/beam/pull/33901)
6262

63+
## Known Issues
64+
65+
* (Java) Current version of protobuf has a [bug](https://github.com/protocolbuffers/protobuf/issues/20599) leading to incompatibilities with clients using older versions of Protobuf ([example issue](https://github.com/GoogleCloudPlatform/DataflowTemplates/issues/2191)). This issue has been seen in SpannerIO in particular. Tracked in [#34452](https://github.com/GoogleCloudPlatform/DataflowTemplates/issues/34452).
66+
* (Java) When constructing `SpannerConfig` for `SpannerIO`, calling `withHost` with a null or empty host will now result in a Null Pointer Exception (`java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "this.text" is null`). See https://github.com/GoogleCloudPlatform/DataflowTemplates/issues/34489 for context.
67+
6368
## List of Contributors
6469

6570
According to git shortlog, the following people contributed to the 2.64.0 release. Thank you to all contributors!

0 commit comments

Comments
 (0)