由于客户端关闭了与我的dropwizard服务的连接而出现错误。
问题在于该连接正在关闭,并且当jersey尝试刷新至该连接时,显然已关闭,因此这是不可能的。问题是,这将作为IOException返回,这使我的日志记录变得混乱。理想情况下,我不在乎客户端是否正在关闭连接,但是我无法抑制它,因为它在WriterInterceptorExecutor.proceed
期间被触发。
理想情况下,当客户端关闭连接时,我希望Jersey的某些配置不会引发错误。
错误:
ERROR [2018-11-06 21:42:07,918] org.glassfish.jersey.server.ServerRuntime$Responder: An I/O error has occurred while writing a response message entity to the container output stream.
! java.io.IOException: Broken pipe
! at sun.nio.ch.FileDispatcherImpl.writev0(Native Method)
! at sun.nio.ch.SocketDispatcher.writev(SocketDispatcher.java:51)
! at sun.nio.ch.IOUtil.write(IOUtil.java:148)
! at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:504)
! at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:179)
! ... 75 common frames omitted
! Causing: org.eclipse.jetty.io.EofException: null
! at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:199)
! at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:420)
! at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:313)
! at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:147)
! at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:739)
! at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
! at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224)
! at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:519)
! at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:737)
! at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:788)
! at org.eclipse.jetty.server.handler.gzip.GzipHttpOutputInterceptor.write(GzipHttpOutputInterceptor.java:108)
! at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:235)
! at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:219)
! at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:491)
! at java.io.OutputStream.write(OutputStream.java:75)
! at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.write(ResponseWriter.java:320)
! at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:218)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:294)
! at org.glassfish.jersey.message.internal.ByteArrayProvider.writeTo(ByteArrayProvider.java:96)
! at org.glassfish.jersey.message.internal.ByteArrayProvider.writeTo(ByteArrayProvider.java:60)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
! at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
! at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86)
! ... 50 common frames omitted
! Causing: org.glassfish.jersey.server.internal.process.MappableException: org.eclipse.jetty.io.EofException
! at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:92)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
! at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
! at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711)
! at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444)
! at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434)
! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329)
! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
! at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
! at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
! at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49)
! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:34)
! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:50)
! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:44)
! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240)
! at io.dropwizard.jetty.ContextRoutingHandler.handle(ContextRoutingHandler.java:38)
! at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:493)
! at io.dropwizard.jetty.BiDiGzipHandler.handle(BiDiGzipHandler.java:68)
! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:169)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
! at org.eclipse.jetty.server.Server.handle(Server.java:534)
! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
! at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
! at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
! at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
! at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
! at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
! at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
! at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
! at java.lang.Thread.run(Thread.java:745)