Skip to content

Commit 04dfd40

Browse files
sinelawNoam Lewis
and
Noam Lewis
authoredNov 21, 2023
fix: Remove -Xlint:unchecked, suppress all existing violations, add @CanIgnoreReturnValue (#1324)
* chore: add @CanIgnoreReturnValue to builder set methods Preparation for enabling errorprone * fix: remove -Xlint:unchecked, suppress all existing violations --------- Co-authored-by: Noam Lewis <noamlewis@google.com>
1 parent 47d9a6e commit 04dfd40

36 files changed

+196
-2
lines changed
 

‎appengine/java/com/google/auth/appengine/AppEngineCredentials.java

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.google.common.base.MoreObjects;
4141
import com.google.common.collect.ImmutableList;
4242
import com.google.common.collect.ImmutableSet;
43+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4344
import java.io.IOException;
4445
import java.io.ObjectInputStream;
4546
import java.util.Collection;
@@ -154,11 +155,13 @@ protected Builder(AppEngineCredentials credentials) {
154155
this.appIdentityService = credentials.appIdentityService;
155156
}
156157

158+
@CanIgnoreReturnValue
157159
public Builder setScopes(Collection<String> scopes) {
158160
this.scopes = scopes;
159161
return this;
160162
}
161163

164+
@CanIgnoreReturnValue
162165
public Builder setAppIdentityService(AppIdentityService appIdentityService) {
163166
this.appIdentityService = appIdentityService;
164167
return this;

‎appengine/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,10 @@
7979
<type>test-jar</type>
8080
<classifier>testlib</classifier>
8181
</dependency>
82+
<dependency>
83+
<groupId>com.google.errorprone</groupId>
84+
<artifactId>error_prone_annotations</artifactId>
85+
<scope>compile</scope>
86+
</dependency>
8287
</dependencies>
8388
</project>

‎oauth2_http/java/com/google/auth/oauth2/AccessToken.java

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
package com.google.auth.oauth2;
3333

3434
import com.google.common.base.MoreObjects;
35+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3536
import java.io.Serializable;
3637
import java.util.ArrayList;
3738
import java.util.Arrays;
@@ -158,18 +159,21 @@ public Date getExpirationTime() {
158159
return this.expirationTime;
159160
}
160161

162+
@CanIgnoreReturnValue
161163
public Builder setTokenValue(String tokenValue) {
162164
this.tokenValue = tokenValue;
163165
return this;
164166
}
165167

168+
@CanIgnoreReturnValue
166169
public Builder setScopes(String scopes) {
167170
if (scopes != null && scopes.trim().length() > 0) {
168171
this.scopes = Arrays.asList(scopes.split(" "));
169172
}
170173
return this;
171174
}
172175

176+
@CanIgnoreReturnValue
173177
public Builder setScopes(List<String> scopes) {
174178
if (scopes == null) {
175179
this.scopes = new ArrayList<>();
@@ -180,6 +184,7 @@ public Builder setScopes(List<String> scopes) {
180184
return this;
181185
}
182186

187+
@CanIgnoreReturnValue
183188
public Builder setExpirationTime(Date expirationTime) {
184189
this.expirationTime = expirationTime;
185190
return this;

‎oauth2_http/java/com/google/auth/oauth2/AwsRequestSignature.java

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
package com.google.auth.oauth2;
3333

34+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3435
import java.util.HashMap;
3536
import java.util.Map;
3637

@@ -130,46 +131,55 @@ static class Builder {
130131
private String region;
131132
private String authorizationHeader;
132133

134+
@CanIgnoreReturnValue
133135
Builder setSignature(String signature) {
134136
this.signature = signature;
135137
return this;
136138
}
137139

140+
@CanIgnoreReturnValue
138141
Builder setCredentialScope(String credentialScope) {
139142
this.credentialScope = credentialScope;
140143
return this;
141144
}
142145

146+
@CanIgnoreReturnValue
143147
Builder setSecurityCredentials(AwsSecurityCredentials awsSecurityCredentials) {
144148
this.awsSecurityCredentials = awsSecurityCredentials;
145149
return this;
146150
}
147151

152+
@CanIgnoreReturnValue
148153
Builder setUrl(String url) {
149154
this.url = url;
150155
return this;
151156
}
152157

158+
@CanIgnoreReturnValue
153159
Builder setHttpMethod(String httpMethod) {
154160
this.httpMethod = httpMethod;
155161
return this;
156162
}
157163

164+
@CanIgnoreReturnValue
158165
Builder setCanonicalHeaders(Map<String, String> canonicalHeaders) {
159166
this.canonicalHeaders = new HashMap<>(canonicalHeaders);
160167
return this;
161168
}
162169

170+
@CanIgnoreReturnValue
163171
Builder setDate(String date) {
164172
this.date = date;
165173
return this;
166174
}
167175

176+
@CanIgnoreReturnValue
168177
Builder setRegion(String region) {
169178
this.region = region;
170179
return this;
171180
}
172181

182+
@CanIgnoreReturnValue
173183
Builder setAuthorizationHeader(String authorizationHeader) {
174184
this.authorizationHeader = authorizationHeader;
175185
return this;

‎oauth2_http/java/com/google/auth/oauth2/AwsRequestSigner.java

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.google.common.base.Joiner;
3939
import com.google.common.base.Splitter;
4040
import com.google.common.io.BaseEncoding;
41+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4142
import java.net.URI;
4243
import java.security.InvalidKeyException;
4344
import java.security.MessageDigest;
@@ -298,11 +299,13 @@ private Builder(
298299
this.region = region;
299300
}
300301

302+
@CanIgnoreReturnValue
301303
Builder setRequestPayload(String requestPayload) {
302304
this.requestPayload = requestPayload;
303305
return this;
304306
}
305307

308+
@CanIgnoreReturnValue
306309
Builder setAdditionalHeaders(Map<String, String> additionalHeaders) {
307310
if (additionalHeaders.containsKey("date") && additionalHeaders.containsKey("x-amz-date")) {
308311
throw new IllegalArgumentException("One of {date, x-amz-date} can be specified, not both.");

‎oauth2_http/java/com/google/auth/oauth2/ClientId.java

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.google.api.client.json.GenericJson;
3535
import com.google.api.client.json.JsonObjectParser;
3636
import com.google.api.client.util.Preconditions;
37+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3738
import java.io.IOException;
3839
import java.io.InputStream;
3940
import java.nio.charset.StandardCharsets;
@@ -184,11 +185,13 @@ protected Builder(ClientId clientId) {
184185
this.clientSecret = clientId.getClientSecret();
185186
}
186187

188+
@CanIgnoreReturnValue
187189
public Builder setClientId(String clientId) {
188190
this.clientId = clientId;
189191
return this;
190192
}
191193

194+
@CanIgnoreReturnValue
192195
public Builder setClientSecret(String clientSecret) {
193196
this.clientSecret = clientSecret;
194197
return this;

‎oauth2_http/java/com/google/auth/oauth2/CloudShellCredentials.java

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.google.api.client.json.JsonParser;
3535
import com.google.common.base.Charsets;
3636
import com.google.common.base.MoreObjects;
37+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3738
import java.io.BufferedReader;
3839
import java.io.IOException;
3940
import java.io.InputStreamReader;
@@ -131,6 +132,7 @@ protected Builder(CloudShellCredentials credentials) {
131132
this.authPort = credentials.authPort;
132133
}
133134

135+
@CanIgnoreReturnValue
134136
public Builder setAuthPort(int authPort) {
135137
this.authPort = authPort;
136138
return this;

‎oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.google.common.base.Joiner;
4848
import com.google.common.base.MoreObjects;
4949
import com.google.common.collect.ImmutableSet;
50+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5051
import java.io.BufferedReader;
5152
import java.io.File;
5253
import java.io.IOException;
@@ -549,11 +550,13 @@ protected Builder(ComputeEngineCredentials credentials) {
549550
this.scopes = credentials.scopes;
550551
}
551552

553+
@CanIgnoreReturnValue
552554
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
553555
this.transportFactory = transportFactory;
554556
return this;
555557
}
556558

559+
@CanIgnoreReturnValue
557560
public Builder setScopes(Collection<String> scopes) {
558561
this.scopes = scopes;
559562
return this;

‎oauth2_http/java/com/google/auth/oauth2/CredentialAccessBoundary.java

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static com.google.common.base.Preconditions.checkNotNull;
3636

3737
import com.google.api.client.json.GenericJson;
38+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3839
import java.util.ArrayList;
3940
import java.util.List;
4041
import javax.annotation.Nullable;
@@ -124,11 +125,13 @@ private Builder() {}
124125
* @param rule the collection of rules to be set, should not be null
125126
* @return this {@code Builder} object
126127
*/
128+
@CanIgnoreReturnValue
127129
public Builder setRules(List<AccessBoundaryRule> rule) {
128130
accessBoundaryRules = new ArrayList<>(checkNotNull(rule));
129131
return this;
130132
}
131133

134+
@CanIgnoreReturnValue
132135
public CredentialAccessBoundary.Builder addRule(AccessBoundaryRule rule) {
133136
if (accessBoundaryRules == null) {
134137
accessBoundaryRules = new ArrayList<>();
@@ -218,6 +221,7 @@ private Builder() {}
218221
* @param availableResource the resource name to set
219222
* @return this {@code Builder} object
220223
*/
224+
@CanIgnoreReturnValue
221225
public Builder setAvailableResource(String availableResource) {
222226
this.availableResource = availableResource;
223227
return this;
@@ -232,6 +236,7 @@ public Builder setAvailableResource(String availableResource) {
232236
* @param availablePermissions the collection of permissions to set, should not be null
233237
* @return this {@code Builder} object
234238
*/
239+
@CanIgnoreReturnValue
235240
public Builder setAvailablePermissions(List<String> availablePermissions) {
236241
this.availablePermissions = new ArrayList<>(checkNotNull(availablePermissions));
237242
return this;
@@ -261,6 +266,7 @@ public Builder addAvailablePermission(String availablePermission) {
261266
* @param availabilityCondition the {@code AvailabilityCondition} to set
262267
* @return this {@code Builder} object
263268
*/
269+
@CanIgnoreReturnValue
264270
public Builder setAvailabilityCondition(AvailabilityCondition availabilityCondition) {
265271
this.availabilityCondition = availabilityCondition;
266272
return this;
@@ -337,6 +343,7 @@ private Builder() {}
337343
* @param expression the expression to set
338344
* @return this {@code Builder} object
339345
*/
346+
@CanIgnoreReturnValue
340347
public Builder setExpression(String expression) {
341348
this.expression = expression;
342349
return this;
@@ -348,6 +355,7 @@ public Builder setExpression(String expression) {
348355
* @param title the title to set
349356
* @return this {@code Builder} object
350357
*/
358+
@CanIgnoreReturnValue
351359
public Builder setTitle(String title) {
352360
this.title = title;
353361
return this;
@@ -359,6 +367,7 @@ public Builder setTitle(String title) {
359367
* @param description the description to set
360368
* @return this {@code Builder} object
361369
*/
370+
@CanIgnoreReturnValue
362371
public Builder setDescription(String description) {
363372
this.description = description;
364373
return this;

‎oauth2_http/java/com/google/auth/oauth2/DownscopedCredentials.java

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import com.google.auth.http.HttpTransportFactory;
3838
import com.google.common.annotations.VisibleForTesting;
39+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3940
import java.io.IOException;
4041

4142
/**
@@ -166,16 +167,19 @@ public static class Builder extends OAuth2Credentials.Builder {
166167

167168
private Builder() {}
168169

170+
@CanIgnoreReturnValue
169171
public Builder setSourceCredential(GoogleCredentials sourceCredential) {
170172
this.sourceCredential = sourceCredential;
171173
return this;
172174
}
173175

176+
@CanIgnoreReturnValue
174177
public Builder setCredentialAccessBoundary(CredentialAccessBoundary credentialAccessBoundary) {
175178
this.credentialAccessBoundary = credentialAccessBoundary;
176179
return this;
177180
}
178181

182+
@CanIgnoreReturnValue
179183
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
180184
this.transportFactory = transportFactory;
181185
return this;

‎oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java

+11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.google.auth.http.HttpTransportFactory;
4848
import com.google.common.base.MoreObjects;
4949
import com.google.common.io.BaseEncoding;
50+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5051
import java.io.IOException;
5152
import java.io.InputStream;
5253
import java.io.ObjectInputStream;
@@ -401,6 +402,7 @@ protected Builder(ExternalAccountAuthorizedUserCredentials credentials) {
401402
* @param transportFactory the {@code HttpTransportFactory} to set
402403
* @return this {@code Builder} object
403404
*/
405+
@CanIgnoreReturnValue
404406
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
405407
this.transportFactory = transportFactory;
406408
return this;
@@ -413,6 +415,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
413415
* @param audience the audience to set
414416
* @return this {@code Builder} object
415417
*/
418+
@CanIgnoreReturnValue
416419
public Builder setAudience(String audience) {
417420
this.audience = audience;
418421
return this;
@@ -424,6 +427,7 @@ public Builder setAudience(String audience) {
424427
* @param tokenUrl the token exchange url to set
425428
* @return this {@code Builder} object
426429
*/
430+
@CanIgnoreReturnValue
427431
public Builder setTokenUrl(String tokenUrl) {
428432
this.tokenUrl = tokenUrl;
429433
return this;
@@ -435,6 +439,7 @@ public Builder setTokenUrl(String tokenUrl) {
435439
* @param tokenInfoUrl the token info url to set
436440
* @return this {@code Builder} object
437441
*/
442+
@CanIgnoreReturnValue
438443
public Builder setTokenInfoUrl(String tokenInfoUrl) {
439444
this.tokenInfoUrl = tokenInfoUrl;
440445
return this;
@@ -446,6 +451,7 @@ public Builder setTokenInfoUrl(String tokenInfoUrl) {
446451
* @param revokeUrl the revoke url to set
447452
* @return this {@code Builder} object
448453
*/
454+
@CanIgnoreReturnValue
449455
public Builder setRevokeUrl(String revokeUrl) {
450456
this.revokeUrl = revokeUrl;
451457
return this;
@@ -457,6 +463,7 @@ public Builder setRevokeUrl(String revokeUrl) {
457463
* @param refreshToken the refresh token
458464
* @return this {@code Builder} object
459465
*/
466+
@CanIgnoreReturnValue
460467
public Builder setRefreshToken(String refreshToken) {
461468
this.refreshToken = refreshToken;
462469
return this;
@@ -468,6 +475,7 @@ public Builder setRefreshToken(String refreshToken) {
468475
* @param clientId the client ID
469476
* @return this {@code Builder} object
470477
*/
478+
@CanIgnoreReturnValue
471479
public Builder setClientId(String clientId) {
472480
this.clientId = clientId;
473481
return this;
@@ -479,6 +487,7 @@ public Builder setClientId(String clientId) {
479487
* @param clientSecret the client secret
480488
* @return this {@code Builder} object
481489
*/
490+
@CanIgnoreReturnValue
482491
public Builder setClientSecret(String clientSecret) {
483492
this.clientSecret = clientSecret;
484493
return this;
@@ -490,6 +499,7 @@ public Builder setClientSecret(String clientSecret) {
490499
* @param quotaProjectId the quota and billing project id to set
491500
* @return this {@code Builder} object
492501
*/
502+
@CanIgnoreReturnValue
493503
public Builder setQuotaProjectId(String quotaProjectId) {
494504
super.setQuotaProjectId(quotaProjectId);
495505
return this;
@@ -501,6 +511,7 @@ public Builder setQuotaProjectId(String quotaProjectId) {
501511
* @param accessToken the access token
502512
* @return this {@code Builder} object
503513
*/
514+
@CanIgnoreReturnValue
504515
public Builder setAccessToken(AccessToken accessToken) {
505516
super.setAccessToken(accessToken);
506517
return this;

‎oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

+17
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.google.auth.RequestMetadataCallback;
4040
import com.google.auth.http.HttpTransportFactory;
4141
import com.google.common.base.MoreObjects;
42+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4243
import java.io.IOException;
4344
import java.io.InputStream;
4445
import java.math.BigDecimal;
@@ -395,6 +396,7 @@ public static ExternalAccountCredentials fromStream(
395396
* @param transportFactory HTTP transport factory, creates the transport used to get access tokens
396397
* @return the credentials defined by the JSON
397398
*/
399+
@SuppressWarnings("unchecked")
398400
static ExternalAccountCredentials fromJson(
399401
Map<String, Object> json, HttpTransportFactory transportFactory) {
400402
checkNotNull(json);
@@ -762,6 +764,7 @@ protected Builder(ExternalAccountCredentials credentials) {
762764
* @param transportFactory the {@code HttpTransportFactory} to set
763765
* @return this {@code Builder} object
764766
*/
767+
@CanIgnoreReturnValue
765768
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
766769
this.transportFactory = transportFactory;
767770
return this;
@@ -774,6 +777,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
774777
* @param audience the Security Token Service audience to set
775778
* @return this {@code Builder} object
776779
*/
780+
@CanIgnoreReturnValue
777781
public Builder setAudience(String audience) {
778782
this.audience = audience;
779783
return this;
@@ -786,6 +790,7 @@ public Builder setAudience(String audience) {
786790
* @param subjectTokenType the Security Token Service subject token type to set
787791
* @return this {@code Builder} object
788792
*/
793+
@CanIgnoreReturnValue
789794
public Builder setSubjectTokenType(String subjectTokenType) {
790795
this.subjectTokenType = subjectTokenType;
791796
return this;
@@ -797,6 +802,7 @@ public Builder setSubjectTokenType(String subjectTokenType) {
797802
* @param tokenUrl the Security Token Service token exchange url to set
798803
* @return this {@code Builder} object
799804
*/
805+
@CanIgnoreReturnValue
800806
public Builder setTokenUrl(String tokenUrl) {
801807
this.tokenUrl = tokenUrl;
802808
return this;
@@ -808,6 +814,7 @@ public Builder setTokenUrl(String tokenUrl) {
808814
* @param credentialSource the {@code CredentialSource} to set
809815
* @return this {@code Builder} object
810816
*/
817+
@CanIgnoreReturnValue
811818
public Builder setCredentialSource(CredentialSource credentialSource) {
812819
this.credentialSource = credentialSource;
813820
return this;
@@ -821,6 +828,7 @@ public Builder setCredentialSource(CredentialSource credentialSource) {
821828
* @param serviceAccountImpersonationUrl the service account impersonation url to set
822829
* @return this {@code Builder} object
823830
*/
831+
@CanIgnoreReturnValue
824832
public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl) {
825833
this.serviceAccountImpersonationUrl = serviceAccountImpersonationUrl;
826834
return this;
@@ -833,6 +841,7 @@ public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonat
833841
* @param tokenInfoUrl the token info url to set
834842
* @return this {@code Builder} object
835843
*/
844+
@CanIgnoreReturnValue
836845
public Builder setTokenInfoUrl(String tokenInfoUrl) {
837846
this.tokenInfoUrl = tokenInfoUrl;
838847
return this;
@@ -844,6 +853,7 @@ public Builder setTokenInfoUrl(String tokenInfoUrl) {
844853
* @param quotaProjectId the quota and billing project id to set
845854
* @return this {@code Builder} object
846855
*/
856+
@CanIgnoreReturnValue
847857
public Builder setQuotaProjectId(String quotaProjectId) {
848858
super.setQuotaProjectId(quotaProjectId);
849859
return this;
@@ -855,6 +865,7 @@ public Builder setQuotaProjectId(String quotaProjectId) {
855865
* @param clientId the service account client id to set
856866
* @return this {@code Builder} object
857867
*/
868+
@CanIgnoreReturnValue
858869
public Builder setClientId(String clientId) {
859870
this.clientId = clientId;
860871
return this;
@@ -866,6 +877,7 @@ public Builder setClientId(String clientId) {
866877
* @param clientSecret the service account client secret to set
867878
* @return this {@code Builder} object
868879
*/
880+
@CanIgnoreReturnValue
869881
public Builder setClientSecret(String clientSecret) {
870882
this.clientSecret = clientSecret;
871883
return this;
@@ -877,6 +889,7 @@ public Builder setClientSecret(String clientSecret) {
877889
* @param scopes the request scopes to set
878890
* @return this {@code Builder} object
879891
*/
892+
@CanIgnoreReturnValue
880893
public Builder setScopes(Collection<String> scopes) {
881894
this.scopes = scopes;
882895
return this;
@@ -890,6 +903,7 @@ public Builder setScopes(Collection<String> scopes) {
890903
* @param workforcePoolUserProject the workforce pool user project number to set
891904
* @return this {@code Builder} object
892905
*/
906+
@CanIgnoreReturnValue
893907
public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) {
894908
this.workforcePoolUserProject = workforcePoolUserProject;
895909
return this;
@@ -901,6 +915,7 @@ public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) {
901915
* @param optionsMap the service account impersonation options to set
902916
* @return this {@code Builder} object
903917
*/
918+
@CanIgnoreReturnValue
904919
public Builder setServiceAccountImpersonationOptions(Map<String, Object> optionsMap) {
905920
this.serviceAccountImpersonationOptions = new ServiceAccountImpersonationOptions(optionsMap);
906921
return this;
@@ -912,6 +927,7 @@ public Builder setServiceAccountImpersonationOptions(Map<String, Object> options
912927
* @param universeDomain the universe domain to set
913928
* @return this {@code Builder} object
914929
*/
930+
@CanIgnoreReturnValue
915931
public Builder setUniverseDomain(String universeDomain) {
916932
this.universeDomain = universeDomain;
917933
return this;
@@ -923,6 +939,7 @@ public Builder setUniverseDomain(String universeDomain) {
923939
* @param environmentProvider the {@code EnvironmentProvider} to set
924940
* @return this {@code Builder} object
925941
*/
942+
@CanIgnoreReturnValue
926943
Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) {
927944
this.environmentProvider = environmentProvider;
928945
return this;

‎oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.google.common.annotations.VisibleForTesting;
4949
import com.google.common.base.MoreObjects;
5050
import com.google.common.base.Preconditions;
51+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5152
import java.io.File;
5253
import java.io.FileInputStream;
5354
import java.io.FileNotFoundException;
@@ -394,41 +395,49 @@ protected Builder(GdchCredentials credentials) {
394395
this.lifetime = credentials.lifetime;
395396
}
396397

398+
@CanIgnoreReturnValue
397399
public Builder setProjectId(String projectId) {
398400
this.projectId = projectId;
399401
return this;
400402
}
401403

404+
@CanIgnoreReturnValue
402405
public Builder setPrivateKeyId(String privateKeyId) {
403406
this.privateKeyId = privateKeyId;
404407
return this;
405408
}
406409

410+
@CanIgnoreReturnValue
407411
public Builder setPrivateKey(PrivateKey privateKey) {
408412
this.privateKey = privateKey;
409413
return this;
410414
}
411415

416+
@CanIgnoreReturnValue
412417
public Builder setServiceIdentityName(String name) {
413418
this.serviceIdentityName = name;
414419
return this;
415420
}
416421

422+
@CanIgnoreReturnValue
417423
public Builder setTokenServerUri(URI tokenServerUri) {
418424
this.tokenServerUri = tokenServerUri;
419425
return this;
420426
}
421427

428+
@CanIgnoreReturnValue
422429
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
423430
this.transportFactory = transportFactory;
424431
return this;
425432
}
426433

434+
@CanIgnoreReturnValue
427435
public Builder setCaCertPath(String caCertPath) {
428436
this.caCertPath = caCertPath;
429437
return this;
430438
}
431439

440+
@CanIgnoreReturnValue
432441
public Builder setGdchAudience(URI apiAudience) {
433442
this.apiAudience = apiAudience;
434443
return this;

‎oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.google.api.client.util.Preconditions;
3838
import com.google.auth.http.HttpTransportFactory;
3939
import com.google.common.collect.ImmutableList;
40+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4041
import java.io.IOException;
4142
import java.io.InputStream;
4243
import java.nio.charset.StandardCharsets;
@@ -359,6 +360,7 @@ public GoogleCredentials build() {
359360
return new GoogleCredentials(this);
360361
}
361362

363+
@CanIgnoreReturnValue
362364
public Builder setQuotaProjectId(String quotaProjectId) {
363365
this.quotaProjectId = quotaProjectId;
364366
return this;
@@ -369,6 +371,7 @@ public String getQuotaProjectId() {
369371
}
370372

371373
@Override
374+
@CanIgnoreReturnValue
372375
public Builder setAccessToken(AccessToken token) {
373376
super.setAccessToken(token);
374377
return this;

‎oauth2_http/java/com/google/auth/oauth2/IdTokenCredentials.java

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import com.google.api.client.util.Preconditions;
3535
import com.google.common.base.MoreObjects;
36+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3637
import java.io.IOException;
3738
import java.util.List;
3839
import java.util.Objects;
@@ -167,6 +168,7 @@ public static class Builder extends OAuth2Credentials.Builder {
167168

168169
protected Builder() {}
169170

171+
@CanIgnoreReturnValue
170172
public Builder setIdTokenProvider(IdTokenProvider idTokenProvider) {
171173
this.idTokenProvider = idTokenProvider;
172174
return this;
@@ -176,6 +178,7 @@ public IdTokenProvider getIdTokenProvider() {
176178
return this.idTokenProvider;
177179
}
178180

181+
@CanIgnoreReturnValue
179182
public Builder setTargetAudience(String targetAudience) {
180183
this.targetAudience = targetAudience;
181184
return this;
@@ -185,6 +188,7 @@ public String getTargetAudience() {
185188
return this.targetAudience;
186189
}
187190

191+
@CanIgnoreReturnValue
188192
public Builder setOptions(List<IdTokenProvider.Option> options) {
189193
this.options = options;
190194
return this;

‎oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentialSource.java

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class IdentityPoolCredentialSource extends ExternalAccountCredentials.Cre
6565
*
6666
* <p>Optional headers can be present, and should be keyed by `headers`.
6767
*/
68+
@SuppressWarnings("unchecked")
6869
public IdentityPoolCredentialSource(Map<String, Object> credentialSourceMap) {
6970
super(credentialSourceMap);
7071

‎oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.google.auth.oauth2.IdentityPoolCredentialSource.CredentialFormatType;
4141
import com.google.auth.oauth2.IdentityPoolCredentialSource.IdentityPoolCredentialSourceType;
4242
import com.google.common.io.CharStreams;
43+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4344
import java.io.BufferedReader;
4445
import java.io.File;
4546
import java.io.FileInputStream;
@@ -182,6 +183,7 @@ public static class Builder extends ExternalAccountCredentials.Builder {
182183
super(credentials);
183184
}
184185

186+
@CanIgnoreReturnValue
185187
public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) {
186188
super.setWorkforcePoolUserProject(workforcePoolUserProject);
187189
return this;

‎oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import com.google.common.annotations.VisibleForTesting;
5050
import com.google.common.base.MoreObjects;
5151
import com.google.common.collect.ImmutableMap;
52+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5253
import java.io.IOException;
5354
import java.io.ObjectInputStream;
5455
import java.text.DateFormat;
@@ -361,6 +362,7 @@ public byte[] sign(byte[] toSign) {
361362
* @return the credentials defined by the JSON
362363
* @throws IOException if the credential cannot be created from the JSON.
363364
*/
365+
@SuppressWarnings("unchecked")
364366
static ImpersonatedCredentials fromJson(
365367
Map<String, Object> json, HttpTransportFactory transportFactory) throws IOException {
366368

@@ -418,7 +420,7 @@ public boolean createScopedRequired() {
418420
@Override
419421
public GoogleCredentials createScoped(Collection<String> scopes) {
420422
return toBuilder()
421-
.setScopes(new ArrayList(scopes))
423+
.setScopes(new ArrayList<>(scopes))
422424
.setLifetime(this.lifetime)
423425
.setDelegates(this.delegates)
424426
.setHttpTransportFactory(this.transportFactory)
@@ -624,6 +626,7 @@ protected Builder(GoogleCredentials sourceCredentials, String targetPrincipal) {
624626
this.targetPrincipal = targetPrincipal;
625627
}
626628

629+
@CanIgnoreReturnValue
627630
public Builder setSourceCredentials(GoogleCredentials sourceCredentials) {
628631
this.sourceCredentials = sourceCredentials;
629632
return this;
@@ -633,6 +636,7 @@ public GoogleCredentials getSourceCredentials() {
633636
return this.sourceCredentials;
634637
}
635638

639+
@CanIgnoreReturnValue
636640
public Builder setTargetPrincipal(String targetPrincipal) {
637641
this.targetPrincipal = targetPrincipal;
638642
return this;
@@ -642,6 +646,7 @@ public String getTargetPrincipal() {
642646
return this.targetPrincipal;
643647
}
644648

649+
@CanIgnoreReturnValue
645650
public Builder setDelegates(List<String> delegates) {
646651
this.delegates = delegates;
647652
return this;
@@ -651,6 +656,7 @@ public List<String> getDelegates() {
651656
return this.delegates;
652657
}
653658

659+
@CanIgnoreReturnValue
654660
public Builder setScopes(List<String> scopes) {
655661
this.scopes = scopes;
656662
return this;
@@ -660,6 +666,7 @@ public List<String> getScopes() {
660666
return this.scopes;
661667
}
662668

669+
@CanIgnoreReturnValue
663670
public Builder setLifetime(int lifetime) {
664671
this.lifetime = lifetime == 0 ? DEFAULT_LIFETIME_IN_SECONDS : lifetime;
665672
return this;
@@ -669,6 +676,7 @@ public int getLifetime() {
669676
return this.lifetime;
670677
}
671678

679+
@CanIgnoreReturnValue
672680
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
673681
this.transportFactory = transportFactory;
674682
return this;
@@ -678,16 +686,19 @@ public HttpTransportFactory getHttpTransportFactory() {
678686
return transportFactory;
679687
}
680688

689+
@CanIgnoreReturnValue
681690
public Builder setQuotaProjectId(String quotaProjectId) {
682691
super.setQuotaProjectId(quotaProjectId);
683692
return this;
684693
}
685694

695+
@CanIgnoreReturnValue
686696
public Builder setIamEndpointOverride(String iamEndpointOverride) {
687697
this.iamEndpointOverride = iamEndpointOverride;
688698
return this;
689699
}
690700

701+
@CanIgnoreReturnValue
691702
public Builder setCalendar(Calendar calendar) {
692703
this.calendar = calendar;
693704
return this;

‎oauth2_http/java/com/google/auth/oauth2/JwtCredentials.java

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.google.auth.http.AuthHttpConstants;
3939
import com.google.common.annotations.VisibleForTesting;
4040
import com.google.common.base.Preconditions;
41+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4142
import java.io.IOException;
4243
import java.net.URI;
4344
import java.security.GeneralSecurityException;
@@ -210,6 +211,7 @@ public static class Builder {
210211

211212
protected Builder() {}
212213

214+
@CanIgnoreReturnValue
213215
public Builder setPrivateKey(PrivateKey privateKey) {
214216
this.privateKey = Preconditions.checkNotNull(privateKey);
215217
return this;
@@ -219,6 +221,7 @@ public PrivateKey getPrivateKey() {
219221
return privateKey;
220222
}
221223

224+
@CanIgnoreReturnValue
222225
public Builder setPrivateKeyId(String privateKeyId) {
223226
this.privateKeyId = privateKeyId;
224227
return this;
@@ -228,6 +231,7 @@ public String getPrivateKeyId() {
228231
return privateKeyId;
229232
}
230233

234+
@CanIgnoreReturnValue
231235
public Builder setJwtClaims(JwtClaims claims) {
232236
this.jwtClaims = Preconditions.checkNotNull(claims);
233237
return this;
@@ -237,6 +241,7 @@ public JwtClaims getJwtClaims() {
237241
return jwtClaims;
238242
}
239243

244+
@CanIgnoreReturnValue
240245
public Builder setLifeSpanSeconds(Long lifeSpanSeconds) {
241246
this.lifeSpanSeconds = Preconditions.checkNotNull(lifeSpanSeconds);
242247
return this;
@@ -246,6 +251,7 @@ public Long getLifeSpanSeconds() {
246251
return lifeSpanSeconds;
247252
}
248253

254+
@CanIgnoreReturnValue
249255
Builder setClock(Clock clock) {
250256
this.clock = Preconditions.checkNotNull(clock);
251257
return this;

‎oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.google.common.util.concurrent.ListenableFuture;
4848
import com.google.common.util.concurrent.ListenableFutureTask;
4949
import com.google.common.util.concurrent.MoreExecutors;
50+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5051
import java.io.IOException;
5152
import java.io.ObjectInputStream;
5253
import java.io.Serializable;
@@ -648,11 +649,13 @@ protected Builder(OAuth2Credentials credentials) {
648649
this.expirationMargin = credentials.expirationMargin;
649650
}
650651

652+
@CanIgnoreReturnValue
651653
public Builder setAccessToken(AccessToken token) {
652654
this.accessToken = token;
653655
return this;
654656
}
655657

658+
@CanIgnoreReturnValue
656659
public Builder setRefreshMargin(Duration refreshMargin) {
657660
this.refreshMargin = refreshMargin;
658661
return this;
@@ -662,6 +665,7 @@ public Duration getRefreshMargin() {
662665
return refreshMargin;
663666
}
664667

668+
@CanIgnoreReturnValue
665669
public Builder setExpirationMargin(Duration expirationMargin) {
666670
this.expirationMargin = expirationMargin;
667671
return this;

‎oauth2_http/java/com/google/auth/oauth2/OAuth2CredentialsWithRefresh.java

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import static com.google.common.base.Preconditions.checkNotNull;
3535

36+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3637
import java.io.IOException;
3738

3839
/**
@@ -99,12 +100,14 @@ private Builder() {}
99100
* {@link IllegalArgumentException} will be thrown.
100101
*/
101102
@Override
103+
@CanIgnoreReturnValue
102104
public Builder setAccessToken(AccessToken token) {
103105
super.setAccessToken(token);
104106
return this;
105107
}
106108

107109
/** Sets the {@link OAuth2RefreshHandler} to be used for token refreshes. */
110+
@CanIgnoreReturnValue
108111
public Builder setRefreshHandler(OAuth2RefreshHandler handler) {
109112
this.refreshHandler = handler;
110113
return this;

‎oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ static String validateOptionalString(Map<String, Object> map, String key, String
170170
}
171171

172172
/** Return the specified list of strings from JSON or throw a helpful error message. */
173+
@SuppressWarnings("unchecked")
173174
static List<String> validateOptionalListString(
174175
Map<String, Object> map, String key, String errorPrefix) throws IOException {
175176
Object value = map.get(key);

‎oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentialSource.java

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public class PluggableAuthCredentialSource extends ExternalAccountCredentials.Cr
8080
// location.
8181
@Nullable final String outputFilePath;
8282

83+
@SuppressWarnings("unchecked")
8384
public PluggableAuthCredentialSource(Map<String, Object> credentialSourceMap) {
8485
super(credentialSourceMap);
8586

‎oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentials.java

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import com.google.auth.oauth2.ExecutableHandler.ExecutableOptions;
3535
import com.google.common.annotations.VisibleForTesting;
36+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3637
import java.io.IOException;
3738
import java.util.ArrayList;
3839
import java.util.Collection;
@@ -219,6 +220,7 @@ public static class Builder extends ExternalAccountCredentials.Builder {
219220
this.handler = credentials.handler;
220221
}
221222

223+
@CanIgnoreReturnValue
222224
public Builder setExecutableHandler(ExecutableHandler handler) {
223225
this.handler = handler;
224226
return this;

‎oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java

+16
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import com.google.common.annotations.VisibleForTesting;
5757
import com.google.common.base.MoreObjects;
5858
import com.google.common.collect.ImmutableSet;
59+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5960
import java.io.IOException;
6061
import java.io.InputStream;
6162
import java.io.ObjectInputStream;
@@ -1005,78 +1006,93 @@ protected Builder(ServiceAccountCredentials credentials) {
10051006
this.defaultRetriesEnabled = credentials.defaultRetriesEnabled;
10061007
}
10071008

1009+
@CanIgnoreReturnValue
10081010
public Builder setClientId(String clientId) {
10091011
this.clientId = clientId;
10101012
return this;
10111013
}
10121014

1015+
@CanIgnoreReturnValue
10131016
public Builder setClientEmail(String clientEmail) {
10141017
this.clientEmail = clientEmail;
10151018
return this;
10161019
}
10171020

1021+
@CanIgnoreReturnValue
10181022
public Builder setPrivateKey(PrivateKey privateKey) {
10191023
this.privateKey = privateKey;
10201024
return this;
10211025
}
10221026

1027+
@CanIgnoreReturnValue
10231028
public Builder setPrivateKeyString(String privateKeyPkcs8) throws IOException {
10241029
this.privateKey = OAuth2Utils.privateKeyFromPkcs8(privateKeyPkcs8);
10251030
return this;
10261031
}
10271032

1033+
@CanIgnoreReturnValue
10281034
public Builder setPrivateKeyId(String privateKeyId) {
10291035
this.privateKeyId = privateKeyId;
10301036
return this;
10311037
}
10321038

1039+
@CanIgnoreReturnValue
10331040
public Builder setScopes(Collection<String> scopes) {
10341041
this.scopes = scopes;
10351042
this.defaultScopes = ImmutableSet.<String>of();
10361043
return this;
10371044
}
10381045

1046+
@CanIgnoreReturnValue
10391047
public Builder setScopes(Collection<String> scopes, Collection<String> defaultScopes) {
10401048
this.scopes = scopes;
10411049
this.defaultScopes = defaultScopes;
10421050
return this;
10431051
}
10441052

1053+
@CanIgnoreReturnValue
10451054
public Builder setServiceAccountUser(String serviceAccountUser) {
10461055
this.serviceAccountUser = serviceAccountUser;
10471056
return this;
10481057
}
10491058

1059+
@CanIgnoreReturnValue
10501060
public Builder setProjectId(String projectId) {
10511061
this.projectId = projectId;
10521062
return this;
10531063
}
10541064

1065+
@CanIgnoreReturnValue
10551066
public Builder setTokenServerUri(URI tokenServerUri) {
10561067
this.tokenServerUri = tokenServerUri;
10571068
return this;
10581069
}
10591070

1071+
@CanIgnoreReturnValue
10601072
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
10611073
this.transportFactory = transportFactory;
10621074
return this;
10631075
}
10641076

1077+
@CanIgnoreReturnValue
10651078
public Builder setQuotaProjectId(String quotaProjectId) {
10661079
super.setQuotaProjectId(quotaProjectId);
10671080
return this;
10681081
}
10691082

1083+
@CanIgnoreReturnValue
10701084
public Builder setLifetime(int lifetime) {
10711085
this.lifetime = lifetime == 0 ? DEFAULT_LIFETIME_IN_SECONDS : lifetime;
10721086
return this;
10731087
}
10741088

1089+
@CanIgnoreReturnValue
10751090
public Builder setUseJwtAccessWithScope(boolean useJwtAccessWithScope) {
10761091
this.useJwtAccessWithScope = useJwtAccessWithScope;
10771092
return this;
10781093
}
10791094

1095+
@CanIgnoreReturnValue
10801096
public Builder setDefaultRetriesEnabled(boolean defaultRetriesEnabled) {
10811097
this.defaultRetriesEnabled = defaultRetriesEnabled;
10821098
return this;

‎oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.google.common.cache.CacheLoader;
5151
import com.google.common.cache.LoadingCache;
5252
import com.google.common.util.concurrent.UncheckedExecutionException;
53+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5354
import java.io.IOException;
5455
import java.io.InputStream;
5556
import java.io.ObjectInputStream;
@@ -485,31 +486,37 @@ protected Builder(ServiceAccountJwtAccessCredentials credentials) {
485486
this.quotaProjectId = credentials.quotaProjectId;
486487
}
487488

489+
@CanIgnoreReturnValue
488490
public Builder setClientId(String clientId) {
489491
this.clientId = clientId;
490492
return this;
491493
}
492494

495+
@CanIgnoreReturnValue
493496
public Builder setClientEmail(String clientEmail) {
494497
this.clientEmail = clientEmail;
495498
return this;
496499
}
497500

501+
@CanIgnoreReturnValue
498502
public Builder setPrivateKey(PrivateKey privateKey) {
499503
this.privateKey = privateKey;
500504
return this;
501505
}
502506

507+
@CanIgnoreReturnValue
503508
public Builder setPrivateKeyId(String privateKeyId) {
504509
this.privateKeyId = privateKeyId;
505510
return this;
506511
}
507512

513+
@CanIgnoreReturnValue
508514
public Builder setDefaultAudience(URI defaultAudience) {
509515
this.defaultAudience = defaultAudience;
510516
return this;
511517
}
512518

519+
@CanIgnoreReturnValue
513520
public Builder setQuotaProjectId(String quotaProjectId) {
514521
this.quotaProjectId = quotaProjectId;
515522
return this;

‎oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.google.api.client.json.JsonParser;
4444
import com.google.api.client.util.GenericData;
4545
import com.google.common.base.Joiner;
46+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4647
import java.io.IOException;
4748
import java.util.ArrayList;
4849
import java.util.Arrays;
@@ -199,11 +200,13 @@ private Builder(
199200
this.httpRequestFactory = httpRequestFactory;
200201
}
201202

203+
@CanIgnoreReturnValue
202204
public StsRequestHandler.Builder setHeaders(HttpHeaders headers) {
203205
this.headers = headers;
204206
return this;
205207
}
206208

209+
@CanIgnoreReturnValue
207210
public StsRequestHandler.Builder setInternalOptions(String internalOptions) {
208211
this.internalOptions = internalOptions;
209212
return this;

‎oauth2_http/java/com/google/auth/oauth2/StsTokenExchangeRequest.java

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import static com.google.common.base.Preconditions.checkNotNull;
3535

36+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3637
import java.util.List;
3738
import javax.annotation.Nullable;
3839

@@ -154,31 +155,37 @@ private Builder(String subjectToken, String subjectTokenType) {
154155
this.subjectTokenType = subjectTokenType;
155156
}
156157

158+
@CanIgnoreReturnValue
157159
public StsTokenExchangeRequest.Builder setResource(String resource) {
158160
this.resource = resource;
159161
return this;
160162
}
161163

164+
@CanIgnoreReturnValue
162165
public StsTokenExchangeRequest.Builder setAudience(String audience) {
163166
this.audience = audience;
164167
return this;
165168
}
166169

170+
@CanIgnoreReturnValue
167171
public StsTokenExchangeRequest.Builder setRequestTokenType(String requestedTokenType) {
168172
this.requestedTokenType = requestedTokenType;
169173
return this;
170174
}
171175

176+
@CanIgnoreReturnValue
172177
public StsTokenExchangeRequest.Builder setScopes(List<String> scopes) {
173178
this.scopes = scopes;
174179
return this;
175180
}
176181

182+
@CanIgnoreReturnValue
177183
public StsTokenExchangeRequest.Builder setActingParty(ActingParty actingParty) {
178184
this.actingParty = actingParty;
179185
return this;
180186
}
181187

188+
@CanIgnoreReturnValue
182189
public StsTokenExchangeRequest.Builder setInternalOptions(String internalOptions) {
183190
this.internalOptions = internalOptions;
184191
return this;

‎oauth2_http/java/com/google/auth/oauth2/StsTokenExchangeResponse.java

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import static com.google.common.base.Preconditions.checkNotNull;
3535

36+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3637
import java.util.ArrayList;
3738
import java.util.Date;
3839
import java.util.List;
@@ -121,16 +122,19 @@ private Builder(String accessToken, String issuedTokenType, String tokenType) {
121122
this.tokenType = tokenType;
122123
}
123124

125+
@CanIgnoreReturnValue
124126
public StsTokenExchangeResponse.Builder setExpiresInSeconds(long expiresInSeconds) {
125127
this.expiresInSeconds = expiresInSeconds;
126128
return this;
127129
}
128130

131+
@CanIgnoreReturnValue
129132
public StsTokenExchangeResponse.Builder setRefreshToken(String refreshToken) {
130133
this.refreshToken = refreshToken;
131134
return this;
132135
}
133136

137+
@CanIgnoreReturnValue
134138
public StsTokenExchangeResponse.Builder setScopes(List<String> scopes) {
135139
if (scopes != null) {
136140
this.scopes = new ArrayList<>(scopes);

‎oauth2_http/java/com/google/auth/oauth2/UserAuthorizer.java

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.google.api.client.util.Preconditions;
4444
import com.google.auth.http.HttpTransportFactory;
4545
import com.google.common.collect.ImmutableList;
46+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4647
import java.io.IOException;
4748
import java.net.URI;
4849
import java.net.URL;
@@ -501,41 +502,49 @@ protected Builder(UserAuthorizer authorizer) {
501502
this.pkce = new DefaultPKCEProvider();
502503
}
503504

505+
@CanIgnoreReturnValue
504506
public Builder setClientId(ClientId clientId) {
505507
this.clientId = clientId;
506508
return this;
507509
}
508510

511+
@CanIgnoreReturnValue
509512
public Builder setTokenStore(TokenStore tokenStore) {
510513
this.tokenStore = tokenStore;
511514
return this;
512515
}
513516

517+
@CanIgnoreReturnValue
514518
public Builder setScopes(Collection<String> scopes) {
515519
this.scopes = scopes;
516520
return this;
517521
}
518522

523+
@CanIgnoreReturnValue
519524
public Builder setTokenServerUri(URI tokenServerUri) {
520525
this.tokenServerUri = tokenServerUri;
521526
return this;
522527
}
523528

529+
@CanIgnoreReturnValue
524530
public Builder setCallbackUri(URI callbackUri) {
525531
this.callbackUri = callbackUri;
526532
return this;
527533
}
528534

535+
@CanIgnoreReturnValue
529536
public Builder setUserAuthUri(URI userAuthUri) {
530537
this.userAuthUri = userAuthUri;
531538
return this;
532539
}
533540

541+
@CanIgnoreReturnValue
534542
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
535543
this.transportFactory = transportFactory;
536544
return this;
537545
}
538546

547+
@CanIgnoreReturnValue
539548
public Builder setPKCEProvider(PKCEProvider pkce) {
540549
if (pkce != null) {
541550
if (pkce.getCodeChallenge() == null

‎oauth2_http/java/com/google/auth/oauth2/UserCredentials.java

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.google.api.client.util.Preconditions;
4848
import com.google.auth.http.HttpTransportFactory;
4949
import com.google.common.base.MoreObjects;
50+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5051
import java.io.ByteArrayInputStream;
5152
import java.io.IOException;
5253
import java.io.InputStream;
@@ -388,46 +389,55 @@ protected Builder(UserCredentials credentials) {
388389
this.tokenServerUri = credentials.tokenServerUri;
389390
}
390391

392+
@CanIgnoreReturnValue
391393
public Builder setClientId(String clientId) {
392394
this.clientId = clientId;
393395
return this;
394396
}
395397

398+
@CanIgnoreReturnValue
396399
public Builder setClientSecret(String clientSecret) {
397400
this.clientSecret = clientSecret;
398401
return this;
399402
}
400403

404+
@CanIgnoreReturnValue
401405
public Builder setRefreshToken(String refreshToken) {
402406
this.refreshToken = refreshToken;
403407
return this;
404408
}
405409

410+
@CanIgnoreReturnValue
406411
public Builder setTokenServerUri(URI tokenServerUri) {
407412
this.tokenServerUri = tokenServerUri;
408413
return this;
409414
}
410415

416+
@CanIgnoreReturnValue
411417
public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
412418
this.transportFactory = transportFactory;
413419
return this;
414420
}
415421

422+
@CanIgnoreReturnValue
416423
public Builder setAccessToken(AccessToken token) {
417424
super.setAccessToken(token);
418425
return this;
419426
}
420427

428+
@CanIgnoreReturnValue
421429
public Builder setExpirationMargin(Duration expirationMargin) {
422430
super.setExpirationMargin(expirationMargin);
423431
return this;
424432
}
425433

434+
@CanIgnoreReturnValue
426435
public Builder setRefreshMargin(Duration refreshMargin) {
427436
super.setRefreshMargin(refreshMargin);
428437
return this;
429438
}
430439

440+
@CanIgnoreReturnValue
431441
public Builder setQuotaProjectId(String quotaProjectId) {
432442
super.setQuotaProjectId(quotaProjectId);
433443
return this;

‎oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public void refreshAccessToken_withServiceAccountImpersonationOptions() throws I
210210
}
211211

212212
@Test
213+
@SuppressWarnings("unchecked")
213214
public void retrieveSubjectToken() throws IOException {
214215
MockExternalAccountCredentialsTransportFactory transportFactory =
215216
new MockExternalAccountCredentialsTransportFactory();
@@ -254,6 +255,7 @@ public void retrieveSubjectToken() throws IOException {
254255
}
255256

256257
@Test
258+
@SuppressWarnings("unchecked")
257259
public void retrieveSubjectTokenWithSessionTokenUrl() throws IOException {
258260
MockExternalAccountCredentialsTransportFactory transportFactory =
259261
new MockExternalAccountCredentialsTransportFactory();

‎oauth2_http/javatests/com/google/auth/oauth2/ExternalAccountCredentialsTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ public void fromJson_pluggableAuthCredentialsWorkforce() {
346346
}
347347

348348
@Test
349+
@SuppressWarnings("unchecked")
349350
public void fromJson_pluggableAuthCredentials_allExecutableOptionsSet() {
350351
GenericJson json = buildJsonPluggableAuthCredential();
351352
Map<String, Object> credentialSourceMap = (Map<String, Object>) json.get("credential_source");
@@ -400,6 +401,7 @@ public void fromJson_pluggableAuthCredentialsWithServiceAccountImpersonationOpti
400401
}
401402

402403
@Test
404+
@SuppressWarnings("unchecked")
403405
public void fromJson_pluggableAuthCredentials_withUniverseDomain() {
404406
GenericJson json = buildJsonPluggableAuthCredential();
405407
json.set("universe_domain", "universeDomain");

‎oauth2_http/javatests/com/google/auth/oauth2/MockExternalAccountCredentialsTransport.java

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public void addScopeSequence(List<String>... scopes) {
112112
}
113113

114114
@Override
115+
@SuppressWarnings("unchecked")
115116
public LowLevelHttpRequest buildRequest(final String method, final String url) {
116117
MockLowLevelHttpRequest request =
117118
new MockLowLevelHttpRequest(url) {

‎oauth2_http/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@
230230
<groupId>com.google.guava</groupId>
231231
<artifactId>guava</artifactId>
232232
</dependency>
233+
<dependency>
234+
<groupId>com.google.errorprone</groupId>
235+
<artifactId>error_prone_annotations</artifactId>
236+
<scope>compile</scope>
237+
</dependency>
233238
<dependency>
234239
<groupId>junit</groupId>
235240
<artifactId>junit</artifactId>

‎pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<deploy.autorelease>false</deploy.autorelease>
7272
<project.autovalue.version>1.8.2</project.autovalue.version>
7373
<auto-value-annotation.version>1.10.4</auto-value-annotation.version>
74+
<project.error-prone.version>2.18.0</project.error-prone.version>
7475
</properties>
7576

7677
<dependencyManagement>
@@ -136,6 +137,12 @@
136137
<type>test-jar</type>
137138
<classifier>testlib</classifier>
138139
</dependency>
140+
<dependency>
141+
<groupId>com.google.errorprone</groupId>
142+
<artifactId>error_prone_annotations</artifactId>
143+
<version>${project.error-prone.version}</version>
144+
<scope>compile</scope>
145+
</dependency>
139146
</dependencies>
140147
</dependencyManagement>
141148

@@ -232,7 +239,6 @@
232239
<source>1.8</source>
233240
<target>1.8</target>
234241
<encoding>UTF-8</encoding>
235-
<compilerArgument>-Xlint:unchecked</compilerArgument>
236242
</configuration>
237243
</plugin>
238244
<plugin>

0 commit comments

Comments
 (0)
Please sign in to comment.