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

QueuedThreadPool sets wrong Classloader for use in quarkus #6399

Closed
JiriOndrusek opened this issue Jun 11, 2021 · 5 comments
Closed

QueuedThreadPool sets wrong Classloader for use in quarkus #6399

JiriOndrusek opened this issue Jun 11, 2021 · 5 comments
Labels
Bug For general bugs on Jetty side

Comments

@JiriOndrusek
Copy link

Jetty version(s)
jetty-9.4.40.v20210413

Description
QueuedThreadPool sets classloader for new threads to getClass().getClassLoader() which sets classloader to QuarkusClassLoaderQuarkus Base Runtime ClassLoader for quarkus based project. This classloader can not load classes from the current project.
Correct classloader should be obtained by Thread.currentThread().getContextClassLoader(), which sets classloader to QuarkusClassLoader:Quarkus Runtime ClassLoader which works even for current projects.

This issues blocks apache/camel-quarkus#2651

How to reproduce?

git clone git@github.com:apache/camel-quarkus.git
cd camel-quarkus
git revert 406058c468609835f9f0ac91a5c0b76e4f52a392
mvnd clean install -Dquickly

cd integration-tests/avro-rpc
mvn clean test
@sbordet
Copy link
Contributor

sbordet commented Jun 11, 2021

@JiriOndrusek the reason QueuedThreadPool sets the class loader in that way is this issue: #5859.

We cannot know how applications use the threads in QueuedThreadPool so basically anything we do would be wrong.
The only thing that we can do is to "reset" everything, and applications should take care of doing what they need, e.g. set the TCCL, and unset it when done.

You can override QueuedThreadPool.runJob(Runnable) to set/unset the TCCL, or you can wrap your jobs to set/unset the TCCL.

I don't think there is much that we can do in general -- if we set the TCCL we break OSGi applications, if we don't we break someone else.

See also #6396.

@JiriOndrusek
Copy link
Author

@sbordet thanks for the explanation and some ways of solving this.. I wasn't sure whether this thing could be changed in jetty. I'll try to override it.

@sbordet
Copy link
Contributor

sbordet commented Jun 11, 2021

@JiriOndrusek please report back your solution, it would help others as well. Thanks!

@janbartel
Copy link
Contributor

@JiriOndrusek can this issue be closed now?

@JiriOndrusek
Copy link
Author

This issue could be closed.

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

3 participants