spring-projects / spring-projects/spring-framework

Setting order programmatically on OncePerRequestFilter or HandlerExceptionResolver beans using BeanRegistrar or GenericApplicationContext does not work

Open
#36,637 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

If you annotate your OncePerRequestFilter or HandlerExceptionResolver beans with @Order annotation that is registered programmatically using BeanRegistrar or GenericApplicationContext, it works correctly. Order value provided in @Order annotation influences order of filter or resolver.

However if you instead provide order value in registerBean's order parameter in case of BeanRegistrar or if you set AbstractBeanDefinition.ORDER_ATTRIBUTE in case of GenericApplicationContext , this value has no influence on filter or resolver order.

SpringBoot 4.0.3
JDK 25
Kotlin 2.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with OncePerRequestFilter and HandlerExceptionResolver beans registered through BeanRegistrar and GenericApplicationContext, comparing @Order with the registerBean order parameter and AbstractBeanDefinition.ORDER_ATTRIBUTE. Trace how the registered order is read when filters and resolvers are assembled; done means both programmatic order mechanisms affect the resulting order consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.