-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Support Ordered interface for @ControllerAdvice beans #23163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After thorough investigation, I have determined that the In conjunction with gh-19993, the Javadoc was incorrectly updated to state that both I will therefore update the Javadoc to correct that: only I will also likely delete or deprecate the unused code paths in |
Is it possible to add support to order My use case is that I need to order my |
I understand your desire to be able to do that.
It is technically possible, and I have some ideas regarding how to achieve that, but I am missing a key piece of the puzzle (see below).
It appears to me that there is in fact a technical reason why it is not currently supported. Namely, each The missing piece of the puzzle for me is why that is the case. Specifically, I am not sure why Spring doesn't retrieve all such beans from the I'll discuss the background on this behavior with @rstoyanchev, and we will decide how to proceed. |
Related Issues and Commits
|
Thanks for the explanation! Seems like the original idea is not to initialize the |
You're welcome.
Yes, that's correct.
Yes, it appears that the intention was to follow the pattern used for looking up handler mappings for controllers which may potentially be defined as prototype beans. However, for a I have updated the title of this issue accordingly. |
Uh oh!
There was an error while loading. Please reload this page.
Affects: 5.1.8
The ControllerAdvice doc states that:
But when I try to order using the
Ordered
interface, it is not working, although the@Order
annotation is working.Example below:
When
@Order
is commented out, I get the response "Handling exception in TestAdvice". However when I uncomment@Order
, then I get the correct order response: "Handling exception in TestAdviceFirst"There is also a StackOverflow question but it is unanswered: https://stackoverflow.com/questions/51896436/ordered-interface-is-not-taken-into-account-for-controlleradvice-components
The text was updated successfully, but these errors were encountered: