Skip to content

Commit e08cfb7

Browse files
committed
fmt
1 parent a229e8c commit e08cfb7

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

databricks-sdk-java/src/main/java/com/databricks/sdk/core/DatabricksConfig.java

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public TokenSource getTokenSource() {
242242
return (TokenSource) headerFactory;
243243
}
244244
return new ErrorTokenSource(
245-
String.format("OAuth Token not supported for current auth type %s", authType));
245+
String.format("OAuth Token not supported for current auth type %s", authType));
246246
}
247247

248248
public CredentialsProvider getCredentialsProvider() {
@@ -434,13 +434,17 @@ public DatabricksConfig setAzureUseMsi(boolean azureUseMsi) {
434434
return this;
435435
}
436436

437-
/** @deprecated Use {@link #getAzureUseMsi()} instead. */
437+
/**
438+
* @deprecated Use {@link #getAzureUseMsi()} instead.
439+
*/
438440
@Deprecated()
439441
public boolean getAzureUseMSI() {
440442
return azureUseMsi;
441443
}
442444

443-
/** @deprecated Use {@link #getAzureUseMsi()} instead. */
445+
/**
446+
* @deprecated Use {@link #getAzureUseMsi()} instead.
447+
*/
444448
@Deprecated
445449
public DatabricksConfig setAzureUseMSI(boolean azureUseMsi) {
446450
this.azureUseMsi = azureUseMsi;
@@ -657,10 +661,10 @@ public OpenIDConnectEndpoints getOidcEndpoints() throws IOException {
657661
}
658662
} catch (Exception e) {
659663
LOG.warn(
660-
"Failed to fetch OIDC Endpoints using discovery URL: {}. Error: {}. \nDefaulting to fetch OIDC using default endpoint.",
661-
discoveryUrl,
662-
e.getMessage(),
663-
e);
664+
"Failed to fetch OIDC Endpoints using discovery URL: {}. Error: {}. \nDefaulting to fetch OIDC using default endpoint.",
665+
discoveryUrl,
666+
e.getMessage(),
667+
e);
664668
}
665669
return fetchDefaultOidcEndpoints();
666670
}
@@ -691,22 +695,22 @@ private OpenIDConnectEndpoints fetchDefaultOidcEndpoints() throws IOException {
691695
return null;
692696
}
693697
return new OpenIDConnectEndpoints(
694-
realAuthUrl.replaceAll("/authorize", "/token"), realAuthUrl);
698+
realAuthUrl.replaceAll("/authorize", "/token"), realAuthUrl);
695699
}
696700
if (isAccountClient() && getAccountId() != null) {
697701
String prefix = getHost() + "/oidc/accounts/" + getAccountId();
698702
return new OpenIDConnectEndpoints(prefix + "/v1/token", prefix + "/v1/authorize");
699703
}
700704

701705
ApiClient apiClient =
702-
new ApiClient.Builder()
703-
.withHttpClient(getHttpClient())
704-
.withGetHostFunc(v -> getHost())
705-
.build();
706+
new ApiClient.Builder()
707+
.withHttpClient(getHttpClient())
708+
.withGetHostFunc(v -> getHost())
709+
.build();
706710
try {
707711
return apiClient.execute(
708-
new Request("GET", "/oidc/.well-known/oauth-authorization-server"),
709-
OpenIDConnectEndpoints.class);
712+
new Request("GET", "/oidc/.well-known/oauth-authorization-server"),
713+
OpenIDConnectEndpoints.class);
710714
} catch (IOException e) {
711715
throw new DatabricksException("IO error: " + e.getMessage(), e);
712716
}
@@ -773,18 +777,18 @@ public DatabricksConfig clone() {
773777

774778
public DatabricksConfig newWithWorkspaceHost(String host) {
775779
Set<String> fieldsToSkip =
776-
new HashSet<>(
777-
Arrays.asList(
778-
// The config for WorkspaceClient has a different host and Azure Workspace resource
779-
// ID, and also omits
780-
// the account ID.
781-
"host",
782-
"accountId",
783-
"azureWorkspaceResourceId",
784-
// For cloud-native OAuth, we need to reauthenticate as the audience has changed, so
785-
// don't cache the
786-
// header factory.
787-
"headerFactory"));
780+
new HashSet<>(
781+
Arrays.asList(
782+
// The config for WorkspaceClient has a different host and Azure Workspace resource
783+
// ID, and also omits
784+
// the account ID.
785+
"host",
786+
"accountId",
787+
"azureWorkspaceResourceId",
788+
// For cloud-native OAuth, we need to reauthenticate as the audience has changed, so
789+
// don't cache the
790+
// header factory.
791+
"headerFactory"));
788792
return clone(fieldsToSkip).setHost(host);
789793
}
790794

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

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ private OAuthClient(Builder b) throws IOException {
119119
this.hc = b.hc;
120120

121121
DatabricksConfig config =
122-
new DatabricksConfig()
123-
.setHost(b.host)
124-
.setAccountId(b.accountId)
125-
.resolve();
122+
new DatabricksConfig().setHost(b.host).setAccountId(b.accountId).resolve();
126123
openIDConnectEndpoints = b.openIDConnectEndpoints;
127124
if (openIDConnectEndpoints == null) {
128125
throw new DatabricksException(b.host + " does not support OAuth");
@@ -193,9 +190,9 @@ private static byte[] sha256(byte[] input) {
193190

194191
private static String urlEncode(String urlBase, Map<String, String> params) {
195192
String queryParams =
196-
params.entrySet().stream()
197-
.map(entry -> entry.getKey() + "=" + entry.getValue())
198-
.collect(Collectors.joining("&"));
193+
params.entrySet().stream()
194+
.map(entry -> entry.getKey() + "=" + entry.getValue())
195+
.collect(Collectors.joining("&"));
199196
return urlBase + "?" + queryParams.replaceAll(" ", "%20");
200197
}
201198

@@ -217,15 +214,15 @@ public Consent initiateConsent() throws MalformedURLException {
217214
String url = urlEncode(authUrl, params);
218215

219216
return new Consent.Builder()
220-
.withClientId(clientId)
221-
.withClientSecret(clientSecret)
222-
.withAuthUrl(url)
223-
.withTokenUrl(tokenUrl)
224-
.withRedirectUrl(redirectUrl)
225-
.withState(state)
226-
.withVerifier(verifier)
227-
.withHttpClient(hc)
228-
.withBrowserTimeout(browserTimeout)
229-
.build();
217+
.withClientId(clientId)
218+
.withClientSecret(clientSecret)
219+
.withAuthUrl(url)
220+
.withTokenUrl(tokenUrl)
221+
.withRedirectUrl(redirectUrl)
222+
.withState(state)
223+
.withVerifier(verifier)
224+
.withHttpClient(hc)
225+
.withBrowserTimeout(browserTimeout)
226+
.build();
230227
}
231228
}

0 commit comments

Comments
 (0)