Use `getBeanOrNull` in `registerDelegateApplicationListener` to simplify implementation.

This change does not alter behavior.
This commit is contained in:
Craig Andrews 2020-05-18 13:17:43 -04:00 committed by Rob Winch
parent dbdeec4216
commit f1db7167cb
1 changed files with 2 additions and 7 deletions

View File

@ -692,15 +692,10 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
private void registerDelegateApplicationListener(H http,
ApplicationListener<?> delegate) {
ApplicationContext context = http.getSharedObject(ApplicationContext.class);
if (context == null) {
DelegatingApplicationListener delegating = getBeanOrNull(DelegatingApplicationListener.class);
if (delegating == null) {
return;
}
if (context.getBeansOfType(DelegatingApplicationListener.class).isEmpty()) {
return;
}
DelegatingApplicationListener delegating = context
.getBean(DelegatingApplicationListener.class);
SmartApplicationListener smartListener = new GenericApplicationListenerAdapter(
delegate);
delegating.addListener(smartListener);