-
Notifications
You must be signed in to change notification settings - Fork 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
Beans created by factories have their interceptor(s) from factory method rather than the bean classes #10836
Comments
Right now, method annotations are merged with the class annotations; that's why the interceptor is created. If you don't need it, don't include annotations that require an interceptor. |
But shouldn't at least the |
there is a debate to be had an maybe an annotation hint could be provided whether the annotation applies to the factory method or the class. Currently they apply to the class and changing this would be a breaking change that we cannot implement. If you want a new feature then sure create a feature request to allow disambiguation. |
I mean I do not have too much of a problem with the Annotation from the factory being applied to the class (altho yes it should be documented) But as far as I see it in the case of Calling a |
Expected Behavior
@NotNull
) the class should have a$Interceptor
generated when created in a@Factory
@NotNull
) even when instantiated by an@Factory
Actual Behaviour
Pretty much the opposite of the aformentioned expected behaviors. The annotations on the types of the beans do not influence interceptor generation at all, but only the annotations on the factory method!
So this in this example
noInterceptor
bean will always be intercepted regardless of its type (BeanThatDoesntNeedInterceptor
)withInterceptor
bean wil never be intercepted regardless of its type (BeanThatShouldHaveInterceptor
)the interceptor creation is controlled by the
@NotNull
on the factory method rather than by the type.Its questionable if
@NotNull
on a factory method makes sense in the first place but for now its very usefull to work around bug #10833!Steps To Reproduce
git clone https://github.com/nbrugger-tgm/micronaut-reproductions
cd micronaut-reproductions/micronaut-4-factory-regression-3
./gradlew test
Environment Information
Example Application
https://github.com/nbrugger-tgm/micronaut-reproductions
Version
4.4.2
The text was updated successfully, but these errors were encountered: