From f1db7167cbff8cab5baa7a2c2d5a38d746c9f676 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 18 May 2020 13:17:43 -0400 Subject: [PATCH] Polish Use `getBeanOrNull` in `registerDelegateApplicationListener` to simplify implementation. This change does not alter behavior. --- .../web/configurers/SessionManagementConfigurer.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java index baf041e44a..5d6d2c22f0 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java @@ -692,15 +692,10 @@ public final class SessionManagementConfigurer> 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);