-
Notifications
You must be signed in to change notification settings - Fork 37.8k
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
AbstractAutoProxyCreator#determineBeanType can trigger bean initialization at build time for aspects implementing Ordered #32230
Comments
Thanks for the report. I 100% agree that AOT should not create such a bean. I'd like to understand your setup a bit more though. Can you please share a small sample we can run ourselves that reproduces the issue? You can attach a zip here or push the code to a GitHub repository. |
I've attached a minimal demo. The stack for that differs slightly as I've simplified the code a bit. The very last |
Thanks for the sample.
That being said, an aspect is a lower-level infrastructure bean and injecting a DAO in there is not necessarily a good idea as these are initialized very early on. I've added We're going to see what we can do here, but I would apply that best practice on high-level dependencies like that irrespective of this issue. If you do so, you can also use |
While I understand your view on the type of beans and advices regarding that, this requires a detailed understanding of Spring which most people (including me) won't have. Additionally the example is obviously simplified and minified to reproduce the issue. In the actual code, the DAO is injected more indirectly making such things less obvious. But I'll try to remember that beans should be lazily injected into aspects. Anybody migrating existing codebases to native will hopefully find this issue, learn how to solve it and also learn more on the details of Spring. |
@codesimplicity the issue is not closed and we'll try to fix it. I am just stating a best practice that has nothing do with Native. |
This comment was marked as resolved.
This comment was marked as resolved.
Since the use of |
We ran into a problem that took us some time to debug and we hope that this could be improved:
DataSource
bean because the properties passed are emptyDataSource
beanDataSource
bean is reference by an AOP bean annotated with@Aspect
that implements theOrdered
interfaceAdvisor
(bean providing AOP advice) applicable to a bean, the code attempts to sort the advisors and if one of them implements theOrdered
interface, its needs to be instantiated in order to call theorder()
methodDataSource
cannot be createdOnce we knew all those details, the fix was trivial: instead of implementing the
Ordered
interface, we use the@Order
annotation.We did not see this mentioned anywhere in the documentation. It could go into the AOT best practices.
Do you see any option to detect this during AOT processing so the error can be handled with a more helpful message?
Last resort would be to just keep this issue around so people can find it.
For reference an example stack trace:
The text was updated successfully, but these errors were encountered: