From 39087954719f4e807db65daf3a5c011b828dbebc Mon Sep 17 00:00:00 2001 From: ogesaku Date: Thu, 8 Feb 2024 07:46:18 +0100 Subject: [PATCH] Fix SlowBeanDetector --- .../quark/context/SlowBeanCreationDetector.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/coditory/quark/context/SlowBeanCreationDetector.java b/src/main/java/com/coditory/quark/context/SlowBeanCreationDetector.java index 3055d30..577ef44 100644 --- a/src/main/java/com/coditory/quark/context/SlowBeanCreationDetector.java +++ b/src/main/java/com/coditory/quark/context/SlowBeanCreationDetector.java @@ -36,7 +36,10 @@ public void handle(BeanPreCreateEvent event) { .add(event.bean()); parentDependencies.computeIfAbsent(event.bean(), (k) -> new HashSet<>()) .add(parent); - timers.get(parent).pause(); + Timer parentTimer = timers.get(parent); + if (parentTimer != null) { + parentTimer.pause(); + } } } @@ -45,8 +48,9 @@ public void handle(BeanPostCreateEvent event) { for (BeanDescriptor parent : parentDependencies.getOrDefault(event.bean(), Set.of())) { Set> children = dependencies.computeIfAbsent(parent, (k) -> new HashSet<>()); children.remove(event.bean()); - if (children.isEmpty()) { - timers.get(parent).resume(); + Timer parentTimer = timers.get(parent); + if (children.isEmpty() && parentTimer != null) { + parentTimer.resume(); } } dependencies.remove(event.bean());