Skip to content

Commit 4f4465a

Browse files
committed
Changed to guava future.
1 parent f3f335e commit 4f4465a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

oauth2_http/java/com/google/auth/oauth2/RegionalAccessBoundaryManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import com.google.api.core.InternalApi;
3636
import com.google.auth.http.HttpTransportFactory;
3737
import com.google.common.annotations.VisibleForTesting;
38-
import java.util.concurrent.CompletableFuture;
38+
import com.google.common.util.concurrent.SettableFuture;
3939
import java.util.concurrent.atomic.AtomicReference;
4040
import java.util.logging.Level;
4141
import 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

Comments
 (0)