|
15 | 15 | * Actions environment. |
16 | 16 | */ |
17 | 17 | 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 */ |
19 | 19 | 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 */ |
21 | 21 | private final String actionsIDTokenRequestToken; |
22 | | - // HTTP client for making requests to GitHub Actions |
| 22 | + /* HTTP client for making requests to GitHub Actions */ |
23 | 23 | 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(); |
26 | 26 |
|
27 | 27 | /** |
28 | 28 | * Constructs a new GithubIDTokenSource. |
@@ -100,11 +100,11 @@ public IDToken getIDToken(String audience) { |
100 | 100 | throw new DatabricksException("ID token response missing 'value' field"); |
101 | 101 | } |
102 | 102 |
|
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) { |
105 | 107 | throw new DatabricksException("Received empty ID token from GitHub Actions"); |
106 | 108 | } |
107 | | - |
108 | | - return new IDToken(tokenValue); |
109 | 109 | } |
110 | 110 | } |
0 commit comments