Skip to content

Commit ddfa7d8

Browse files
committed
Update existing unit tests for compatibility and readability.
1 parent 47f6319 commit ddfa7d8

File tree

2 files changed

+154
-131
lines changed

2 files changed

+154
-131
lines changed

cab-token-generator/java/com/google/auth/credentialaccessboundary/ClientSideCredentialAccessBoundaryFactory.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ private void refreshCredentialsIfRequired() throws IOException {
152152
break;
153153
case ASYNC:
154154
if (refreshTask.isNew) {
155-
// Start a new background thread for the refresh task.
156-
// This allows the current thread to continue without blocking.
155+
// Starts a new background thread for the refresh task if it's a new task.
156+
// We create a new thread because the Auth Library doesn't currently include a background
157+
// executor. Introducing an executor would add complexity in managing its lifecycle and
158+
// could potentially lead to memory leaks.
159+
// We limit the number of concurrent refresh threads to 1, so the overhead of creating new
160+
// threads for asynchronous calls should be acceptable.
157161
new Thread(refreshTask.task).start();
158162
} // (No else needed - if not new, another thread is handling the refresh)
159163
break;
@@ -307,14 +311,23 @@ private void finishRefreshTask(ListenableFuture<IntermediateCredentials> finishe
307311
*
308312
* <p>These credentials include an intermediate access token and an access boundary session key.
309313
*/
310-
private static class IntermediateCredentials {
314+
@VisibleForTesting
315+
static class IntermediateCredentials {
311316
private final AccessToken intermediateAccessToken;
312317
private final String accessBoundarySessionKey;
313318

314319
IntermediateCredentials(AccessToken accessToken, String accessBoundarySessionKey) {
315320
this.intermediateAccessToken = accessToken;
316321
this.accessBoundarySessionKey = accessBoundarySessionKey;
317322
}
323+
324+
String getAccessBoundarySessionKey() {
325+
return accessBoundarySessionKey;
326+
}
327+
328+
AccessToken getIntermediateAccessToken() {
329+
return intermediateAccessToken;
330+
}
318331
}
319332

320333
/**

0 commit comments

Comments
 (0)