Skip to content

Commit bc66554

Browse files
committed
Use set instead of with for cached token source builder
1 parent a6b8df2 commit bc66554

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public Builder(TokenSource tokenSource) {
9898
* @param token The initial token to cache.
9999
* @return This builder instance for method chaining.
100100
*/
101-
public Builder withToken(Token token) {
101+
public Builder setToken(Token token) {
102102
this.token = token;
103103
return this;
104104
}
@@ -113,7 +113,7 @@ public Builder withToken(Token token) {
113113
* @param asyncEnabled True to enable asynchronous refresh, false to disable.
114114
* @return This builder instance for method chaining.
115115
*/
116-
public Builder withAsyncEnabled(boolean asyncEnabled) {
116+
public Builder setAsyncEnabled(boolean asyncEnabled) {
117117
this.asyncEnabled = asyncEnabled;
118118
return this;
119119
}
@@ -128,7 +128,7 @@ public Builder withAsyncEnabled(boolean asyncEnabled) {
128128
* than the expiry buffer duration.
129129
* @return This builder instance for method chaining.
130130
*/
131-
public Builder withStaleDuration(Duration staleDuration) {
131+
public Builder setStaleDuration(Duration staleDuration) {
132132
this.staleDuration = staleDuration;
133133
return this;
134134
}
@@ -143,7 +143,7 @@ public Builder withStaleDuration(Duration staleDuration) {
143143
* less than the stale duration.
144144
* @return This builder instance for method chaining.
145145
*/
146-
public Builder withExpiryBuffer(Duration expiryBuffer) {
146+
public Builder setExpiryBuffer(Duration expiryBuffer) {
147147
this.expiryBuffer = expiryBuffer;
148148
return this;
149149
}
@@ -157,7 +157,7 @@ public Builder withExpiryBuffer(Duration expiryBuffer) {
157157
* @param clockSupplier The clock supplier to use for determining current time.
158158
* @return This builder instance for method chaining.
159159
*/
160-
public Builder withClockSupplier(ClockSupplier clockSupplier) {
160+
public Builder setClockSupplier(ClockSupplier clockSupplier) {
161161
this.clockSupplier = clockSupplier;
162162
return this;
163163
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@ CachedTokenSource performBrowserAuth(
128128
Optional.ofNullable(config.getEffectiveOAuthRedirectUrl()),
129129
Optional.ofNullable(tokenCache));
130130

131-
return new CachedTokenSource.Builder(tokenSource).withToken(token).build();
131+
return new CachedTokenSource.Builder(tokenSource).setToken(token).build();
132132
}
133133
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public String authType() {
4141
@Override
4242
public OAuthHeaderFactory configure(DatabricksConfig config) {
4343
CachedTokenSource cachedTokenSource =
44-
new CachedTokenSource.Builder(tokenSource).withToken(tokenSource.getToken()).build();
44+
new CachedTokenSource.Builder(tokenSource).setToken(tokenSource.getToken()).build();
4545
return OAuthHeaderFactory.fromTokenSource(cachedTokenSource);
4646
}
4747

databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/CachedTokenSourceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public Token getToken() {
6767

6868
CachedTokenSource source =
6969
new CachedTokenSource.Builder(tokenSource)
70-
.withAsyncEnabled(asyncEnabled)
71-
.withToken(initialToken)
70+
.setAsyncEnabled(asyncEnabled)
71+
.setToken(initialToken)
7272
.build();
7373

7474
Token token = source.getToken();
@@ -127,9 +127,9 @@ public Token getToken() {
127127
TestSource testSource = new TestSource();
128128
CachedTokenSource source =
129129
new CachedTokenSource.Builder(testSource)
130-
.withAsyncEnabled(true)
131-
.withToken(staleToken)
132-
.withClockSupplier(clockSupplier)
130+
.setAsyncEnabled(true)
131+
.setToken(staleToken)
132+
.setClockSupplier(clockSupplier)
133133
.build();
134134

135135
// First call triggers async refresh, which fails

databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/ExternalBrowserCredentialsProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ void cacheWithInvalidAccessTokenRefreshFailingTest() throws IOException {
435435
Optional.empty());
436436

437437
CachedTokenSource cachedTokenSource =
438-
new CachedTokenSource.Builder(browserAuthTokenSource).withToken(browserAuthToken).build();
438+
new CachedTokenSource.Builder(browserAuthTokenSource).setToken(browserAuthToken).build();
439439

440440
// Create config with failing HTTP client and mock token cache
441441
DatabricksConfig config =
@@ -512,7 +512,7 @@ void cacheWithInvalidTokensTest() throws IOException {
512512
Optional.empty());
513513

514514
CachedTokenSource cachedTokenSource =
515-
new CachedTokenSource.Builder(browserAuthTokenSource).withToken(browserAuthToken).build();
515+
new CachedTokenSource.Builder(browserAuthTokenSource).setToken(browserAuthToken).build();
516516

517517
// Create simple config
518518
DatabricksConfig config =

0 commit comments

Comments
 (0)