-
Notifications
You must be signed in to change notification settings - Fork 31
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
@RequestBody argument resolver throws 'java.io.IOException: Stream closed' #200
Comments
Please take into account that using Consider using |
Nevertheless always reading the content to a String indeed seems bad practice. |
If the endpoint is supposed to process large payloads such as binaries (>100MB), it's better done on input stream level, there is no reason to wrap a binary file as a POJO, thus in that scenario |
You can indeed assume that the body that the user wants to process with a In your code snippets, you have 2 potentially large allocations: Additionally, the cached content is limited to 1024 bytes, which is likely a bit too small for things like alfred api, where the search and metadata endpoint both can take much larger structures (search query and all metadata of a document) |
That is not the right place to fix that problem? You already have such protection at the level of Tomcat configuration. |
I'm submitting a ... (check one with "x")
Expected Behavior
No
IOException
when working with the@RequestBody
parameterCurrent Behavior
Webscript method arguments annotated with
@RequestBody
are resolved with theRequestBodyArgumentResolver
. This resolver reads the input stream of the request and tries to parse it into the requested type. Nevertheless if the input stream has already been read (and closed), this will throw anIOException
.Possible Solution
Use
content.getContent()
instead ofcontent.getInputStream()
to resolve the argument. This will not throw an exception if the input streams is already closed, and will just return the content that was read earlier.Steps to Reproduce (for bugs)
@Before
webscript handler that has e.g. theContent
as an argument@RequestBody
annotationYour Environment
The text was updated successfully, but these errors were encountered: