上传文件出现 OOM 错误
我的环境
版本:683caf7a 数据库:H2 1.4.196 (2017-06-10) 运行模式:development User Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
错误日志
2020-09-26 11:56:12.290 WARN 21204 --- [qtp36758956-379] org.eclipse.jetty.server.HttpChannel : /api/admin/attachments/upload
java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at java.base/java.util.Arrays.copyOf(Arrays.java:3745) ~[na:na]
at java.base/java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:120) ~[na:na]
at java.base/java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:95) ~[na:na]
at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:137) ~[na:na]
at org.eclipse.jetty.util.MultiPartInputStreamParser$MultiPart.write(MultiPartInputStreamParser.java:173) ~[jetty-util-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.util.MultiPartInputStreamParser.parse(MultiPartInputStreamParser.java:797) ~[jetty-util-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.util.MultiPartInputStreamParser.getParts(MultiPartInputStreamParser.java:482) ~[jetty-util-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.server.MultiParts$MultiPartsUtilParser.getParts(MultiParts.java:112) ~[jetty-server-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.server.Request.getParts(Request.java:2382) ~[jetty-server-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.server.Request.extractContentParameters(Request.java:529) ~[jetty-server-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.server.Request.getParameters(Request.java:430) ~[jetty-server-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.eclipse.jetty.server.Request.getParameter(Request.java:1059) ~[jetty-server-9.4.29.v20200521.jar:9.4.29.v20200521]
at run.halo.app.security.filter.AbstractAuthenticationFilter.getTokenFromRequest(AbstractAuthenticationFilter.java:250) ~[classes/:na]
at run.halo.app.security.filter.AbstractAuthenticationFilter.isSufficientOneTimeToken(AbstractAuthenticationFilter.java:206) ~[classes/:na]
at run.halo.app.security.filter.AbstractAuthenticationFilter.doFilterInternal(AbstractAuthenticationFilter.java:184) ~[classes/:na]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
at run.halo.app.filter.CorsFilter.doFilter(CorsFilter.java:49) ~[classes/:na]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
at run.halo.app.filter.LogFilter.doFilterInternal(LogFilter.java:38) ~[classes/:na]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) ~[spring-boot-actuator-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618) ~[jetty-servlet-9.4.29.v20200521.jar:9.4.29.v20200521]
期望行为
无论多大的文件,只要磁盘空间满足,都能够正常上传。
当前行为
上传 3.4G 的文件过程中,出现以上错误。