nielsbasjes commented on a change in pull request #12846:
URL: https://github.com/apache/flink/pull/12846#discussion_r457943087



##########
File path: 
flink-connectors/flink-connector-gcp-pubsub/src/main/java/org/apache/flink/streaming/connectors/gcp/pubsub/PubSubSink.java
##########
@@ -273,7 +290,13 @@ private PubSubSinkBuilder(SerializationSchema<IN> 
serializationSchema) {
                 */
                public PubSubSink<IN> build() throws IOException {
                        if (credentials == null) {
-                               credentials = 
defaultCredentialsProviderBuilder().build().getCredentials();
+                               if (hostAndPort == null) {
+                                       // No hostAndPort is the normal 
scenario so we use the default credentials.
+                                       credentials = 
defaultCredentialsProviderBuilder().build().getCredentials();
+                               } else {
+                                       // With hostAndPort the PubSub emulator 
is used so we do not have credentials.
+                                       credentials = 
EmulatorCredentials.getInstance();
+                               }

Review comment:
       You can already pass different credentials if you want to via the 
withCredentials method in both the normal and the emulator situations.
   
   This code is about which are the right **default** credentials to choose in 
case none were provided: Either the default Google credentials or (in case the 
emulator was specified) the "Emulator Credentials".




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

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


Reply via email to