Replies: 3 comments 5 replies
-
|
I'll have to try to create a reproducer unless you've already got one. Part of the reason for the limit is to avoid a DDoS or similar attacks. |
Beta Was this translation helpful? Give feedback.
-
|
Hi James, we are using I assumed that there will be no buffering on resteasy side since using So before investing more time here, can you tell if it's possible at all to prevent resteasy from buffering before sending out the request? All the attempts failed because ultimately BR, |
Beta Was this translation helpful? Give feedback.
-
|
Here's a proposed solution provided by Grok that maybe useful: Potential Solutions
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a system that retrieves a large file via one API and forwards it to another API as part of a multipart/related request. My goal is to stream the file directly from the incoming source to the outgoing API without fully buffering it in memory or disk.
I'm using a Jakarta EE 10 / MicroProfile 6 compatible setup, deployed on a WF33-backed server, with the following versions:
What I'm doing:
1️⃣ I use a MicroProfile Rest Client to fetch an InputStream from the first API.
2️⃣ I wrap that stream in a MultipartRelatedOutput along with a small JSON part.
3️⃣ I send it using another MicroProfile Rest Client with the following method:
My expectation:
Since the part I’m passing to MultipartRelatedOutput is an InputStream, and debugging shows that the incoming stream works as expected (the stream is lazily obtained), I expect RESTEasy’s multipart writer to stream the data directly to the outgoing request.
What actually happens:
When the request is prepared, the process quickly returns the InputStream (no delays in fetching).
However, when the request is sent to the second API, the process hangs and starts consuming memory. After hitting the default 50 MB threshold, I receive:
Debugging shows, that the problem does not occur while receiving the InputStream; it's fast and behaves as expected. The issue happens during sending, inside the multipart serialization and writing phase. The stack trace confirms that RESTEasy’s multipart writer calls the InputStreamProvider.writeTo(), which streams, but ultimately buffering seems to be enforced lower down by EntityOutputStream.checkFileThreshold().
My question:
Is there a supported way to disable full buffering of the multipart entity when using MultipartRelatedOutput + InputStream parts, so that true end-to-end streaming can happen? Or is the only viable approach to manually build the multipart body using StreamingOutput (or a custom writer)? I understand that buffering might be needed when Content-Length is unknown, but since my incoming file has a known length (from metadata of the first API), I am wondering if this could be leveraged to achieve streaming without full buffering.
Beta Was this translation helpful? Give feedback.
All reactions