Skip to content

fix(auth): Address ClientSideCredentialAccessBoundary RefreshTask race condition#12681

Merged
lqiu96 merged 4 commits intogoogleapis:mainfrom
vverman:fix-cab-race-condition
Apr 13, 2026
Merged

fix(auth): Address ClientSideCredentialAccessBoundary RefreshTask race condition#12681
lqiu96 merged 4 commits intogoogleapis:mainfrom
vverman:fix-cab-race-condition

Conversation

@vverman
Copy link
Copy Markdown
Contributor

@vverman vverman commented Apr 5, 2026

This change addresses a race condition in ClientSideCredentialAccessBoundaryFactory that occurred when multiple concurrent calls were made to generateToken.

The fix involves:

  • Waiting on the RefreshTask itself rather than its internal task.
  • Using a single listener in RefreshTask to ensure finishRefreshTask completes before the outer future unblocks waiting threads.
  • Adding a regression test generateToken_freshInstance_concurrent_noNpe.

This change addresses a race condition in ClientSideCredentialAccessBoundaryFactory that occurred when multiple concurrent calls were made to generateToken.

The fix involves:
- Waiting on the RefreshTask itself rather than its internal task.
- Using a single listener in RefreshTask to ensure finishRefreshTask completes before the outer future unblocks waiting threads.
- Adding a regression test generateToken_freshInstance_concurrent_noNpe.
@vverman vverman requested review from a team as code owners April 5, 2026 00:12
Copy link
Copy Markdown
Contributor

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

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 refactors the RefreshTask in ClientSideCredentialAccessBoundaryFactory to use a single listener, ensuring internal state updates occur before the future completes. It also simplifies the refresh logic and adds a concurrent test case to address a race condition. Feedback was provided to enhance the robustness of error handling in the task listener, specifically by catching Throwable and handling null causes in ExecutionException to avoid potential hangs.

@diegomarquezp diegomarquezp added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 7, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 7, 2026
@lqiu96 lqiu96 changed the title feat(auth): fix ClientSideCredentialAccessBoundary race condition fix(auth): Address ClientSideCredentialAccessBoundary RefreshTask race condition Apr 10, 2026
Copy link
Copy Markdown

@macastelaz macastelaz left a comment

Choose a reason for hiding this comment

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

LGTM!

@lsirac lsirac requested review from lsirac and removed request for lsirac April 10, 2026 17:12
@lqiu96 lqiu96 self-requested a review April 10, 2026 17:33
@vverman vverman requested a review from a team as a code owner April 10, 2026 18:45
@lqiu96
Copy link
Copy Markdown
Member

lqiu96 commented Apr 10, 2026

Thanks for the fix @vverman ! Changes LGTM

@lqiu96 lqiu96 merged commit 30088d2 into googleapis:main Apr 13, 2026
110 of 113 checks passed
diegomarquezp added a commit that referenced this pull request Apr 14, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>1.85.0</summary>

##
[1.85.0](v1.84.0...v1.85.0)
(2026-04-14)


### Features

* [appoptimize] new module for appoptimize
([#12768](#12768))
([050187d](050187d))
* [chronicle] Add DataTableService to Chronicle v1 Client Libraries
([fc62b1e](fc62b1e))
* [databasecenter] Add support for BigQuery datasets and
([fc62b1e](fc62b1e))
* [dataplex] Allow Data Documentation DataScans to support BigQuery
([fc62b1e](fc62b1e))
* [dataproc] Add `Engine` field to support LightningEngine in
([fc62b1e](fc62b1e))
* [discoveryengine] add AUTO condition to SearchAsYouTypeSpec in
([fc62b1e](fc62b1e))
* [infra-manager] adding DeploymentGroups, you can now manage
([fc62b1e](fc62b1e))
* [kms] add a variable to SingleTenantHsmInstanceCreate to control
([fc62b1e](fc62b1e))
* [kms] support external-μ in the Digest
([fc62b1e](fc62b1e))
* [shopping-merchant-products] a new field `base64_encoded_name` is
([fc62b1e](fc62b1e))
* [vectorsearch] Added CMEK support
([fc62b1e](fc62b1e))


### Bug Fixes

* **auth:** Address ClientSideCredentialAccessBoundary RefreshTask race
condition
([#12681](#12681))
([30088d2](30088d2))
* **bqjdbc:** lazily instantiate Statement in BigQueryDatabaseMetaData
([#12752](#12752))
([72e5508](72e5508))
* **deps:** update the Java code generator (gapic-generator-java) to
([fc62b1e](fc62b1e))
* **gdch:** support EC private keys
([#1896](#1896))
([bf926fb](bf926fb))
* update appoptimize version to 0.0.1 to match released repo
([#12782](#12782))
([80dfac6](80dfac6))


### Documentation

* [network-management] Update comment for the `region` field in
([fc62b1e](fc62b1e))
* [shopping-merchant-inventories] A comment for field `name` in
([fc62b1e](fc62b1e))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

5 participants