Skip to content

Commit 71a8d3d

Browse files
committed
Minor fix
1 parent 6b16d2b commit 71a8d3d

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
public class DefaultCredentialsProvider implements CredentialsProvider {
1616
private static final Logger LOG = LoggerFactory.getLogger(DefaultCredentialsProvider.class);
1717

18-
// List of credential providers that will be tried in sequence
19-
private List<CredentialsProvider> providers = new ArrayList<>();
18+
/* List of credential providers that will be tried in sequence */
19+
private List<CredentialsProvider> providers;
2020

21-
// The currently selected authentication type
21+
/* The currently selected authentication type */
2222
private String authType = "default";
2323

2424
/**
@@ -143,6 +143,7 @@ private void addOIDCCredentialsProviders(DatabricksConfig config) {
143143
* @param config The Databricks configuration to use for provider initialization
144144
*/
145145
private void addDefaultCredentialsProviders(DatabricksConfig config) {
146+
providers = new ArrayList<>();
146147
providers.add(new PatCredentialsProvider());
147148
providers.add(new BasicCredentialsProvider());
148149
providers.add(new OAuthM2MServicePrincipalCredentialsProvider());

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* Actions environment.
1616
*/
1717
public class GithubIDTokenSource implements IDTokenSource {
18-
// URL endpoint for requesting ID tokens from GitHub Actions
18+
/* URL endpoint for requesting ID tokens from GitHub Actions */
1919
private final String actionsIDTokenRequestURL;
20-
// Authentication token required to request ID tokens from GitHub Actions
20+
/* Authentication token required to request ID tokens from GitHub Actions */
2121
private final String actionsIDTokenRequestToken;
22-
// HTTP client for making requests to GitHub Actions
22+
/* HTTP client for making requests to GitHub Actions */
2323
private final HttpClient httpClient;
24-
// JSON mapper for parsing response data
25-
private final ObjectMapper mapper = new ObjectMapper();
24+
/* JSON mapper for parsing response data */
25+
private static final ObjectMapper mapper = new ObjectMapper();
2626

2727
/**
2828
* Constructs a new GithubIDTokenSource.
@@ -100,11 +100,11 @@ public IDToken getIDToken(String audience) {
100100
throw new DatabricksException("ID token response missing 'value' field");
101101
}
102102

103-
String tokenValue = jsonResp.get("value").textValue();
104-
if (Strings.isNullOrEmpty(tokenValue)) {
103+
try {
104+
String tokenValue = jsonResp.get("value").textValue();
105+
return new IDToken(tokenValue);
106+
} catch (IllegalArgumentException e) {
105107
throw new DatabricksException("Received empty ID token from GitHub Actions");
106108
}
107-
108-
return new IDToken(tokenValue);
109109
}
110110
}

0 commit comments

Comments
 (0)