Skip to content

Commit 8e14a5d

Browse files
committed
Prevent NPE in AbstractApplicationEventMulticaster's non-caching code path
Issue: SPR-12545 (cherry picked from commit 1cefeb2)
1 parent 230aa07 commit 8e14a5d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ private Collection<ApplicationListener<?>> retrieveApplicationListeners(
200200
}
201201
for (ApplicationListener<?> listener : listeners) {
202202
if (supportsEvent(listener, event.getClass(), sourceType)) {
203-
retriever.applicationListeners.add(listener);
203+
if (retriever != null) {
204+
retriever.applicationListeners.add(listener);
205+
}
204206
allListeners.add(listener);
205207
}
206208
}
@@ -213,7 +215,9 @@ private Collection<ApplicationListener<?>> retrieveApplicationListeners(
213215
ApplicationListener<?> listener =
214216
beanFactory.getBean(listenerBeanName, ApplicationListener.class);
215217
if (!allListeners.contains(listener) && supportsEvent(listener, event.getClass(), sourceType)) {
216-
retriever.applicationListenerBeans.add(listenerBeanName);
218+
if (retriever != null) {
219+
retriever.applicationListenerBeans.add(listenerBeanName);
220+
}
217221
allListeners.add(listener);
218222
}
219223
}

0 commit comments

Comments
 (0)