From a78a3a5fe8f1eb7ca260d1858b9704308576c9fa Mon Sep 17 00:00:00 2001 From: Noam Lewis Date: Sun, 5 Nov 2023 13:32:48 +0000 Subject: [PATCH] fix: remove -Xlint:unchecked, suppress all existing violations --- .../com/google/auth/oauth2/ExternalAccountCredentials.java | 1 + .../com/google/auth/oauth2/IdentityPoolCredentialSource.java | 1 + .../java/com/google/auth/oauth2/ImpersonatedCredentials.java | 3 ++- oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java | 1 + .../com/google/auth/oauth2/PluggableAuthCredentialSource.java | 1 + .../javatests/com/google/auth/oauth2/AwsCredentialsTest.java | 2 ++ .../com/google/auth/oauth2/ExternalAccountCredentialsTest.java | 2 ++ .../auth/oauth2/MockExternalAccountCredentialsTransport.java | 1 + pom.xml | 1 - 9 files changed, 11 insertions(+), 2 deletions(-) diff --git a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java index 930c1bb4e..45d7dda9c 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java @@ -396,6 +396,7 @@ public static ExternalAccountCredentials fromStream( * @param transportFactory HTTP transport factory, creates the transport used to get access tokens * @return the credentials defined by the JSON */ + @SuppressWarnings("unchecked") static ExternalAccountCredentials fromJson( Map json, HttpTransportFactory transportFactory) { checkNotNull(json); diff --git a/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentialSource.java b/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentialSource.java index ea7166184..6fa9e6f41 100644 --- a/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentialSource.java +++ b/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentialSource.java @@ -65,6 +65,7 @@ public class IdentityPoolCredentialSource extends ExternalAccountCredentials.Cre * *

Optional headers can be present, and should be keyed by `headers`. */ + @SuppressWarnings("unchecked") public IdentityPoolCredentialSource(Map credentialSourceMap) { super(credentialSourceMap); diff --git a/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java index 7c0145d11..d54d5b547 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java @@ -362,6 +362,7 @@ public byte[] sign(byte[] toSign) { * @return the credentials defined by the JSON * @throws IOException if the credential cannot be created from the JSON. */ + @SuppressWarnings("unchecked") static ImpersonatedCredentials fromJson( Map json, HttpTransportFactory transportFactory) throws IOException { @@ -419,7 +420,7 @@ public boolean createScopedRequired() { @Override public GoogleCredentials createScoped(Collection scopes) { return toBuilder() - .setScopes(new ArrayList(scopes)) + .setScopes(new ArrayList<>(scopes)) .setLifetime(this.lifetime) .setDelegates(this.delegates) .setHttpTransportFactory(this.transportFactory) diff --git a/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java b/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java index fce0abc12..a1d276bad 100644 --- a/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java +++ b/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java @@ -170,6 +170,7 @@ static String validateOptionalString(Map map, String key, String } /** Return the specified list of strings from JSON or throw a helpful error message. */ + @SuppressWarnings("unchecked") static List validateOptionalListString( Map map, String key, String errorPrefix) throws IOException { Object value = map.get(key); diff --git a/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentialSource.java b/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentialSource.java index 1554dd9cb..44406e7f9 100644 --- a/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentialSource.java +++ b/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentialSource.java @@ -80,6 +80,7 @@ public class PluggableAuthCredentialSource extends ExternalAccountCredentials.Cr // location. @Nullable final String outputFilePath; + @SuppressWarnings("unchecked") public PluggableAuthCredentialSource(Map credentialSourceMap) { super(credentialSourceMap); diff --git a/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java b/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java index b1e384020..b6e73fcce 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java @@ -210,6 +210,7 @@ public void refreshAccessToken_withServiceAccountImpersonationOptions() throws I } @Test + @SuppressWarnings("unchecked") public void retrieveSubjectToken() throws IOException { MockExternalAccountCredentialsTransportFactory transportFactory = new MockExternalAccountCredentialsTransportFactory(); @@ -254,6 +255,7 @@ public void retrieveSubjectToken() throws IOException { } @Test + @SuppressWarnings("unchecked") public void retrieveSubjectTokenWithSessionTokenUrl() throws IOException { MockExternalAccountCredentialsTransportFactory transportFactory = new MockExternalAccountCredentialsTransportFactory(); diff --git a/oauth2_http/javatests/com/google/auth/oauth2/ExternalAccountCredentialsTest.java b/oauth2_http/javatests/com/google/auth/oauth2/ExternalAccountCredentialsTest.java index ec558cfa8..6d2fe38dc 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/ExternalAccountCredentialsTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/ExternalAccountCredentialsTest.java @@ -346,6 +346,7 @@ public void fromJson_pluggableAuthCredentialsWorkforce() { } @Test + @SuppressWarnings("unchecked") public void fromJson_pluggableAuthCredentials_allExecutableOptionsSet() { GenericJson json = buildJsonPluggableAuthCredential(); Map credentialSourceMap = (Map) json.get("credential_source"); @@ -400,6 +401,7 @@ public void fromJson_pluggableAuthCredentialsWithServiceAccountImpersonationOpti } @Test + @SuppressWarnings("unchecked") public void fromJson_pluggableAuthCredentials_withUniverseDomain() { GenericJson json = buildJsonPluggableAuthCredential(); json.set("universe_domain", "universeDomain"); diff --git a/oauth2_http/javatests/com/google/auth/oauth2/MockExternalAccountCredentialsTransport.java b/oauth2_http/javatests/com/google/auth/oauth2/MockExternalAccountCredentialsTransport.java index 16c82c43b..a8208fb65 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/MockExternalAccountCredentialsTransport.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/MockExternalAccountCredentialsTransport.java @@ -112,6 +112,7 @@ public void addScopeSequence(List... scopes) { } @Override + @SuppressWarnings("unchecked") public LowLevelHttpRequest buildRequest(final String method, final String url) { MockLowLevelHttpRequest request = new MockLowLevelHttpRequest(url) { diff --git a/pom.xml b/pom.xml index ae7bfa08a..164bcdf2a 100644 --- a/pom.xml +++ b/pom.xml @@ -232,7 +232,6 @@ 1.8 1.8 UTF-8 - -Xlint:unchecked