After upgrading to the newest zlib library (seen with 1.2.11) , it seems that only first chunk of Tomcat gzip response is compressed, which results, for example, with CSS not being loaded by browser:
As the response served by Tomcat is invalid, most browser will also terminate the connection resulting in an error like:
Caused by: org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Broken pipe (Write failed) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:407) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:310) at org.apache.catalina.connector.OutputBuffer.writeByte(OutputBuffer.java:451) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:77) at com.atlassian.plugin.webresource.impl.annotators.SemicolonResourceContentAnnotator.afterResourceInBatch(SemicolonResourceContentAnnotator.java:53) at com.atlassian.plugin.webresource.impl.annotators.ListOfAnnotators.afterResourceInBatch(ListOfAnnotators.java:35) at com.atlassian.plugin.webresource.impl.helpers.ResourceServingHelpers$1.writeTo(ResourceServingHelpers.java:130) ... 102 more Caused by: java.net.SocketException: Broken pipe (Write failed) at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) at java.net.SocketOutputStream.write(SocketOutputStream.java:155) at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366) at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:240) at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:117) at org.apache.coyote.http11.filters.GzipOutputFilter$FakeOutputStream.write(GzipOutputFilter.java:177) at org.apache.coyote.http11.filters.FlushableGZIPOutputStream.deflate(FlushableGZIPOutputStream.java:153)
on the server side.
Workaround:
- if possible downgrade zlib to a version before 1.2.11 (1.2.8 is known to work correctly)
- alternately disabling compression in Tomcat's server.xml configuration file will alleviate this issue (by setting the attribute compression to off on the Connector element in CROWD_INSTALL_DIR/apache-tomcat/conf/server.xml):
<?xml version="1.0" encoding="UTF-8"?> <Server port="8020" shutdown="SHUTDOWN"> <Service name="Catalina"> <Connector ... compression="off" ...
Tomcat7 produces corrupted gzip response with newest zlib (1.2.11) library
After upgrading to the newest zlib library (seen with 1.2.11) , it seems that only first chunk of Tomcat gzip response is compressed, which results, for example, with CSS not being loaded by browser:
As the response served by Tomcat is invalid, most browser will also terminate the connection resulting in an error like:
Caused by: org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Broken pipe (Write failed) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:407) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:310) at org.apache.catalina.connector.OutputBuffer.writeByte(OutputBuffer.java:451) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:77) at com.atlassian.plugin.webresource.impl.annotators.SemicolonResourceContentAnnotator.afterResourceInBatch(SemicolonResourceContentAnnotator.java:53) at com.atlassian.plugin.webresource.impl.annotators.ListOfAnnotators.afterResourceInBatch(ListOfAnnotators.java:35) at com.atlassian.plugin.webresource.impl.helpers.ResourceServingHelpers$1.writeTo(ResourceServingHelpers.java:130) ... 102 more Caused by: java.net.SocketException: Broken pipe (Write failed) at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) at java.net.SocketOutputStream.write(SocketOutputStream.java:155) at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366) at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:240) at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:117) at org.apache.coyote.http11.filters.GzipOutputFilter$FakeOutputStream.write(GzipOutputFilter.java:177) at org.apache.coyote.http11.filters.FlushableGZIPOutputStream.deflate(FlushableGZIPOutputStream.java:153)
on the server side.
Workaround:
- if possible downgrade zlib to a version before 1.2.11 (1.2.8 is known to work correctly)
- alternately disabling compression in Tomcat's server.xml configuration file will alleviate this issue (by setting the attribute compression to off on the Connector element in CROWD_INSTALL_DIR/apache-tomcat/conf/server.xml):
<?xml version="1.0" encoding="UTF-8"?> <Server port="8020" shutdown="SHUTDOWN"> <Service name="Catalina"> <Connector ... compression="off" ...