File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
spring-context/src/main/java/org/springframework/context/event Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,12 @@ private Collection<ApplicationListener<?>> retrieveApplicationListeners(
239
239
beanFactory .getBean (listenerBeanName , ApplicationListener .class );
240
240
if (!allListeners .contains (listener ) && supportsEvent (listener , eventType , sourceType )) {
241
241
if (retriever != null ) {
242
- retriever .applicationListenerBeans .add (listenerBeanName );
242
+ if (beanFactory .isSingleton (listenerBeanName )) {
243
+ retriever .applicationListeners .add (listener );
244
+ }
245
+ else {
246
+ retriever .applicationListenerBeans .add (listenerBeanName );
247
+ }
243
248
}
244
249
allListeners .add (listener );
245
250
}
@@ -252,6 +257,10 @@ private Collection<ApplicationListener<?>> retrieveApplicationListeners(
252
257
}
253
258
}
254
259
AnnotationAwareOrderComparator .sort (allListeners );
260
+ if (retriever != null && retriever .applicationListenerBeans .isEmpty ()) {
261
+ retriever .applicationListeners .clear ();
262
+ retriever .applicationListeners .addAll (allListeners );
263
+ }
255
264
return allListeners ;
256
265
}
257
266
@@ -385,7 +394,9 @@ public Collection<ApplicationListener<?>> getApplicationListeners() {
385
394
}
386
395
}
387
396
}
388
- AnnotationAwareOrderComparator .sort (allListeners );
397
+ if (!this .preFiltered || !this .applicationListenerBeans .isEmpty ()) {
398
+ AnnotationAwareOrderComparator .sort (allListeners );
399
+ }
389
400
return allListeners ;
390
401
}
391
402
}
You can’t perform that action at this time.
0 commit comments