Skip to content

Commit a758cc8

Browse files
committed
Nit fixes.
1 parent cae1afa commit a758cc8

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
import com.google.common.annotations.VisibleForTesting;
3838
import com.google.common.util.concurrent.SettableFuture;
3939
import java.util.concurrent.ExecutorService;
40+
import java.util.concurrent.LinkedBlockingQueue;
41+
import java.util.concurrent.ThreadPoolExecutor;
42+
import java.util.concurrent.TimeUnit;
4043
import java.util.concurrent.atomic.AtomicInteger;
4144
import java.util.concurrent.atomic.AtomicReference;
4245
import java.util.logging.Level;
@@ -88,18 +91,20 @@ final class RegionalAccessBoundaryManager {
8891
private static final ExecutorService EXECUTOR;
8992

9093
static {
91-
java.util.concurrent.ThreadPoolExecutor executor =
92-
new java.util.concurrent.ThreadPoolExecutor(
94+
ThreadPoolExecutor executor =
95+
new ThreadPoolExecutor(
9396
5, // corePoolSize: threads to keep alive
9497
5, // maximumPoolSize: max threads allowed
9598
1, // keepAliveTime: time to wait before terminating idle threads
96-
java.util.concurrent.TimeUnit.HOURS, // unit for keepAliveTime
97-
new java.util.concurrent.LinkedBlockingQueue<>(), // work queue
99+
TimeUnit.HOURS, // unit for keepAliveTime
100+
new LinkedBlockingQueue<>(), // work queue
98101
r -> {
99102
Thread t = new Thread(r, "RAB-refresh-" + threadCount.getAndIncrement());
100103
t.setDaemon(true);
101104
return t;
102105
});
106+
// Allow core threads to time out so the executor can shrink to 0 when idle.
107+
// Ensures threads are released when idle to avoid unnecessary resource usage.
103108
executor.allowCoreThreadTimeOut(true);
104109
EXECUTOR = executor;
105110
}

0 commit comments

Comments
 (0)