Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add a workaround to make sure grpc clients' hosts always match their universe domain #2588

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,12 @@ public GrpcStorageOptions.Builder setBlobWriteSessionConfig(
@BetaApi
@Override
public GrpcStorageOptions build() {
return new GrpcStorageOptions(this, defaults());
GrpcStorageOptions options = new GrpcStorageOptions(this, defaults());
if (options.getUniverseDomain() != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a todo-link to the issue to be fixed in sdk-platform-java? Merge away afterward.

this.setHost("https://storage." + options.getUniverseDomain());
return new GrpcStorageOptions(this, defaults());
}
return options;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public void grpc() throws Exception {
() -> assertThat(rebuilt.hashCode()).isEqualTo(base.hashCode()));
}

@Test
public void testGrpcUniverseDomainMatchesHost() throws Exception {
Storage storage =
StorageOptions.grpc().setUniverseDomain("my-universe-domain.com").build().getService();
assertAll(
() -> assertThat(storage.getOptions().getUniverseDomain().equals("my-universe-domain.com")),
() ->
assertThat(
storage.getOptions().getHost().equals("https://storage.my-universe-domain.com")));
}

private static class MyStorageRetryStrategy implements StorageRetryStrategy {

@Override
Expand Down
Loading