不定时出现Stream is closed,大佬能不能帮我分析一下哪里错误

com.jfinal.template.TemplateException: UT010029: Stream is closed

Template: "/common/error/500.html". Line: 1

at com.jfinal.template.stat.ast.Text.exec(Text.java:51)

at com.jfinal.template.stat.ast.StatList.exec(StatList.java:68)

at com.jfinal.template.Template.render(Template.java:58)

at com.jfinal.render.TemplateRender.render(TemplateRender.java:61)

at com.jfinal.render.ErrorRender.render(ErrorRender.java:51)

at com.jfinal.core.ActionHandler.handleActionException(ActionHandler.java:168)

at com.jfinal.core.ActionHandler.handle(ActionHandler.java:116)

at com.jfinal.ext.handler.SessionIdHandler.handle(SessionIdHandler.java:20)

at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:48)

at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)

at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)

at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)

at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)

at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)

at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)

at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)

at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)

at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)

at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.io.IOException: UT010029: Stream is closed

at io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:137)

at com.jfinal.template.io.ByteWriter.write(ByteWriter.java:86)

at com.jfinal.template.stat.ast.Text.exec(Text.java:49)

... 48 more

并发比较多后不定时出现,然后整个网站就奔溃了

还有com.jfinal.core.ActionException这个错误,调试中又不出现,不知道怎么追踪,重启又好了

评论区

JFinal

2020-11-16 11:48

我自己的项目也偶尔出现这个异常,但网站绝对不会奔溃,奔溃应该是别的原因,一般是资源泄漏之类的错误

你碰到 TemplateException: UT010029: Stream is closed 这个异常是指服务端在向客户端发送数据的时候,发现客户端主动断开了连接,这种异常是无法避免的

例如,某些情况下由于网速太慢,客户端在请求某个网页时发现迟迟没有响应,由于关闭浏览器,这个时候服务端仍然在向客户端发送数据,就一定会出现这个异常

阿里云的网络还比较稳定, 我的 jfinal.com 大概两三天会抛一个你碰到的这个异常,我都是直接无视的

JFinal

2020-11-16 11:50

如果你不想看到这个异常,有一些解决办法:
1:配置日志,让日志跳过这个异常
2:继承 TemplateRender 在 try catch 中处理一下,然后配置 me.setRenderFactory(....) 接管 Controller.render(...)

zys666

2020-11-16 11:54

@JFinal 谢谢老大

JFinal

2020-11-16 11:57

@zys666 服务端在发送数据的时候客户端主动断开连接,这个是没法控制的

jfinal.com 也一直有这个异常,但项目从来都是可以正常访问的

JFinal

2020-11-16 11:58

@zys666 你说的项目奔溃了,我建议用一下 jdk 自带的 jvisualvm 这个工具,看看你的项目资源占用与回收情况,重点看内存、线程这类资源

zys666

2020-11-16 12:21

热门反馈

扫码入社