3535import com .google .api .core .InternalApi ;
3636import com .google .auth .http .HttpTransportFactory ;
3737import com .google .common .annotations .VisibleForTesting ;
38- import java . util .concurrent .CompletableFuture ;
38+ import com . google . common . util .concurrent .SettableFuture ;
3939import java .util .concurrent .atomic .AtomicReference ;
4040import java .util .logging .Level ;
4141import javax .annotation .Nullable ;
@@ -72,7 +72,7 @@ final class RegionalAccessBoundaryManager {
7272 * indicates a background refresh is already in progress. It also provides a handle for
7373 * observability and unit testing to track the background task's lifecycle.
7474 */
75- private final AtomicReference <CompletableFuture <RegionalAccessBoundary >> refreshFuture =
75+ private final AtomicReference <SettableFuture <RegionalAccessBoundary >> refreshFuture =
7676 new AtomicReference <>();
7777
7878 private final AtomicReference <CooldownState > cooldownState =
@@ -137,7 +137,7 @@ void triggerAsyncRefresh(
137137 return ;
138138 }
139139
140- CompletableFuture <RegionalAccessBoundary > future = new CompletableFuture <> ();
140+ SettableFuture <RegionalAccessBoundary > future = SettableFuture . create ();
141141 // Atomically check if a refresh is already running. If compareAndSet returns true,
142142 // this thread "won the race" and is responsible for starting the background task.
143143 // All other concurrent threads will return false and exit immediately.
@@ -152,10 +152,10 @@ void triggerAsyncRefresh(
152152 cachedRAB .set (newRAB );
153153 resetCooldown ();
154154 // Complete the future so monitors (like unit tests) know we are done.
155- future .complete (newRAB );
155+ future .set (newRAB );
156156 } catch (Exception e ) {
157157 handleRefreshFailure (e );
158- future .completeExceptionally (e );
158+ future .setException (e );
159159 } finally {
160160 // Open the gate again for future refresh requests.
161161 refreshFuture .set (null );
@@ -179,7 +179,7 @@ void triggerAsyncRefresh(
179179 // If scheduling fails (e.g., RejectedExecutionException, OutOfMemoryError for threads),
180180 // the task's finally block will never execute. We must release the lock here.
181181 refreshFuture .set (null );
182- future .completeExceptionally (e );
182+ future .setException (e );
183183 handleRefreshFailure (
184184 new Exception ("Regional Access Boundary background refresh failed to schedule" , e ));
185185 }
0 commit comments