Skip to content

Commit f2ec619

Browse files
SNOW-1889398: Handle endpoint without protocol for GCS (#2038)
1 parent bee2e4b commit f2ec619

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ private void setupGCSClient(
13141314
if (accessToken != null) {
13151315
// We are authenticated with an oauth access token.
13161316
StorageOptions.Builder builder = StorageOptions.newBuilder();
1317-
stage.gcsCustomEndpoint().ifPresent(builder::setHost);
1317+
overrideHost(stage, builder);
13181318

13191319
if (areDisabledGcsDefaultCredentials(session)) {
13201320
logger.debug(
@@ -1335,7 +1335,7 @@ private void setupGCSClient(
13351335
// Use anonymous authentication.
13361336
HttpStorageOptions.Builder builder =
13371337
HttpStorageOptions.newBuilder().setCredentials(NoCredentials.getInstance());
1338-
stage.gcsCustomEndpoint().ifPresent(builder::setHost);
1338+
overrideHost(stage, builder);
13391339
this.gcsClient = builder.build().getService();
13401340
}
13411341

@@ -1357,6 +1357,19 @@ private void setupGCSClient(
13571357
}
13581358
}
13591359

1360+
private static void overrideHost(StageInfo stage, StorageOptions.Builder builder) {
1361+
stage
1362+
.gcsCustomEndpoint()
1363+
.ifPresent(
1364+
host -> {
1365+
if (host.startsWith("https://")) {
1366+
builder.setHost(host);
1367+
} else {
1368+
builder.setHost("https://" + host);
1369+
}
1370+
});
1371+
}
1372+
13601373
private static boolean areDisabledGcsDefaultCredentials(SFSession session) {
13611374
return session != null && session.getDisableGcsDefaultCredentials()
13621375
|| convertSystemPropertyToBooleanValue(

0 commit comments

Comments
 (0)