Skip to content

Commit dade9ff

Browse files
authored
Merge branch 'main' into patch-2
2 parents 3682a87 + 1191e0d commit dade9ff

6,493 files changed

Lines changed: 51443 additions & 47189 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/showcase-version-check.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,28 @@ on:
2222
- cron: '30 3 * * *' # Run daily at 3:30 AM UTC
2323
workflow_dispatch: # Allow manual trigger
2424
pull_request:
25-
paths:
26-
- 'librarian.yaml'
27-
- 'java-showcase/gapic-showcase/pom.xml'
28-
- '.github/workflows/showcase-version-check.yaml'
2925

3026
jobs:
31-
check-version:
27+
filter:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
should_run: ${{ steps.filter.outputs.should_run }}
31+
steps:
32+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
33+
with:
34+
persist-credentials: false
35+
- uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3
36+
id: filter
37+
with:
38+
filters: |
39+
should_run:
40+
- 'librarian.yaml'
41+
- 'java-showcase/gapic-showcase/pom.xml'
42+
- '.github/workflows/showcase-version-check.yaml'
43+
44+
check-showcase-version:
45+
needs: filter
46+
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.filter.outputs.should_run == 'true' }}
3247
runs-on: ubuntu-latest
3348
permissions:
3449
issues: write

google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,10 @@ void setProjectId(String projectId) {
648648
private static boolean pingComputeEngineMetadata(
649649
HttpTransportFactory transportFactory, DefaultCredentialsProvider provider) {
650650
GenericUrl tokenUrl = new GenericUrl(getMetadataServerUrl(provider));
651+
// pingComputeEngineMetadata is executed heavily during startup (within isOnGce()) on non-GCE
652+
// environments. We use a strict 500ms timeout and manual 3-try loop (instead of
653+
// ExponentialBackOff and HttpRequest.setUnsuccessfulResponseHandler) to fail fast and avoid
654+
// significantly delaying application startup for workflows running on local setups.
651655
for (int i = 1; i <= MAX_COMPUTE_PING_TRIES; ++i) {
652656
try {
653657
HttpRequest request =
@@ -673,6 +677,12 @@ private static boolean pingComputeEngineMetadata(
673677
} catch (SocketTimeoutException expected) {
674678
// Ignore logging timeouts which is the expected failure mode in non GCE environments.
675679
} catch (IOException e) {
680+
if (e instanceof HttpResponseException) {
681+
int statusCode = ((HttpResponseException) e).getStatusCode();
682+
if (statusCode >= 400 && statusCode < 500) {
683+
return false;
684+
}
685+
}
676686
LOGGER.log(
677687
Level.FINE,
678688
"Encountered an unexpected exception when checking"

google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/ComputeEngineCredentialsTest.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@
5858
import com.google.auth.TestUtils;
5959
import com.google.auth.http.HttpTransportFactory;
6060
import com.google.auth.oauth2.DefaultCredentialsProviderTest.MockRequestCountingTransportFactory;
61+
import java.io.ByteArrayInputStream;
62+
import java.io.File;
63+
import java.io.FileNotFoundException;
6164
import java.io.IOException;
65+
import java.io.InputStream;
6266
import java.net.URI;
67+
import java.nio.charset.StandardCharsets;
6368
import java.util.ArrayDeque;
6469
import java.util.Arrays;
6570
import java.util.Collection;
@@ -1177,6 +1182,60 @@ void getProjectId_explicitSet_noMDsCall() {
11771182
assertEquals(0, transportFactory.transport.getRequestCount());
11781183
}
11791184

1185+
@Test
1186+
void isOnGce_clientError_doesNotRetry_returnsFalseOnUnknownOs() {
1187+
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
1188+
transportFactory.transport.setStatusCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND);
1189+
DefaultCredentialsProvider provider =
1190+
new DefaultCredentialsProvider() {
1191+
@Override
1192+
String getEnv(String name) {
1193+
if (DefaultCredentialsProvider.NO_GCE_CHECK_ENV_VAR.equals(name)) {
1194+
return "false";
1195+
}
1196+
return super.getEnv(name);
1197+
}
1198+
1199+
@Override
1200+
String getOsName() {
1201+
return "Unknown";
1202+
}
1203+
};
1204+
boolean isOnGce = ComputeEngineCredentials.isOnGce(transportFactory, provider);
1205+
assertFalse(isOnGce);
1206+
assertEquals(1, transportFactory.transport.getRequestCount());
1207+
}
1208+
1209+
@Test
1210+
void isOnGce_clientError_doesNotRetry_returnsTrueOnLinuxGce() {
1211+
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
1212+
transportFactory.transport.setStatusCode(HttpStatusCodes.STATUS_CODE_FORBIDDEN);
1213+
DefaultCredentialsProvider provider =
1214+
new DefaultCredentialsProvider() {
1215+
@Override
1216+
String getEnv(String name) {
1217+
if (DefaultCredentialsProvider.NO_GCE_CHECK_ENV_VAR.equals(name)) {
1218+
return "false";
1219+
}
1220+
return super.getEnv(name);
1221+
}
1222+
1223+
@Override
1224+
String getOsName() {
1225+
return "linux";
1226+
}
1227+
1228+
@Override
1229+
InputStream readStream(File file) throws FileNotFoundException {
1230+
return new ByteArrayInputStream(
1231+
"Google Compute Engine".getBytes(StandardCharsets.UTF_8));
1232+
}
1233+
};
1234+
boolean isOnGce = ComputeEngineCredentials.isOnGce(transportFactory, provider);
1235+
assertTrue(isOnGce);
1236+
assertEquals(1, transportFactory.transport.getRequestCount());
1237+
}
1238+
11801239
static class MockMetadataServerTransportFactory implements HttpTransportFactory {
11811240

11821241
MockMetadataServerTransport transport =

google-auth-library-java/oauth2_http/javatests/com/google/auth/oauth2/MockMetadataServerTransport.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class MockMetadataServerTransport extends MockHttpTransport {
7171

7272
private boolean emptyContent;
7373
private MockLowLevelHttpRequest request;
74+
private int requestCount = 0;
75+
76+
public int getRequestCount() {
77+
return requestCount;
78+
}
7479

7580
public MockMetadataServerTransport() {}
7681

@@ -125,6 +130,7 @@ public MockLowLevelHttpRequest getRequest() {
125130

126131
@Override
127132
public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
133+
requestCount++;
128134
if (url.startsWith(ComputeEngineCredentials.getTokenServerEncodedUrl())) {
129135
this.request = getMockRequestForTokenEndpoint(url);
130136
return this.request;

java-accessapproval/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ the individual GitHub repository `github.com/GoogleAPIs/java-SERVICENAME`
147147
and on [google-cloud-java][g-c-j].
148148

149149
## Versioning
150-
151-
152150
This library follows [Semantic Versioning](http://semver.org/).
153151

154152

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/AccessApprovalAdminClient.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.concurrent.TimeUnit;
3535
import javax.annotation.Generated;
3636
import org.jspecify.annotations.NullMarked;
37+
import org.jspecify.annotations.Nullable;
3738

3839
// AUTO-GENERATED DOCUMENTATION AND CLASS.
3940
/**
@@ -318,7 +319,7 @@
318319
@NullMarked
319320
@Generated("by gapic-generator-java")
320321
public class AccessApprovalAdminClient implements BackgroundResource {
321-
private final AccessApprovalAdminSettings settings;
322+
private final @Nullable AccessApprovalAdminSettings settings;
322323
private final AccessApprovalStub stub;
323324

324325
/** Constructs an instance of AccessApprovalAdminClient with default settings. */
@@ -358,7 +359,7 @@ protected AccessApprovalAdminClient(AccessApprovalStub stub) {
358359
this.stub = stub;
359360
}
360361

361-
public final AccessApprovalAdminSettings getSettings() {
362+
public final @Nullable AccessApprovalAdminSettings getSettings() {
362363
return settings;
363364
}
364365

@@ -392,7 +393,7 @@ public AccessApprovalStub getStub() {
392393
* "organizations/{organization}".
393394
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
394395
*/
395-
public final ListApprovalRequestsPagedResponse listApprovalRequests(FolderName parent) {
396+
public final ListApprovalRequestsPagedResponse listApprovalRequests(@Nullable FolderName parent) {
396397
ListApprovalRequestsMessage request =
397398
ListApprovalRequestsMessage.newBuilder()
398399
.setParent(parent == null ? null : parent.toString())
@@ -426,7 +427,8 @@ public final ListApprovalRequestsPagedResponse listApprovalRequests(FolderName p
426427
* "organizations/{organization}".
427428
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
428429
*/
429-
public final ListApprovalRequestsPagedResponse listApprovalRequests(OrganizationName parent) {
430+
public final ListApprovalRequestsPagedResponse listApprovalRequests(
431+
@Nullable OrganizationName parent) {
430432
ListApprovalRequestsMessage request =
431433
ListApprovalRequestsMessage.newBuilder()
432434
.setParent(parent == null ? null : parent.toString())
@@ -460,7 +462,8 @@ public final ListApprovalRequestsPagedResponse listApprovalRequests(Organization
460462
* "organizations/{organization}".
461463
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
462464
*/
463-
public final ListApprovalRequestsPagedResponse listApprovalRequests(ProjectName parent) {
465+
public final ListApprovalRequestsPagedResponse listApprovalRequests(
466+
@Nullable ProjectName parent) {
464467
ListApprovalRequestsMessage request =
465468
ListApprovalRequestsMessage.newBuilder()
466469
.setParent(parent == null ? null : parent.toString())
@@ -636,7 +639,7 @@ public final ListApprovalRequestsPagedResponse listApprovalRequests(
636639
* "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
637640
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
638641
*/
639-
public final ApprovalRequest getApprovalRequest(ApprovalRequestName name) {
642+
public final ApprovalRequest getApprovalRequest(@Nullable ApprovalRequestName name) {
640643
GetApprovalRequestMessage request =
641644
GetApprovalRequestMessage.newBuilder()
642645
.setName(name == null ? null : name.toString())
@@ -980,7 +983,8 @@ public final ApprovalRequest invalidateApprovalRequest(InvalidateApprovalRequest
980983
* "{projects|folders|organizations}/{id}/accessApprovalSettings"
981984
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
982985
*/
983-
public final AccessApprovalSettings getAccessApprovalSettings(AccessApprovalSettingsName name) {
986+
public final AccessApprovalSettings getAccessApprovalSettings(
987+
@Nullable AccessApprovalSettingsName name) {
984988
GetAccessApprovalSettingsMessage request =
985989
GetAccessApprovalSettingsMessage.newBuilder()
986990
.setName(name == null ? null : name.toString())
@@ -1204,7 +1208,7 @@ public final AccessApprovalSettings updateAccessApprovalSettings(
12041208
* @param name Name of the AccessApprovalSettings to delete.
12051209
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
12061210
*/
1207-
public final void deleteAccessApprovalSettings(AccessApprovalSettingsName name) {
1211+
public final void deleteAccessApprovalSettings(@Nullable AccessApprovalSettingsName name) {
12081212
DeleteAccessApprovalSettingsMessage request =
12091213
DeleteAccessApprovalSettingsMessage.newBuilder()
12101214
.setName(name == null ? null : name.toString())
@@ -1457,9 +1461,10 @@ public static class ListApprovalRequestsPage
14571461
ListApprovalRequestsPage> {
14581462

14591463
private ListApprovalRequestsPage(
1460-
PageContext<ListApprovalRequestsMessage, ListApprovalRequestsResponse, ApprovalRequest>
1464+
@Nullable
1465+
PageContext<ListApprovalRequestsMessage, ListApprovalRequestsResponse, ApprovalRequest>
14611466
context,
1462-
ListApprovalRequestsResponse response) {
1467+
@Nullable ListApprovalRequestsResponse response) {
14631468
super(context, response);
14641469
}
14651470

@@ -1469,15 +1474,17 @@ private static ListApprovalRequestsPage createEmptyPage() {
14691474

14701475
@Override
14711476
protected ListApprovalRequestsPage createPage(
1472-
PageContext<ListApprovalRequestsMessage, ListApprovalRequestsResponse, ApprovalRequest>
1477+
@Nullable
1478+
PageContext<ListApprovalRequestsMessage, ListApprovalRequestsResponse, ApprovalRequest>
14731479
context,
1474-
ListApprovalRequestsResponse response) {
1480+
@Nullable ListApprovalRequestsResponse response) {
14751481
return new ListApprovalRequestsPage(context, response);
14761482
}
14771483

14781484
@Override
14791485
public ApiFuture<ListApprovalRequestsPage> createPageAsync(
1480-
PageContext<ListApprovalRequestsMessage, ListApprovalRequestsResponse, ApprovalRequest>
1486+
@Nullable
1487+
PageContext<ListApprovalRequestsMessage, ListApprovalRequestsResponse, ApprovalRequest>
14811488
context,
14821489
ApiFuture<ListApprovalRequestsResponse> futureResponse) {
14831490
return super.createPageAsync(context, futureResponse);
@@ -1493,7 +1500,7 @@ public static class ListApprovalRequestsFixedSizeCollection
14931500
ListApprovalRequestsFixedSizeCollection> {
14941501

14951502
private ListApprovalRequestsFixedSizeCollection(
1496-
List<ListApprovalRequestsPage> pages, int collectionSize) {
1503+
@Nullable List<ListApprovalRequestsPage> pages, int collectionSize) {
14971504
super(pages, collectionSize);
14981505
}
14991506

@@ -1503,7 +1510,7 @@ private static ListApprovalRequestsFixedSizeCollection createEmptyCollection() {
15031510

15041511
@Override
15051512
protected ListApprovalRequestsFixedSizeCollection createCollection(
1506-
List<ListApprovalRequestsPage> pages, int collectionSize) {
1513+
@Nullable List<ListApprovalRequestsPage> pages, int collectionSize) {
15071514
return new ListApprovalRequestsFixedSizeCollection(pages, collectionSize);
15081515
}
15091516
}

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/AccessApprovalAdminSettings.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.List;
3737
import javax.annotation.Generated;
3838
import org.jspecify.annotations.NullMarked;
39+
import org.jspecify.annotations.Nullable;
3940

4041
// AUTO-GENERATED DOCUMENTATION AND CLASS.
4142
/**
@@ -207,7 +208,7 @@ public static Builder newHttpJsonBuilder() {
207208
}
208209

209210
/** Returns a new builder for this class. */
210-
public static Builder newBuilder(ClientContext clientContext) {
211+
public static Builder newBuilder(@Nullable ClientContext clientContext) {
211212
return new Builder(clientContext);
212213
}
213214

@@ -227,7 +228,7 @@ protected Builder() throws IOException {
227228
this(((ClientContext) null));
228229
}
229230

230-
protected Builder(ClientContext clientContext) {
231+
protected Builder(@Nullable ClientContext clientContext) {
231232
super(AccessApprovalStubSettings.newBuilder(clientContext));
232233
}
233234

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/stub/AccessApprovalStubSettings.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import java.util.List;
6969
import javax.annotation.Generated;
7070
import org.jspecify.annotations.NullMarked;
71+
import org.jspecify.annotations.Nullable;
7172

7273
// AUTO-GENERATED DOCUMENTATION AND CLASS.
7374
/**
@@ -371,7 +372,7 @@ public static Builder newHttpJsonBuilder() {
371372
}
372373

373374
/** Returns a new builder for this class. */
374-
public static Builder newBuilder(ClientContext clientContext) {
375+
public static Builder newBuilder(@Nullable ClientContext clientContext) {
375376
return new Builder(clientContext);
376377
}
377378

@@ -481,7 +482,7 @@ protected Builder() {
481482
this(((ClientContext) null));
482483
}
483484

484-
protected Builder(ClientContext clientContext) {
485+
protected Builder(@Nullable ClientContext clientContext) {
485486
super(clientContext);
486487

487488
listApprovalRequestsSettings =

java-accessapproval/owlbot.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)