Skip to content

Commit

Permalink
fix: handle error-prone warnings (#1334)
Browse files Browse the repository at this point in the history
* fix: pom.xml - remove duplicate dependencies / plugin clauses that cause warnings

This prevents the following errors:

$ mvn install -DskipTests=true
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.google.auth:google-auth-library-oauth2-http:jar:1.20.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> duplicate declaration of version (?) @ line 249, column 17
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-failsafe-plugin @ line 193, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]

* fix: add missing @OverRide annotations on overriding methods

---------

Co-authored-by: Noam Lewis <noamlewis@google.com>
Co-authored-by: Timur Sadykov <stim@google.com>
  • Loading branch information
3 people committed Jan 9, 2024
1 parent 7e26861 commit 927cad8
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public static Builder newBuilder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -175,6 +176,7 @@ public AppIdentityService getAppIdentityService() {
return appIdentityService;
}

@Override
public AppEngineCredentials build() {
return new AppEngineCredentials(scopes, appIdentityService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public boolean equals(Object obj) {
return this.authPort == other.authPort;
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -142,6 +143,7 @@ public int getAuthPort() {
return authPort;
}

@Override
public CloudShellCredentials build() {
return new CloudShellCredentials(authPort);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ private void readObject(ObjectInputStream input) throws IOException, ClassNotFou
transportFactory = newInstance(transportFactoryClassName);
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -675,6 +676,7 @@ public Collection<String> getDefaultScopes() {
return defaultScopes;
}

@Override
public ComputeEngineCredentials build() {
return new ComputeEngineCredentials(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
return this;
}

@Override
public DownscopedCredentials build() {
return new DownscopedCredentials(
sourceCredential, credentialAccessBoundary, transportFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public boolean equals(Object obj) {
&& Objects.equals(this.quotaProjectId, credentials.quotaProjectId);
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -501,6 +502,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);
Expand All @@ -513,12 +515,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,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);
Expand Down Expand Up @@ -941,6 +942,7 @@ Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) {
return this;
}

@Override
public abstract ExternalAccountCredentials build();
}
}
2 changes: 2 additions & 0 deletions oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public static Builder newBuilder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -475,6 +476,7 @@ public int getLifetime() {
return lifetime;
}

@Override
public GdchCredentials build() {
return new GdchCredentials(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ public static Builder newBuilder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -502,6 +503,7 @@ protected Builder(GoogleCredentials.Builder builder) {
this.universeDomain = builder.universeDomain;
}

@Override
public GoogleCredentials build() {
return new GoogleCredentials(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -198,6 +199,7 @@ public List<IdTokenProvider.Option> getOptions() {
return this.options;
}

@Override
public IdTokenCredentials build() {
return new IdTokenCredentials(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public static class Builder extends ExternalAccountCredentials.Builder {
super(credentials);
}

@Override
@CanIgnoreReturnValue
public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) {
super.setWorkforcePoolUserProject(workforcePoolUserProject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ public boolean equals(Object obj) {
&& Objects.equals(this.iamEndpointOverride, other.iamEndpointOverride);
}

@Override
public Builder toBuilder() {
return new Builder(this.sourceCredentials, this.targetPrincipal);
}
Expand Down Expand Up @@ -688,6 +689,7 @@ public HttpTransportFactory getHttpTransportFactory() {
return transportFactory;
}

@Override
@CanIgnoreReturnValue
public Builder setQuotaProjectId(String quotaProjectId) {
super.setQuotaProjectId(quotaProjectId);
Expand All @@ -710,6 +712,7 @@ public Calendar getCalendar() {
return this.calendar;
}

@Override
public ImpersonatedCredentials build() {
return new ImpersonatedCredentials(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ public ListenableFutureTask<OAuthValue> getTask() {
return this.task;
}

@Override
public void run() {
task.run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public Builder setRefreshHandler(OAuth2RefreshHandler handler) {
return this;
}

@Override
public OAuth2CredentialsWithRefresh build() {
return new OAuth2CredentialsWithRefresh(this);
}
Expand Down
1 change: 1 addition & 0 deletions oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class OAuth2Utils {

static class DefaultHttpTransportFactory implements HttpTransportFactory {

@Override
public HttpTransport create() {
return HTTP_TRANSPORT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ public static Builder newBuilder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -1103,6 +1104,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
return this;
}

@Override
@CanIgnoreReturnValue
public Builder setQuotaProjectId(String quotaProjectId) {
super.setQuotaProjectId(quotaProjectId);
Expand Down Expand Up @@ -1188,6 +1190,7 @@ public boolean isDefaultRetriesEnabled() {
return defaultRetriesEnabled;
}

@Override
public ServiceAccountCredentials build() {
return new ServiceAccountCredentials(this);
}
Expand Down
6 changes: 6 additions & 0 deletions oauth2_http/java/com/google/auth/oauth2/UserCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ public static Builder newBuilder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return new Builder(this);
}
Expand Down Expand Up @@ -425,24 +426,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);
Expand All @@ -469,6 +474,7 @@ public HttpTransportFactory getHttpTransportFactory() {
return transportFactory;
}

@Override
public UserCredentials build() {
return new UserCredentials(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ private String tempFilePath(String filename) {
private class LogHandler extends Handler {
LogRecord lastRecord;

@Override
public void publish(LogRecord record) {
lastRecord = record;
}
Expand All @@ -614,8 +615,10 @@ public LogRecord getRecord() {
return lastRecord;
}

@Override
public void close() {}

@Override
public void flush() {}
}

Expand Down
26 changes: 8 additions & 18 deletions oauth2_http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@
<include>**/functional/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -175,18 +183,6 @@
<reportNameSuffix>sponge_log</reportNameSuffix>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -231,12 +227,6 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down

0 comments on commit 927cad8

Please sign in to comment.