quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Managed executor thread has the AppClassLoader on HttpClient dependent task

Open antoniomacri opened this issue 8 months ago • 19 comments

Describe the bug

I'm passing the ManagedExecutor to the Java HttpClient in order for it to run its tasks. However, when I set a "small" CPU limit on the docker container (via docker run or k8s CPU limit) in dependent tasks the contextual classloader is the JVM jdk.internal.loader.ClassLoaders$AppClassLoader. As a consequence, I have ClassNotFoundExceptions.

Expected behavior

The classloader on threads running dependent tasks should be the RunnerClassLoader from Quarkus.

Actual behavior

The classloader on threads running dependent tasks is the JVM jdk.internal.loader.ClassLoaders$AppClassLoader.

How to Reproduce?

Clone https://github.com/antoniomacri/quarkus-reproducer-http-client-classloader.git

Then run

./build-image.sh && ./run-image.sh

On another shell run:

curl http://localhost:8080/test

The expected output should be:

io.quarkus.bootstrap.runner.RunnerClassLoader

but instead it is:

jdk.internal.loader.ClassLoaders$AppClassLoader

If I set --cpus=2.1 or greater, the classloader is correct.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.11.2

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

Running MacOS on M2 Pro with 12 cores

antoniomacri avatar Jun 19 '24 14:06 antoniomacri