|
|
|
@ -151,34 +151,38 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM |
|
|
|
* @param event the current event to propagate |
|
|
|
* @param event the current event to propagate |
|
|
|
* @since 4.1 |
|
|
|
* @since 4.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings({"unchecked", "rawtypes"}) |
|
|
|
protected void invokeListener(ApplicationListener<?> listener, ApplicationEvent event) { |
|
|
|
protected void invokeListener(ApplicationListener listener, ApplicationEvent event) { |
|
|
|
|
|
|
|
ErrorHandler errorHandler = getErrorHandler(); |
|
|
|
ErrorHandler errorHandler = getErrorHandler(); |
|
|
|
if (errorHandler != null) { |
|
|
|
if (errorHandler != null) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
listener.onApplicationEvent(event); |
|
|
|
doInvokeListener(listener, event); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Throwable err) { |
|
|
|
catch (Throwable err) { |
|
|
|
errorHandler.handleError(err); |
|
|
|
errorHandler.handleError(err); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
try { |
|
|
|
doInvokeListener(listener, event); |
|
|
|
listener.onApplicationEvent(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ClassCastException ex) { |
|
|
|
|
|
|
|
String msg = ex.getMessage(); |
|
|
|
@SuppressWarnings({"unchecked", "rawtypes"}) |
|
|
|
if (msg == null || msg.startsWith(event.getClass().getName())) { |
|
|
|
private void doInvokeListener(ApplicationListener listener, ApplicationEvent event) { |
|
|
|
// Possibly a lambda-defined listener which we could not resolve the generic event type for
|
|
|
|
try { |
|
|
|
Log logger = LogFactory.getLog(getClass()); |
|
|
|
listener.onApplicationEvent(event); |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
} |
|
|
|
logger.debug("Non-matching event type for listener: " + listener, ex); |
|
|
|
catch (ClassCastException ex) { |
|
|
|
} |
|
|
|
String msg = ex.getMessage(); |
|
|
|
} |
|
|
|
if (msg == null || msg.startsWith(event.getClass().getName())) { |
|
|
|
else { |
|
|
|
// Possibly a lambda-defined listener which we could not resolve the generic event type for
|
|
|
|
throw ex; |
|
|
|
Log logger = LogFactory.getLog(getClass()); |
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
|
|
|
|
logger.debug("Non-matching event type for listener: " + listener, ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
throw ex; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|