From 1d33bd7ab6d04110bbfa74f2b165db4d5e2bbbdc Mon Sep 17 00:00:00 2001 From: Noam Lewis Date: Tue, 21 Nov 2023 19:13:04 +0000 Subject: [PATCH] fix: add missing @Override annotations on overriding methods --- .../com/google/auth/appengine/AppEngineCredentials.java | 2 ++ .../java/com/google/auth/oauth2/CloudShellCredentials.java | 2 ++ .../com/google/auth/oauth2/ComputeEngineCredentials.java | 2 ++ .../java/com/google/auth/oauth2/DownscopedCredentials.java | 1 + .../oauth2/ExternalAccountAuthorizedUserCredentials.java | 4 ++++ .../com/google/auth/oauth2/ExternalAccountCredentials.java | 2 ++ .../java/com/google/auth/oauth2/GdchCredentials.java | 2 ++ .../java/com/google/auth/oauth2/GoogleCredentials.java | 2 ++ .../java/com/google/auth/oauth2/IdTokenCredentials.java | 2 ++ .../com/google/auth/oauth2/IdentityPoolCredentials.java | 1 + .../com/google/auth/oauth2/ImpersonatedCredentials.java | 3 +++ .../java/com/google/auth/oauth2/OAuth2Credentials.java | 1 + .../google/auth/oauth2/OAuth2CredentialsWithRefresh.java | 1 + oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java | 1 + .../com/google/auth/oauth2/ServiceAccountCredentials.java | 3 +++ .../java/com/google/auth/oauth2/UserCredentials.java | 6 ++++++ .../google/auth/oauth2/DefaultCredentialsProviderTest.java | 3 +++ 17 files changed, 38 insertions(+) diff --git a/appengine/java/com/google/auth/appengine/AppEngineCredentials.java b/appengine/java/com/google/auth/appengine/AppEngineCredentials.java index 3af489d67..16d046907 100644 --- a/appengine/java/com/google/auth/appengine/AppEngineCredentials.java +++ b/appengine/java/com/google/auth/appengine/AppEngineCredentials.java @@ -139,6 +139,7 @@ public static Builder newBuilder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -175,6 +176,7 @@ public AppIdentityService getAppIdentityService() { return appIdentityService; } + @Override public AppEngineCredentials build() { return new AppEngineCredentials(scopes, appIdentityService); } diff --git a/oauth2_http/java/com/google/auth/oauth2/CloudShellCredentials.java b/oauth2_http/java/com/google/auth/oauth2/CloudShellCredentials.java index 8574f0108..2baa77f50 100644 --- a/oauth2_http/java/com/google/auth/oauth2/CloudShellCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/CloudShellCredentials.java @@ -115,6 +115,7 @@ public boolean equals(Object obj) { return this.authPort == other.authPort; } + @Override public Builder toBuilder() { return new Builder(this); } @@ -142,6 +143,7 @@ public int getAuthPort() { return authPort; } + @Override public CloudShellCredentials build() { return new CloudShellCredentials(authPort); } diff --git a/oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java index 735860d86..59bfc7e7b 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java @@ -457,6 +457,7 @@ private void readObject(ObjectInputStream input) throws IOException, ClassNotFou transportFactory = newInstance(transportFactoryClassName); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -570,6 +571,7 @@ public Collection getScopes() { return scopes; } + @Override public ComputeEngineCredentials build() { return new ComputeEngineCredentials(transportFactory, scopes, null); } diff --git a/oauth2_http/java/com/google/auth/oauth2/DownscopedCredentials.java b/oauth2_http/java/com/google/auth/oauth2/DownscopedCredentials.java index a8447a69a..43709d779 100644 --- a/oauth2_http/java/com/google/auth/oauth2/DownscopedCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/DownscopedCredentials.java @@ -185,6 +185,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { return this; } + @Override public DownscopedCredentials build() { return new DownscopedCredentials( sourceCredential, credentialAccessBoundary, transportFactory); diff --git a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java index 0f87464bd..f57c15e22 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java @@ -292,6 +292,7 @@ public boolean equals(Object obj) { && Objects.equals(this.quotaProjectId, credentials.quotaProjectId); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -499,6 +500,7 @@ public Builder setClientSecret(String clientSecret) { * @param quotaProjectId the quota and billing project id to set * @return this {@code Builder} object */ + @Override @CanIgnoreReturnValue public Builder setQuotaProjectId(String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); @@ -511,12 +513,14 @@ public Builder setQuotaProjectId(String quotaProjectId) { * @param accessToken the access token * @return this {@code Builder} object */ + @Override @CanIgnoreReturnValue public Builder setAccessToken(AccessToken accessToken) { super.setAccessToken(accessToken); return this; } + @Override public ExternalAccountAuthorizedUserCredentials build() { return new ExternalAccountAuthorizedUserCredentials(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java index 45d7dda9c..03d81daaf 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java @@ -853,6 +853,7 @@ public Builder setTokenInfoUrl(String tokenInfoUrl) { * @param quotaProjectId the quota and billing project id to set * @return this {@code Builder} object */ + @Override @CanIgnoreReturnValue public Builder setQuotaProjectId(String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); @@ -945,6 +946,7 @@ Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) { return this; } + @Override public abstract ExternalAccountCredentials build(); } } diff --git a/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java b/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java index 4ffa87520..642dd7858 100644 --- a/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java @@ -311,6 +311,7 @@ public static Builder newBuilder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -475,6 +476,7 @@ public int getLifetime() { return lifetime; } + @Override public GdchCredentials build() { return new GdchCredentials(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java b/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java index 258a347c3..40ac5a9b3 100644 --- a/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java @@ -270,6 +270,7 @@ public static Builder newBuilder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -356,6 +357,7 @@ protected Builder(GoogleCredentials credentials) { this.quotaProjectId = credentials.quotaProjectId; } + @Override public GoogleCredentials build() { return new GoogleCredentials(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/IdTokenCredentials.java b/oauth2_http/java/com/google/auth/oauth2/IdTokenCredentials.java index a9bd03208..42bdbaa6e 100644 --- a/oauth2_http/java/com/google/auth/oauth2/IdTokenCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/IdTokenCredentials.java @@ -149,6 +149,7 @@ public boolean equals(Object obj) { && Objects.equals(this.targetAudience, other.targetAudience); } + @Override public Builder toBuilder() { return new Builder() .setIdTokenProvider(this.idTokenProvider) @@ -198,6 +199,7 @@ public List getOptions() { return this.options; } + @Override public IdTokenCredentials build() { return new IdTokenCredentials(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java b/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java index fcfc7bb9b..776a01e05 100644 --- a/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java @@ -183,6 +183,7 @@ public static class Builder extends ExternalAccountCredentials.Builder { super(credentials); } + @Override @CanIgnoreReturnValue public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) { super.setWorkforcePoolUserProject(workforcePoolUserProject); diff --git a/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java index d54d5b547..6d4ef09e1 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java @@ -600,6 +600,7 @@ public boolean equals(Object obj) { && Objects.equals(this.iamEndpointOverride, other.iamEndpointOverride); } + @Override public Builder toBuilder() { return new Builder(this.sourceCredentials, this.targetPrincipal); } @@ -686,6 +687,7 @@ public HttpTransportFactory getHttpTransportFactory() { return transportFactory; } + @Override @CanIgnoreReturnValue public Builder setQuotaProjectId(String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); @@ -708,6 +710,7 @@ public Calendar getCalendar() { return this.calendar; } + @Override public ImpersonatedCredentials build() { return new ImpersonatedCredentials(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java b/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java index 7eafd530e..e6cfc458c 100644 --- a/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java @@ -630,6 +630,7 @@ public ListenableFutureTask getTask() { return this.task; } + @Override public void run() { task.run(); } diff --git a/oauth2_http/java/com/google/auth/oauth2/OAuth2CredentialsWithRefresh.java b/oauth2_http/java/com/google/auth/oauth2/OAuth2CredentialsWithRefresh.java index 14e3ddae8..954378f7b 100644 --- a/oauth2_http/java/com/google/auth/oauth2/OAuth2CredentialsWithRefresh.java +++ b/oauth2_http/java/com/google/auth/oauth2/OAuth2CredentialsWithRefresh.java @@ -113,6 +113,7 @@ public Builder setRefreshHandler(OAuth2RefreshHandler handler) { return this; } + @Override public OAuth2CredentialsWithRefresh build() { return new OAuth2CredentialsWithRefresh(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java b/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java index a1d276bad..d4a29d515 100644 --- a/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java +++ b/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java @@ -99,6 +99,7 @@ class OAuth2Utils { static class DefaultHttpTransportFactory implements HttpTransportFactory { + @Override public HttpTransport create() { return HTTP_TRANSPORT; } diff --git a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java index c83c8ff97..463b0d3c2 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java @@ -967,6 +967,7 @@ public static Builder newBuilder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -1074,6 +1075,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { return this; } + @Override @CanIgnoreReturnValue public Builder setQuotaProjectId(String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); @@ -1150,6 +1152,7 @@ public boolean isDefaultRetriesEnabled() { return defaultRetriesEnabled; } + @Override public ServiceAccountCredentials build() { return new ServiceAccountCredentials(this); } diff --git a/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java b/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java index abc040f25..5ac22da56 100644 --- a/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java @@ -366,6 +366,7 @@ public static Builder newBuilder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(this); } @@ -419,24 +420,28 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { return this; } + @Override @CanIgnoreReturnValue public Builder setAccessToken(AccessToken token) { super.setAccessToken(token); return this; } + @Override @CanIgnoreReturnValue public Builder setExpirationMargin(Duration expirationMargin) { super.setExpirationMargin(expirationMargin); return this; } + @Override @CanIgnoreReturnValue public Builder setRefreshMargin(Duration refreshMargin) { super.setRefreshMargin(refreshMargin); return this; } + @Override @CanIgnoreReturnValue public Builder setQuotaProjectId(String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); @@ -463,6 +468,7 @@ public HttpTransportFactory getHttpTransportFactory() { return transportFactory; } + @Override public UserCredentials build() { return new UserCredentials(this); } diff --git a/oauth2_http/javatests/com/google/auth/oauth2/DefaultCredentialsProviderTest.java b/oauth2_http/javatests/com/google/auth/oauth2/DefaultCredentialsProviderTest.java index 3b7abe203..d0e921c20 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/DefaultCredentialsProviderTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/DefaultCredentialsProviderTest.java @@ -616,6 +616,7 @@ private String tempFilePath(String filename) { private class LogHandler extends Handler { LogRecord lastRecord; + @Override public void publish(LogRecord record) { lastRecord = record; } @@ -624,8 +625,10 @@ public LogRecord getRecord() { return lastRecord; } + @Override public void close() {} + @Override public void flush() {} }