Skip to content

Commit

Permalink
Merge pull request ReactiveX#353 from resilience4j/autotransitioner_d…
Browse files Browse the repository at this point in the history
…aemon

ReactiveX#351 - this change should fix bug that prevents JVM shutdown
  • Loading branch information
storozhukBM authored Mar 6, 2019
2 parents 347c302 + c458153 commit 2a53946
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
public class AutoTransitioner {

private static final Lazy<ScheduledExecutorService> executorService = Lazy.of(
Executors::newSingleThreadScheduledExecutor);
private static final Lazy<ScheduledExecutorService> executorService = Lazy.of(AutoTransitioner::autoTransitionerSchedulerFactory);

private AutoTransitioner() {
}
Expand All @@ -25,4 +24,12 @@ public static void scheduleAutoTransition(Runnable transition, Duration waitDura
waitDurationInOpenState.toMillis(),
TimeUnit.MILLISECONDS);
}
}

private static ScheduledExecutorService autoTransitionerSchedulerFactory() {
return Executors.newSingleThreadScheduledExecutor(threadTask -> {
Thread thread = new Thread(threadTask, "AutomaticTransitionerFromOpenToHalfOpen");
thread.setDaemon(true);
return thread;
});
}
}

0 comments on commit 2a53946

Please sign in to comment.