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
Register Resource methods for reflection if ResourceInfo#getMethod is used in filters #28378
Conversation
Note that this should not be backported (unless we really really need it) because this depends on #28371 |
This comment has been minimized.
This comment has been minimized.
MacOS job failure is unrelated |
The changes in this pull request are really really remarkable and illustrative. Maybe I miss some code coverage, even being for Native only. Apart from that, I want to deeply review this pull request to understand all the tools and components (planning to do that this afternoon or tomorrow morning). If you are in a hurry, feel free to merge it, and I will review it later. |
No hurry at all. Indeed this change is needed only for native compatibility. That said, we could have made things A LOT simpler by just registering everything for reflection, but this being Quarkus, we really try to make things are performant as possible :). The general idea (if it's not evident) is that at build time, we check the bytecode of the method that will actually be called to implement the filter and if we find the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already had a chance to review these changes.
Awesome job!!
If I would have to comment something:
- I would refactor the class FilterClassIntrospector to (1) move the logic that reads the method source and deals with the visitMethodInsn semantics into a general purpose class, so we can use it in the future to inspect other sources in the future, and (2) have a UsesGetResourceMethodInstropector (since just reading the class name, you can know what is about).
- Even being for native, I would add tests to cover this functionality as it involves several components and can be easily broken in the future.
Thanks!
To be honest, I don't think it's that general to be applicable to other places.
I agree, however here is the problem: We would need a separate application for each of these cases in order to thoroughly test the functionality and as you know native tests don't come cheap, so I think we need to compromise. |
I just realized I had not committed the test I had added! PR updated |
This comment has been minimized.
This comment has been minimized.
… used in filters ResourceInfo#getMethod is used in order to retrieve the Resource method that is handles the HTTP request, and it obviously uses reflection. Resource methods are not by default registered for reflection, but this change introduces a way for Quarkus to read the bytecode of all filter methods and checks whether any of them uses the ResourceInfo#getMethod API and if so, forces the registration for reflection of all Resource methods. Fixes: quarkusio#28182
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
ResourceInfo#getMethod
is used in order to retrieve the Resource method that is handles the HTTP request, and it obviously uses reflection. Resource methods are not by default registered for reflection, but this change introduces a way for Quarkus to read the bytecode of all filter methods and checks whether any of them uses theResourceInfo#getMethod
API and if so, forces the registration for reflection of all Resource methods.Fixes: #28182