I am familiar why the following exception is raised on the server side (client disconnecting from the server without reading the data). However, when this happens, the server becomes extrememly slow and unresponsive. I am looking at potential solutions so that the server is resilient to a bad behaving client.
java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_45]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_45]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_45]
at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_45]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_45]
at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:127) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:173) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:139) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:197) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer.java:41) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer.java:320) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:84) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.coyote.Response.doWrite(Response.java:503) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:388) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
... 103 common frames omitted
Wrapped by: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:393) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
I had faced a similar situation where every download through controller was throwing Broken Pipe exception, later on I found the root cause of issue to be duplicate loading of spring context in tomcat container. This can be checked by scanning the logs for two entries of same controller method. I resolved it by moving loading the mvc-dispatcher servlet exactly once.