Skip to content

Commit 33efa34

Browse files
authored
Add Support for Asynchronous Token Refresh (#465)
## What changes are proposed in this pull request? This PR introduces a new environment variable `DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH` to enable asynchronous token refresh in the Databricks SDK for Java. This feature improves performance by allowing token refresh operations to happen in the background, reducing latency for API calls. This change activates the asynchronous refresh capability that was previously added in #455. When enabled, stale tokens will trigger a background refresh while expired tokens will still block until a new token is fetched. ### How to Enable Async Token Refresh Set the environment variable: ```bash export DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH=true ``` This setting will be automatically picked up by the SDK and applied to all token refresh operations. ## How is this tested? Manual verification that existing unit tests and integration tests pass with both async refresh disabled and enabled.
1 parent 580c015 commit 33efa34

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

NEXT_CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
## Release v0.54.0
44

55
### New Features and Improvements
6-
6+
* [Experimental] Add support for asynchronous token refresh ([#464](https://github.com/databricks/databricks-sdk-java/pull/465)).
7+
Enable this feature by setting the environment variable:
8+
```bash
9+
export DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH=true
10+
```
11+
Note: This feature and its configuration are experimental and may be removed in future releases.
712
### Bug Fixes
813

914
### Documentation

databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/RefreshableTokenSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ protected enum TokenState {
4545
// The current OAuth token. May be null if not yet fetched.
4646
protected volatile Token token;
4747
// Whether asynchronous refresh is enabled.
48-
private boolean asyncEnabled = false;
48+
private boolean asyncEnabled =
49+
Boolean.parseBoolean(System.getenv("DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH"));
4950
// Duration before expiry to consider a token as 'stale'.
5051
private Duration staleDuration = DEFAULT_STALE_DURATION;
5152
// Additional buffer before expiry to consider a token as expired.

0 commit comments

Comments
 (0)