Skip to content

fix(auth): refine JSpecify nullability for ServiceAccountCredentials and UserCredentials - #14159

Merged
lqiu96 merged 1 commit into
mainfrom
fix_auth_service_account_and_user_credentials
Aug 21, 2026
Merged

fix(auth): refine JSpecify nullability for ServiceAccountCredentials and UserCredentials#14159
lqiu96 merged 1 commit into
mainfrom
fix_auth_service_account_and_user_credentials

Conversation

@lqiu96

@lqiu96 lqiu96 commented Aug 21, 2026

Copy link
Copy Markdown
Member

Description

Refines JSpecify nullability annotations and checks for ServiceAccountCredentials, UserCredentials, and their base hierarchy (GoogleCredentials, OAuth2Credentials, QuotaProjectIdProvider).

  • JSpecify Type-Use Nullability: Annotates return types, fields, and builder methods with standard type-use @Nullable annotations.
  • Guava Preconditions: Migrates from com.google.api.client.util.Preconditions to com.google.common.base.Preconditions.
  • Null-Check Cleanup: Removes redundant null checks on constructor-validated non-null fields in UserCredentials.

@lqiu96
lqiu96 requested review from a team as code owners August 21, 2026 00:52
@lqiu96
lqiu96 marked this pull request as draft August 21, 2026 00:52

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several credential classes, including GoogleCredentials, OAuth2Credentials, QuotaProjectIdProvider, ServiceAccountCredentials, and UserCredentials, to adopt JSpecify nullability annotations. It also updates the OAuth2Credentials constructor to handle null margins by falling back to default values, and removes redundant null checks in UserCredentials. Feedback suggests explicitly annotating the refreshMargin and expirationMargin parameters in the OAuth2Credentials constructor with @nullable to align with the new null-handling logic.

@lqiu96
lqiu96 force-pushed the fix_auth_service_account_and_user_credentials branch 2 times, most recently from 546cf59 to a10d03d Compare August 21, 2026 01:10
@lqiu96
lqiu96 force-pushed the fix_auth_service_account_and_user_credentials branch from a10d03d to ee0abbc Compare August 21, 2026 01:24
@lqiu96

lqiu96 commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves null safety across several credential classes, including GoogleCredentials, OAuth2Credentials, QuotaProjectIdProvider, ServiceAccountCredentials, and UserCredentials, by systematically adding and standardizing @nullable annotations on fields, method parameters, and return types. It also migrates Preconditions imports from com.google.api.client.util to com.google.common.base and simplifies JSON serialization in UserCredentials by removing redundant null checks. No review comments were provided, so there is no additional feedback to address.

@lqiu96
lqiu96 marked this pull request as ready for review August 21, 2026 20:09
@lqiu96
lqiu96 merged commit a929250 into main Aug 21, 2026
316 checks passed
@lqiu96
lqiu96 deleted the fix_auth_service_account_and_user_credentials branch August 21, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants