Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4069e9b
fix(oauth2_http): avoid retrying on 403 Forbidden during GCE metadata…
macastelaz Jul 8, 2026
d03d42c
test: assert exactly 1 request is made on 403 in isOnGce_forbidden_do…
macastelaz Jul 8, 2026
b38389c
fix(oauth2_http): downgrade instanceof pattern matching for Java 8 co…
macastelaz Jul 8, 2026
cd409a9
test: add getRequestCount to MockMetadataServerTransport to support v…
macastelaz Jul 9, 2026
3c7ca3e
chore: sync java-showcase generated files
macastelaz Jul 9, 2026
b5f6618
test: mock getOsName in isOnGce_forbidden_doesNotRetry to avoid CI en…
macastelaz Jul 9, 2026
86ec2fd
feat(oauth2_http): fail fast on all 4xx client errors during GCE ping
macastelaz Jul 9, 2026
345c3ef
test: mock lowercase os name for linux in gce detection tests
macastelaz Jul 9, 2026
bf4d821
style(oauth2_http): format ComputeEngineCredentialsTest
macastelaz Jul 9, 2026
1ecf6ea
Address review comments
macastelaz Jul 13, 2026
1e46c24
Merge branch 'main' into remove-gce-403-retry
macastelaz Jul 13, 2026
4a30454
Fix CI styling errors
macastelaz Jul 13, 2026
83634c4
Fix trailing spaces to satisfy formatter
macastelaz Jul 13, 2026
69b21ff
Merge branch 'main' into remove-gce-403-retry
macastelaz Jul 14, 2026
3096a47
Fix Windows proto compilation issue with UDM
macastelaz Jul 14, 2026
ced1e31
Fix JDK 21 compiler bug in generated gRPC code
macastelaz Jul 14, 2026
2e61017
Fix generated code for UdmProto rename to fix Windows CI
macastelaz Jul 14, 2026
23f7bc0
Retrigger CI
macastelaz Jul 14, 2026
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 @@ -673,6 +673,10 @@ private static boolean pingComputeEngineMetadata(
} catch (SocketTimeoutException expected) {
// Ignore logging timeouts which is the expected failure mode in non GCE environments.
} catch (IOException e) {
if (e instanceof HttpResponseException
&& ((HttpResponseException) e).getStatusCode() == 403) {
Comment thread
macastelaz marked this conversation as resolved.
Outdated
return false;
}
LOGGER.log(
Level.FINE,
"Encountered an unexpected exception when checking"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,23 @@ void getProjectId_explicitSet_noMDsCall() {
assertEquals(0, transportFactory.transport.getRequestCount());
}

@Test
void isOnGce_forbidden_doesNotRetry() {
Comment thread
macastelaz marked this conversation as resolved.
Outdated
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
transportFactory.transport.setStatusCode(HttpStatusCodes.STATUS_CODE_FORBIDDEN);
UnknownOsCredentialsProvider provider = new UnknownOsCredentialsProvider();
boolean isOnGce = ComputeEngineCredentials.isOnGce(transportFactory, provider);
assertFalse(isOnGce);
assertEquals(1, transportFactory.transport.getRequestCount());
}

static class UnknownOsCredentialsProvider extends DefaultCredentialsProvider {
@Override
String getOsName() {
return "Unknown";
}
}

static class MockMetadataServerTransportFactory implements HttpTransportFactory {

MockMetadataServerTransport transport =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public class MockMetadataServerTransport extends MockHttpTransport {

private boolean emptyContent;
private MockLowLevelHttpRequest request;
private int requestCount = 0;

public int getRequestCount() {
return requestCount;
}

public MockMetadataServerTransport() {}

Expand Down Expand Up @@ -125,6 +130,7 @@ public MockLowLevelHttpRequest getRequest() {

@Override
public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
requestCount++;
if (url.startsWith(ComputeEngineCredentials.getTokenServerEncodedUrl())) {
this.request = getMockRequestForTokenEndpoint(url);
return this.request;
Expand Down
3 changes: 1 addition & 2 deletions java-showcase/.repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
"repo_short": "java-showcase",
"distribution_name": "com.google.cloud:gapic-showcase",
"library_type": "OTHER",
"requires_billing": true,
"excluded_poms": "gapic-showcase-bom"
Comment thread
macastelaz marked this conversation as resolved.
Outdated
"requires_billing": true
}
Loading