ResponseEntity<Resource> is not reliably closed with InputStreamResource #32802
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: documentation
A documentation task
type: enhancement
A general enhancement
Milestone
Environment: SpringBoot 2.7.10, SpringWeb 5.3.26, Java 11
There is a file download api which uses Amazon S3, and the return result is a ResponseEntity
It works fine until invalid content types appear, such as "excel". The InputStream of the S3Object is not closed because SpringWeb failed to parse the content type. It leads to memory leaks and connection pool leaks.
I can not do anything in this situation because I am not sure if the return will result in any exceptions. So I have to use try-with-resources instead:
In my opinion, the Spring framework should be responsible for closing the input stream that I return, no mater what exception occurs.
If my viewpoint is incorrect, please tell me the standard implementation for file downloads.
Thanks
The text was updated successfully, but these errors were encountered: