ApplicationListenerMethodAdapter: gracefully handle beans which are actually NullBean

Currently, if you have an optional event listener (via a @Bean method returning `null`)
this causes the event multicaster to explode violently.  Now, we just safely skip it.
This commit is contained in:
Steven Schlansker
2019-10-11 13:55:50 -07:00
committed by Juergen Hoeller
parent d494621ee3
commit fc55e66d50
2 changed files with 41 additions and 0 deletions

View File

@@ -295,6 +295,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@Nullable
protected Object doInvoke(Object... args) {
Object bean = getTargetBean();
if (bean.equals(null)) {
return null;
}
ReflectionUtils.makeAccessible(this.method);
try {
return this.method.invoke(bean, args);