-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
VirtualThreads cannot be used with JAX-RS interfaces #45186
Comments
/cc @FroMage (rest), @stuartwdouglas (rest) |
Thanks for reporting. I am pretty sure we've discussed this before. Do you remember @michalvavrik @cescoffier @Ladicek ? |
Yes, their was discussed. If I remember correctly, we said we did not want to support @RunOnVirtualThread on interfaces. |
Actually the report is slightly different. Not sure how it can be fixed... |
IMHO, the annotation doesn't belong on the interface (as it is an implementation detail). What I am asking for is that the annotation be allowed and honoured on the implementing bean. I am aware of the risks of setting virtual threads as the default (that's why I am asking for annoating the implementing bean). But right now, there seems to be no way at all. So setting a default (where it is known to be safe) would still be better than nothing... |
I guess, the proper "fix" would be to check implemented interfaces for JAX-RS annotations when collecting "entrypoint" methods. Not sure how complicated that could become, and maybe it's OK to prohibit multiple inheritance and such. But the plain case of "Bean implements Intfce" where the JAX-RS annotations are on the interface would be really helpful (and not an uncommon case for "API-first" development cases). |
I'll have a look |
Actually cc @Ladicek who did the implementation of |
Well, the |
I think, I found one (other?) part of the problem, while debugging through EndpointIndexer.isRunOnVirtualThread(). |
In my testing, when passing AUTOMATIC to the second (actualMethodInfo) invocation of |
I am wondering what the intended semantics of the "blockingDefault" is. My current understanding is (in the given order) of preference:
Or in short: "explicit annotation beats default" Is that understanding correct? The method Also, |
This is indeed the expected behavior. |
Will you be fixing this or do you want me to create a PR? |
I'm busy with other stuff ATM, so if you have a fix in mind, feel free to open a PR |
Describe the bug
We are implementing a JAX-RS endpoint, where the API is given by a Java interface (provided by another project). Our implementation consists of an ApplicationScoped bean implementing this interface. We would like to have the implementation execute on virtual threads, but Quarkus fails to recognize the annotation.
Expected behavior
We should be able to put @RunOnVirtualThread on the class or methods of our bean that implements the JAX-RS interface, to have them execute on a virtual thread.
Actual behavior
Putting @RunOnVirtualThread
There seems to be no valid way to get one of the methods to execute on a virtual thread.
This behaviour is present in Quarkus 3.17.4 but was already present in 3.8 (with quarkus-resteasy-reactive), so it seems to be general issue with the recognition of "entrypoints" in conjunction with Java interfaces.
How to Reproduce?
I have attached a small reproducer tha shows that @RunOnVirtualThread works correctly when put on a JAX-RS bean, but it is being ignored (or leads to an error message) when used in conjunction with interfaces.
Output of
uname -a
orver
Mac OS
Output of
java -version
Java 21
Quarkus version or git rev
3.17.4
Build tool (ie. output of
mvnw --version
orgradlew --version
)mvn 3.9.9
Additional information
virtual-rest-impl.zip
The text was updated successfully, but these errors were encountered: