You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, we're observing an issue with ShallowEtagHeaderFilter when the downloaded file is bigger than 2Gb, the ContentCachingResponseWrapper throws a NumberFormatException due to int overflow when trying to save the Content-Length value.
Is it possible to update this class to support long values for the Content-Length value?
Here is a stack trace of an exception
java.lang.NumberFormatException: For input string: "2148532224"
at java.base/java.lang.NumberFormatException.forInputString(Unknown Source)
at java.base/java.lang.Integer.parseInt(Unknown Source)
at java.base/java.lang.Integer.valueOf(Unknown Source)
at org.springframework.web.util.ContentCachingResponseWrapper.addHeader(ContentCachingResponseWrapper.java:173)
at jakarta.servlet.http.HttpServletResponseWrapper.addHeader(HttpServletResponseWrapper.java:141)
.......
// Configuration.java
@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
return new ShallowEtagHeaderFilter();
}
@geobreze we'll look into this, thanks for the report. Are you aware that using the ShallowEtagHeaderFilter is effectively caching the entire response in memory? This is putting huge pressure on your GC and I wouldn't advise this approach if your application is serving very large files.
ContentCachingResponseWrapper is really designed to limit to 2GB given it's buffering the content in memory. We have a dedicated exception that states as much:
Affects: spring-web 6.1.10
Hello, we're observing an issue with ShallowEtagHeaderFilter when the downloaded file is bigger than 2Gb, the ContentCachingResponseWrapper throws a NumberFormatException due to int overflow when trying to save the Content-Length value.
Is it possible to update this class to support
long
values for the Content-Length value?Here is a stack trace of an exception
and the sample code we use in
@RestController
It would be great If you could share suggestions on how to avoid this issue when content length overflows
int
.The text was updated successfully, but these errors were encountered: