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

NonInjectionManager produce out of memory error #5805

Closed
skafenko opened this issue Nov 19, 2024 · 1 comment · Fixed by #5813
Closed

NonInjectionManager produce out of memory error #5805

skafenko opened this issue Nov 19, 2024 · 1 comment · Fixed by #5813

Comments

@skafenko
Copy link

Jersey client version = 2.45

Case: When invoke first request or by asynch way or by CompletableFuture jersey create instances of ClientRequest in NonInjectionManager$TypedInstances.threadPredestroyables and they never cleaned until clinet not closed, but i need to reuse client instance.

CODE:
` Client client = ClientBuilder.newClient();

    Response response = client.target("https://google.com").request().get();
    int status = response.getStatus();
    response.close();
    System.out.println(status);
    //Create instance in NonInjectionManager$TypedInstances.threadPredestroyables

    for (int i = 0; i <= 10; i++) {
         client.target("https://google.com").request()
                .async()
                .post(Entity.text("text"));
    }
    //Create 10 instance in NonInjectionManager$TypedInstances.threadPredestroyables

    for (int i = 0; i <= 10; i++) {
        CompletableFuture.supplyAsync(() -> {
            Response test = client.target("https://google.com").request()
                    .post(Entity.text("text"));
            int string = test.getStatus();
            test.close();
            System.out.println(string);

            return null;
        }).join();
    }
    //Create 10 instance in NonInjectionManager$TypedInstances.threadPredestroyables

    response = client.target("https://sm-dev.smiddle.lab/MessengerGateway/ping").request().get();
    status = response.getStatus();
    response.close();`

image

@jansupol
Copy link
Contributor

@skafenko Thank you for testing our NonInjectionManager for the Jersey Client. Its primary purpose at the moment is a fallback when HK2 is not on a classpath. It is not capable of injections the way the JAX-RS Spec mandates, and HK2 is the preferred injection framework backing up the Jersey Client. The intention is to use this NonInjectionManager for the client in Jersey 5, where HK2 will be replaced to better comply with Jakarta REST's next Specification.

We have added a proper cleanup of the @RequestScoped objects in #5813.

@jansupol jansupol linked a pull request Dec 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants