Coder Social home page Coder Social logo

Comments (6)

antoniomacri avatar antoniomacri commented on August 18, 2024

Setting -XX:ActiveProcessorCount=N, instead of running in a docker container with cpu limit, produces the same results.

from quarkus.

geoand avatar geoand commented on August 18, 2024

Thanks for reporting.

I believe this is not a Quarkus issue

from quarkus.

antoniomacri avatar antoniomacri commented on August 18, 2024

Hi @geoand. Could you expand on that?

from quarkus.

geoand avatar geoand commented on August 18, 2024

We don't do anything specific for either the HTTP client or respond specifically to container limits.

I would suggest trying to reproduce something similar (essentially the executor not being taken into account) with plain Java

from quarkus.

antoniomacri avatar antoniomacri commented on August 18, 2024

I may be wrong, but the executor seems OK to me. From this code:

    @PostConstruct
    void createHttpClient() {
        this.httpClient = HttpClient.newBuilder()
                .executor(managedExecutor)
                .version(HttpClient.Version.HTTP_2)
                .build();

        managedExecutor.supplyAsync(() -> "").thenApplyAsync(response -> {
            Log.infof("PostConstruct thread=%s", Thread.currentThread().hashCode());
            Log.infof("PostConstruct classLoaderAfter=%s", Thread.currentThread().getContextClassLoader());
            return Thread.currentThread().getContextClassLoader().getClass().getName();
        }, managedExecutor);
    }


    @GET
    @Produces({MediaType.TEXT_PLAIN})
    public CompletableFuture<String> test() {
        URI uri = URI.create("http://www.columbia.edu/~fdc/sample.html");
        HttpRequest request = HttpRequest.newBuilder().GET().uri(uri).build();

        Log.infof("classLoaderBefore=%s", Thread.currentThread().getContextClassLoader());
        return httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenApplyAsync(response -> {
            Log.infof("thread=%s", Thread.currentThread().hashCode());
            Log.infof("classLoaderAfter=%s", Thread.currentThread().getContextClassLoader());
            return Thread.currentThread().getContextClassLoader().getClass().getName();
        }, managedExecutor);
    }

I get this log:

2024-06-23 08:46:15,765 INFO  [ClassloadingResource] (executor-thread-1) PostConstruct thread=10217343
2024-06-23 08:46:15,765 INFO  [ClassloadingResource] (executor-thread-1) PostConstruct classLoaderAfter=io.quarkus.bootstrap.runner.RunnerClassLoader@1
2024-06-23 08:46:15,766 INFO  [ClassloadingResource] (vert.x-eventloop-thread-1) classLoaderBefore=io.quarkus.bootstrap.runner.RunnerClassLoader@1
2024-06-23 08:46:16,093 INFO  [ClassloadingResource] (executor-thread-2) thread=1224931749
2024-06-23 08:46:16,094 INFO  [ClassloadingResource] (executor-thread-2) classLoaderAfter=jdk.internal.loader.ClassLoaders$AppClassLoader@3d71d552

The thread appears to be from the managed executor.

The problem seems related to the classloader not being set/propagated on thread context.

Correct?

from quarkus.

dmlloyd avatar dmlloyd commented on August 18, 2024

This does seem like a real bug to me. Our thread pools should always be propagating the correct class loader, so it's odd that it's being erased somehow.

from quarkus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.