fix(auth): refine JSpecify nullability annotations for external account credentials - #14164
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves nullability safety across several credential classes (including AwsCredentials, ExternalAccountAuthorizedUserCredentials, ExternalAccountCredentials, IdentityPoolCredentials, and PluggableAuthCredentials) by adding @nullable annotations to fields, getters, and builder setters, as well as adding missing @OverRide annotations. Feedback on the changes suggests restoring the @nullable annotation on getExecutableHandler() in PluggableAuthCredentials.java because the handler can indeed be null.
|
|
||
| @VisibleForTesting | ||
| @Nullable ExecutableHandler getExecutableHandler() { | ||
| ExecutableHandler getExecutableHandler() { |
There was a problem hiding this comment.
Since handler is optional (for instance, when configured via an executable command in the JSON configuration rather than a custom programmatic handler), this.handler can be null. Therefore, getExecutableHandler() can return null and should retain its @Nullable annotation to correctly reflect its nullability contract. Additionally, please verify if any callers of getExecutableHandler() pass the returned value directly to APIs that do not accept nulls (such as Guava's ImmutableMap.Builder), and ensure proper null checks are in place.
| ExecutableHandler getExecutableHandler() { | |
| @Nullable ExecutableHandler getExecutableHandler() { |
References
- When annotating a method with
@Nullable, verify if any callers pass the returned value directly to APIs that do not accept nulls (such as Guava'sImmutableMap.Builder). If null checks are missing, they should be added or tracked for follow-up work.
8b30685 to
0c59b08
Compare
…nt credentials Refine JSpecify nullability annotations across ExternalAccountCredentials and subclasses: - Annotate optional fields, getters, and builder setters/fields with @nullable across ExternalAccountCredentials, IdentityPoolCredentials, AwsCredentials, PluggableAuthCredentials, and ExternalAccountAuthorizedUserCredentials. - Ensure correct JSpecify type-use annotation placements on fields, return types, and parameters. - Migrate Preconditions imports to com.google.common.base.Preconditions. - Ensure builder copy constructors properly preserve all fields.
91b799f to
ffa7391
Compare
Stacked on #14162.
Refines JSpecify nullability annotations across ExternalAccountCredentials and subclasses:
@Nullableacross:ExternalAccountCredentialsIdentityPoolCredentialsAwsCredentialsPluggableAuthCredentialsExternalAccountAuthorizedUserCredentialscom.google.common.base.Preconditionsovercom.google.api.client.util.Preconditions.