enonic/cms-ce — pull request #297 by vfi (2011-10-17 11:01:14+00:00)
Title: B-02342 Better exception handling in HttpServletUtil.copyNoCloseOut

B-02342 Better exception handling in HttpServletUtil.copyNoCloseOut

Inside the try-catch IOException, wrap the line:

in.close()

...in a new try-catch that catches IOException

and logs the message as a warning.

This is to avoid exception thrown to client if connection have been reset by client.

Stacktrace that inspired this task:

java.net.SocketException: Connection reset
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:358)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)

at com.enonic.cms.framework.util.HttpServletUtil.copyNoCloseOut(HttpServletUtil.java:128)