SimpleApplicationEventMulticaster just swallows event downcast exceptions

Issue: SPR-14846
This commit is contained in:
Juergen Hoeller
2016-10-28 15:25:22 +02:00
parent 2874066a97
commit 13001b9aff
2 changed files with 51 additions and 2 deletions

View File

@@ -166,8 +166,13 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
listener.onApplicationEvent(event);
}
catch (ClassCastException ex) {
// Possibly a lambda-defined listener which we could not resolve the generic event type for
LogFactory.getLog(getClass()).debug("Non-matching event type for listener: " + listener, ex);
if (ex.getMessage().startsWith(event.getClass().getName())) {
// Possibly a lambda-defined listener which we could not resolve the generic event type for
LogFactory.getLog(getClass()).debug("Non-matching event type for listener: " + listener, ex);
}
else {
throw ex;
}
}
}
}