bvolpato commented on code in PR #27987:
URL: https://github.com/apache/beam/pull/27987#discussion_r1359961890


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/datastore/DatastoreV1.java:
##########
@@ -1526,15 +1748,28 @@ static class DatastoreWriterFn extends DoFn<Mutation, 
Void> {
         @Nullable String localhost,
         V1DatastoreFactory datastoreFactory,
         WriteBatcher writeBatcher) {
+      this(projectId, null, localhost, datastoreFactory, writeBatcher);
+    }
+
+    @VisibleForTesting
+    DatastoreWriterFn(
+        ValueProvider<String> projectId,
+        ValueProvider<String> databaseIdProvider,
+        @Nullable String localhost,
+        V1DatastoreFactory datastoreFactory,
+        WriteBatcher writeBatcher) {
       this.projectId = checkNotNull(projectId, "projectId");
+      this.databaseId = databaseIdProvider == null ? DEFAULT_DATABASE : 
databaseIdProvider.get();

Review Comment:
   `.get()` here defeats the purpose of ValueProviders. Even if it's null, it 
doesn't mean that it is accessible (e.g., in case of RuntimeValueProvider).
   
   Ideally you would `.get()` only inside a DoFn. My suggestion would be to 
keep it using the same thing as we do for `projectId`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to