EventListenerMethodProcessor leniently handles unresolvable bean types
Issue: SPR-13712
This commit is contained in:
@@ -75,7 +75,16 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
String[] allBeanNames = this.applicationContext.getBeanNamesForType(Object.class);
|
||||
for (String beanName : allBeanNames) {
|
||||
if (!ScopedProxyUtils.isScopedTarget(beanName)) {
|
||||
Class<?> type = AutoProxyUtils.determineTargetClass(this.applicationContext.getBeanFactory(), beanName);
|
||||
Class<?> type = null;
|
||||
try {
|
||||
type = AutoProxyUtils.determineTargetClass(this.applicationContext.getBeanFactory(), beanName);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// An unresolvable bean type, probably from a lazy bean - let's ignore it.
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Could not resolve target class for bean with name '" + beanName + "'", ex);
|
||||
}
|
||||
}
|
||||
if (type != null) {
|
||||
if (ScopedObject.class.isAssignableFrom(type)) {
|
||||
try {
|
||||
@@ -107,8 +116,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
* {@link EventListener} annotated methods.
|
||||
*/
|
||||
protected List<EventListenerFactory> getEventListenerFactories() {
|
||||
Map<String, EventListenerFactory> beans =
|
||||
this.applicationContext.getBeansOfType(EventListenerFactory.class);
|
||||
Map<String, EventListenerFactory> beans = this.applicationContext.getBeansOfType(EventListenerFactory.class);
|
||||
List<EventListenerFactory> allFactories = new ArrayList<EventListenerFactory>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(allFactories);
|
||||
return allFactories;
|
||||
|
||||
Reference in New Issue
Block a user