@@ -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