Skip to content
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

Project Loom/JDK 21 compatible #5545

Open
patrickjamesbarry opened this issue Feb 23, 2024 · 8 comments
Open

Project Loom/JDK 21 compatible #5545

patrickjamesbarry opened this issue Feb 23, 2024 · 8 comments

Comments

@patrickjamesbarry
Copy link

We are preparing ourselves to upgrade to jdk 21, and was excited to see the addition of the JavaNetHttpConnectorProvider, because it would result in less dependencies to manage and automatically support virtual threads. However, after scanning the code in this repo, I see usages of synchronized methods which will result in pinned threads. Is there work under way to replace these locks with locking strategies that will not result in pinning the thread? If so, what version can I look forward to trying out that is more "project loom" friendly?

@jansupol
Copy link
Contributor

That's a good point, we planned to revisit synchronized blocks all over the code.

@patrickjamesbarry
Copy link
Author

Will the use of ThreadLocals migrate to using some of the new scoping functionality in 21? ie ScopedValue and StructuredTaskScope? Will this lead to just a change in behaviour for Jersey's own @requestScope?

@jansupol
Copy link
Contributor

jansupol commented Feb 24, 2024

ThreadLocals might or might not be an issue, depending on what the ThreadLocal holds. If the hold value is a subject just for a single virtual thread, it is not that an issue, afaik.

But yes, the ThreadLocal use should be revisited, too.

@jansupol
Copy link
Contributor

We have replaced the synchronized blocks for 3.1.6, along with minor ThreadLocal changes to clear the storage. However, right now we do not plan to drop the ThreadLocals as they work with virtual threads. We revisited the usage and it should not cause any harm with virtual threads. The Jersey @RequestScope behavior should not be affected. We do not plan to use ScopedValues (still maintaining support for JDK 11) unless there would be a reason. Do you have any actual bottleneck in mind?

That said, Jersey works quite well with Loom in Helidon 4 (JDK 21) already.

@wendigo
Copy link

wendigo commented Mar 21, 2024

@jansupol when is the 3.1.6 release happening? We (https://github.com/trinodb/trino) would love to try it out with virtual threads :)

@jansupol
Copy link
Contributor

@wendigo The next week, likely.

@wendigo
Copy link

wendigo commented Mar 21, 2024

Great! Thanks @jansupol

@celtric
Copy link

celtric commented Apr 19, 2024

What would be the appropriate way to enable virtual threads when using jersey-container-jetty-http or jersey-container-jetty-http2?

We're currently using JettyHttpContainerFactory, but the thread pool is apparently hardcoded https://github.com/eclipse-ee4j/jersey/blob/3.1/containers/jetty-http/src/main/java17/org/glassfish/jersey/jetty/JettyHttpContainerFactory.java#L257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants