-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Non-Proxy Custom Scopes #6064
Comments
Looks like correct condition would be
which can be simplified to
Also, proxy target bean definition should be searched here only if it is scoped proxy (to make AOP work correctly for non scoped proxies). Patched locally for now, but looking forward to see this fixed upstream! It also would be cool to have some API in |
* Address issues with bean scopes * Improve exception handling for AbstractConcurrentScope. Fixes micronaut-projects#6343 * Fix custom scopes for beans not annotated with ScopedProxy. Fixes micronaut-projects#6064 * Don't scoped proxy instances. Fixes micronaut-projects#6342 * simplify * fix erroneous logic * elimnate duplicate line
Issue description
I suspect this is not a bug, but rather that I am just misunderstanding how Micronaut works.
Consider this example:
I expected that
SpeciaBeanScope.getOrCreate()
would be called forSpecialService
but it isn't. It looks like the scope is never looked up byDefaultBeanContext.getScopedBeanForDefinition()
because SpecialBean is not annotated with@ScopedProxy
.Here is the relevant code from
DefaultBeanContext.getScopedBeanForDefinition()
:This seems very intentional, but I am not sure why. Why do custom scopes have to be proxies? In my case, I cannot simply add
@ScopeProxy
because some of my beans arefinal
.The text was updated successfully, but these errors were encountered: