From 9a6ef82f27738ca2fff227740056c6ef56fee5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20H=C3=BCbner?= Date: Wed, 18 Mar 2026 15:10:24 +0100 Subject: [PATCH] RefreshableResponseProvider.shutdown without waiting for queued tasks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In many of our unit tests we involve instances of `RefreshableResponseProvider`. Problem is, we run into the issue of a large number of pending threads not being shutdown after test execution. This leads to OutOfMemoryExceptions during test runs, especially on MacOS systems. The root cause is the `RefreshableResponseProvider`'s executor service "here-auth-refresher" thread is never being shutdown really, because there is always a refresh task waiting in the queue, usually. This commit forces the `RefreshableResponseProvider`'s executor service to shutdown without waiting for the task queue to deplete. In local tests, this change nicely cleans up all refresher threads. Signed-off-by: Stefan Hübner --- .../com/here/account/util/RefreshableResponseProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/here-oauth-client/src/main/java/com/here/account/util/RefreshableResponseProvider.java b/here-oauth-client/src/main/java/com/here/account/util/RefreshableResponseProvider.java index 64ece291..b919e2d8 100644 --- a/here-oauth-client/src/main/java/com/here/account/util/RefreshableResponseProvider.java +++ b/here-oauth-client/src/main/java/com/here/account/util/RefreshableResponseProvider.java @@ -199,13 +199,13 @@ public interface ExpiringResponse { } /** - * Shutdown the background threads + * Shutdown the background threads without waiting for queued tasks */ public void shutdown() { if (started) { try { LOG.info("Shutting down refresh token thread"); - scheduledExecutorService.shutdown(); + scheduledExecutorService.shutdownNow(); } finally { started = false; }