FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Possible race condition in credential refresh · Issue #692 · googleapis/google-auth-library-java · GitHub

This repository was archived by the owner on May 12, 2026. It is now read-only.
This repository was archived by the owner on May 12, 2026. It is now read-only.

Possible race condition in credential refresh #692

Description

We are seeing a possible race condition around credential refresh. We use the following code in an integration test suite to fetch OAuth2 tokens:

    GoogleCredentials credentials = ...;
    try {
      if (forceRefresh) {
        credentials.refresh();
      } else {
        credentials.getRequestMetadata();
      }

      AccessToken token = credentials.getAccessToken();
      return token.getTokenValue();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

We expect the credentials to contain a valid access token at the end of the if-else block. However, our tests intermittently fail by throwing a NullPointerException at token.getTokenValue(). Any thoughts on what might be going on here? What should we do to ensure that getAccessToken() always returns a non-null value?

Note: In the failing tests, forceRefresh has been set to false. So it should execute the credentials.getRequestMetadata() path.

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.status: investigatingThe issue is under investigation, which is determined to be non-trivial.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL