SimpleApplicationEventMulticaster just swallows event downcast exceptions

Issue: SPR-14846
(cherry picked from commit 13001b9)
This commit is contained in:
Juergen Hoeller
2016-10-28 15:25:22 +02:00
parent 01e9307fb7
commit fbad637235
2 changed files with 55 additions and 6 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;
}
}
}
}