Skip to content

Publishing PrePostTemplateDefaults creates circular dependency #14674

Closed
@jzheaux

Description

@jzheaux

When publishing PrePostTemplateDefaults like so:

@Bean 
PrePostTemplateDefaults templateDefaults() {
    return new PrePostTemplateDefaults();
}

the advisor counterparts to the method security method interceptors fail to be published due to a circular dependency:

2024-03-01T14:52:39.412-07:00 TRACE 3681326 --- [    Test worker] .a.f.a.BeanFactoryAdvisorRetrievalHelper : Skipping advisor 'preAuthorizeAuthorizationAdvisor' with dependency on currently created bean: Error creating bean with name 'preAuthorizeAuthorizationAdvisor' defined in class path resource [org/springframework/security/config/annotation/method/configuration/PrePostMethodSecurityConfiguration.class]: Failed to instantiate [org.aopalliance.intercept.MethodInterceptor]: Factory method 'preAuthorizeAuthorizationMethodInterceptor' threw exception with message: Error creating bean with name 'templateDefaults': Requested bean is currently in creation: Is there an unresolvable circular reference?

Here is a sample that demonstrates the circular dependency: https://github.com/jzheaux/spring-security-samples/tree/gh-14674

Metadata

Metadata

Assignees

Labels

in: configAn issue in spring-security-configtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions