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());