Skip to content

Commit d85ff44

Browse files
committed
Only propagate events if the Reactor environment is alive. Fixes #9912
1 parent 1ae17ca commit d85ff44

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

grails-plugin-events/src/main/groovy/org/grails/events/spring/SpringEventTranslator.groovy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.springframework.context.ApplicationEvent
2525
import org.springframework.context.ApplicationListener
2626
import org.springframework.context.event.ContextClosedEvent
2727
import org.springframework.context.support.GenericApplicationContext
28+
import reactor.Environment
2829

2930
import java.util.concurrent.ConcurrentHashMap
3031

@@ -58,9 +59,12 @@ class SpringEventTranslator implements ApplicationListener, Events, ApplicationC
5859

5960
void onApplicationEvent(ApplicationEvent event) {
6061
def eventName = eventClassToName[event.getClass()]
61-
// don't relay context closed events because Reactor would have been shutdown
62-
if(!(event instanceof ContextClosedEvent)) {
63-
notify(eventName, eventFor(event))
62+
63+
if(Environment.alive()) {
64+
// don't relay context closed events because Reactor would have been shutdown
65+
if(!(event instanceof ContextClosedEvent)) {
66+
notify(eventName, eventFor(event))
67+
}
6468
}
6569
}
6670

0 commit comments

Comments
 (0)