Skip to content

Document @Order behavior on types, bean methods, and config classes #30177

@nightswimmings

Description

@nightswimmings

Using latest Spring-Boot 3.x, I experimented a bit with @order in the context of Spring-Security on multiple @SecurityFilterChains.

I created 2 @configuration SecurityConfigs, each one with 2 @bean SecurityFilterChain, and later on I debugged the

@Autowired(required = false)
void setFilterChains(List<SecurityFilterChain> securityFilterChains) {
   this.securityFilterChains = securityFilterChains;
}

to double-check the injection order.

    1. When annotating explictly (with random different @order values) all the bean-exposing methods, injection is eventually always ordered, regardless the instantiation order, as docs state, and regardless the @order annotations at class-level.
    1. When annotating only the classes, the annotations do not change the instantiation order of both @configuration classes or its bean-exposing methods, nor the order of injection of those beans.

So I am wondering, what is the point of @order at class level?

    1. Is it doing something or it is expected to not have any effect? Does it depend on the annotated kind of component? (Perhaps it's useless on @Configurations but not on @EventListeners, etc.. If so I think it would be nice to have it documented
    1. Am I perhaps facing a bug? If so I'll create the issue in this github or spring-security one if hat's the culprit
    1. A very important relevant nuance that should be documented in my opinion is whether the @order annotation is that kind of annotation that when put at class level behaves like an alias for annotating all its methods, or on the contrary, it has semantics on its own. If so, I think they should be documented for @configuration classes context at least

Thanks a lot!

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions