[java-shib-shared] 07/09: JSSH-71 Remove the impact of the DestructableComponent Interface

Codeberg noreply at shibboleth.net
Mon Jul 6 15:29:34 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch dev/JSSH-71-old
in repository java-shib-shared.

View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/381b83e154dbe1a8596e78e82503491145120c40

commit 381b83e154dbe1a8596e78e82503491145120c40
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon May 25 15:36:00 2026 +0100

    JSSH-71 Remove the impact of the DestructableComponent Interface
    
    https://shibboleth.atlassian.net/browse/JSSH-71
    
    Police CommonAnnotationBeanPostProcessor (and enforce) in our applicationContextBuilder.
---
 .../spring/util/ApplicationContextBuilder.java     | 30 ++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java
index fd203b7a..991bc69d 100644
--- a/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java
@@ -47,6 +47,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.ApplicationContextInitializer;
 import org.springframework.context.EnvironmentAware;
+import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
 import org.springframework.context.support.ConversionServiceFactoryBean;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@@ -275,6 +276,10 @@ public class ApplicationContextBuilder {
     @Nonnull public ApplicationContextBuilder setBeanPostProcessor(@Nonnull final BeanPostProcessor processor) {
         Constraint.isNotNull(processor, "BeanPostProcessor cannot be null");
         
+        if (!(processor instanceof CommonAnnotationBeanPostProcessor)) {
+            log.warn("{} : BeanPostPrcoessor of type {} not a CommonAnnotationBeanPostProcessor",
+                    contextName, processor.getClass());
+        }
         postProcessors = CollectionSupport.singletonList(processor);
         
         return this;
@@ -296,7 +301,20 @@ public class ApplicationContextBuilder {
         Constraint.isNotNull(processors, "BeanPostProcessor collection cannot be null");
 
         postProcessors = CollectionSupport.copyToList(processors);
-        
+
+        // Check that the Annotation processor is there
+        boolean foundProcessor = false;
+        for (BeanPostProcessor bean:processors) {
+            if (bean instanceof CommonAnnotationBeanPostProcessor) {
+                foundProcessor = true;
+                break;
+            }
+        }
+        if (!foundProcessor) {
+            log.warn("{} : Injected collection of bean processors should contain a CommonAnnotationBeanPostProcessor",
+                    contextName);
+        }
+
         return this;
     }
     
@@ -412,10 +430,12 @@ public class ApplicationContextBuilder {
             propertyConfigurer.setEnvironment(context.getEnvironment());
             context.getBeanFactoryPostProcessors().add(propertyConfigurer);
         }
-        
+
+        boolean foundSpringAnnotationBpp = false;
         if (postProcessors != null) {
             for (final BeanPostProcessor bpp : postProcessors) {
                 assert bpp != null;
+                foundSpringAnnotationBpp |= (bpp instanceof CommonAnnotationBeanPostProcessor);
                 context.getBeanFactory().addBeanPostProcessor(bpp);
                 if (bpp instanceof ApplicationContextAware aware) {
                     aware.setApplicationContext(context);
@@ -425,6 +445,12 @@ public class ApplicationContextBuilder {
                 }
             }
         }
+        if (!foundSpringAnnotationBpp)  {
+            final BeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
+            assert(!(bpp instanceof EnvironmentAware));
+            assert(!(bpp instanceof ApplicationContextAware));
+            context.getBeanFactory().addBeanPostProcessor(bpp);
+        }
         
         if (beanProfiles != null) {
             final String[] profiles = beanProfiles.toArray(new String[0]);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list