From c458153c55df0207a428c27c0db3ad5802d59beb Mon Sep 17 00:00:00 2001 From: bstorozhuk Date: Thu, 7 Mar 2019 00:04:20 +0200 Subject: [PATCH] #351 - this change should fix bug that prevents JVM shutdown --- .../circuitbreaker/internal/AutoTransitioner.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/AutoTransitioner.java b/resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/AutoTransitioner.java index eb0ff9bd4b..bd68a2def1 100644 --- a/resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/AutoTransitioner.java +++ b/resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/AutoTransitioner.java @@ -13,8 +13,7 @@ */ public class AutoTransitioner { - private static final Lazy executorService = Lazy.of( - Executors::newSingleThreadScheduledExecutor); + private static final Lazy executorService = Lazy.of(AutoTransitioner::autoTransitionerSchedulerFactory); private AutoTransitioner() { } @@ -25,4 +24,12 @@ public static void scheduleAutoTransition(Runnable transition, Duration waitDura waitDurationInOpenState.toMillis(), TimeUnit.MILLISECONDS); } -} \ No newline at end of file + + private static ScheduledExecutorService autoTransitionerSchedulerFactory() { + return Executors.newSingleThreadScheduledExecutor(threadTask -> { + Thread thread = new Thread(threadTask, "AutomaticTransitionerFromOpenToHalfOpen"); + thread.setDaemon(true); + return thread; + }); + } +}