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

Cannot download a large file using RESTEasy Reactive #22218

Closed
pjeanjean opened this issue Dec 14, 2021 · 1 comment · Fixed by #22229
Closed

Cannot download a large file using RESTEasy Reactive #22218

pjeanjean opened this issue Dec 14, 2021 · 1 comment · Fixed by #22229
Labels
area/resteasy-reactive kind/bug Something isn't working
Milestone

Comments

@pjeanjean
Copy link

Describe the bug

I recently switched to resteasy-reactive for my application, and I'm now unable to download large files.
If I try to create a response with the following syntax:

response = Response.ok(file);

It fails for files larger than 2GB because it tries to buffer them but it is not possible to instantiate a ByteArrayOutputStream larger than MAX_INT (there is basically an integer overflow when calling the constructor and I end up with Request failed: java.lang.IllegalArgumentException: Negative initial size).

When I try to pass a FileInputStream as the response entity, it does work but my application maxes one of my CPU core during the download, and if the download gets interrupted the inputstream is never closed.

Expected behavior

It should be possible to send large files as response entities using resteasy-reactive without maxing CPU usage.

Actual behavior

Using a File type leads to integer overflow when instantiating the response outputstream, using an inputstream maxes a CPU core and never closes the file descriptor if interrupted.

How to Reproduce?

  1. Use resteasy-reactive
  2. Build a service that sends a file
  3. Request a file larger than Integer.MAX_INT bytes

Output of uname -a or ver

Linux 5.13.13-arch1-1 #1 SMP PREEMPT Thu, 26 Aug 2021 19:14:36 +0000 x86_64 GNU/Linux

Output of java -version

openjdk 11.0.12 2021-07-20

GraalVM version (if different from Java)

GraalVM 21.3.0 Java 11 CE (Java Version 11.0.13+7-jvmci-21.3-b05)

Quarkus version or git rev

2.5.1.Final

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

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Additional information

No response

@pjeanjean pjeanjean added the kind/bug Something isn't working label Dec 14, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Dec 14, 2021

/cc @FroMage, @geoand, @stuartwdouglas

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Dec 15, 2021
This makes it possible to download large files, however it is still
slower than the static resource handler.

Even when using Vert.x AsyncFile it is still slower than the built in
Vertx handler, so more work on performance is required here.

Fixes quarkusio#22218
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Dec 15, 2021
This makes it possible to download large files, however it is still
slower than the static resource handler.

Even when using Vert.x AsyncFile it is still slower than the built in
Vertx handler, so more work on performance is required here.

Fixes quarkusio#22218
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Dec 15, 2021
This makes it possible to download large files, however it is still
slower than the static resource handler.

Fixes quarkusio#22218
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Dec 15, 2021
This makes it possible to download large files.

Fixes quarkusio#22218
@quarkus-bot quarkus-bot bot added this to the 2.7 - main milestone Dec 15, 2021
gsmet pushed a commit that referenced this issue Dec 15, 2021
This makes it possible to download large files.

Fixes #22218

(cherry picked from commit 86978e8)
@gsmet gsmet modified the milestones: 2.7 - main, 2.6.0.Final Dec 15, 2021
gsmet pushed a commit that referenced this issue Dec 15, 2021
This makes it possible to download large files.

Fixes #22218

(cherry picked from commit 86978e8)
@gsmet gsmet modified the milestones: 2.6.0.Final, 2.5.3.Final Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-reactive kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants