[NO ISSUE][*DB] Apply missing change for GCS anonymous
Change-Id: I20aff3a73a822ff8627af685cd33b904384d6905
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17607
Reviewed-by: Hussain Towaileb <hussainht@gmail.com>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/google/gcs/GCSUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/google/gcs/GCSUtils.java
index 3efb041..6183a88 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/google/gcs/GCSUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/google/gcs/GCSUtils.java
@@ -58,6 +58,7 @@
import com.google.api.gax.paging.Page;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.BaseServiceException;
+import com.google.cloud.NoCredentials;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
@@ -101,15 +102,14 @@
} catch (IOException ex) {
throw CompilationException.create(EXTERNAL_SOURCE_ERROR, getMessageOrToString(ex));
}
- }
-
- // json credentials
- if (jsonCredentials != null) {
+ } else if (jsonCredentials != null) {
try (InputStream credentialsStream = new ByteArrayInputStream(jsonCredentials.getBytes())) {
builder.setCredentials(GoogleCredentials.fromStream(credentialsStream));
} catch (IOException ex) {
throw new CompilationException(EXTERNAL_SOURCE_ERROR, getMessageOrToString(ex));
}
+ } else {
+ builder.setCredentials(NoCredentials.getInstance());
}
if (endpoint != null) {