damccorm commented on code in PR #41473:
URL: https://github.com/apache/beam/pull/41473#discussion_r4787657804


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java:
##########
@@ -311,9 +335,11 @@ static SpannerOptions buildSpannerOptions(SpannerConfig 
spannerConfig, OpenTelem
       builder.setDirectedReadOptions(directedReadOptions.get());
     }
     ValueProvider<Credentials> credentials = spannerConfig.getCredentials();
-    if (credentials != null && credentials.get() != null) {
+    if (resolvedEmulatorHost != null) {
+      builder.setCredentials(NoCredentials.getInstance());
+    } else if (credentials != null && credentials.get() != null) {
       builder.setCredentials(credentials.get());

Review Comment:
   I think there is a small likely unintended change in behavior here when:
   
   - resolvedEmulatorHost is non-null
   - credentials are also non-null
   - experimentalHost is set
   
   In this case, previously we would have passed credentials.get() to the 
builder here, but now we'll pass NoCredentials.getInstance().
   
   That doesn't matter if no experimental host is set since the creds [get 
discarded](https://github.com/googleapis/java-spanner/blob/7c466974099eceddad563998e2d34c47713112b5/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java#L2077),
 but it will matter if it is an experimentalHost.
   
   In general, would it be cleaner to just keep the current logic and extend it 
to resolvedEmulatorHost? I'm thinking something like:
   
   ```
   if (credentials != null && credentials.get() != null) {
      builder.setCredentials(credentials.get());
   } else if (hasExperimentalHost || resolvedEmulatorHost != null) {
      builder.setCredentials(NoCredentials.getInstance());
   }
   ```
   
   That way we pass the credentials through no matter what and don't have to 
worry about dropping them ourselves.



-- 
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