diff --git a/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibDecoder.java b/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibDecoder.java index 23a9c550a4..a35f48fda1 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibDecoder.java @@ -18,7 +18,6 @@ package io.netty.handler.codec.compression; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import java.nio.ByteOrder; import java.util.List; import java.util.zip.CRC32; import java.util.zip.DataFormatException; @@ -173,8 +172,9 @@ public class JdkZlibDecoder extends ZlibDecoder { boolean readFooter = false; byte[] outArray = decompressed.array(); while (!inflater.needsInput()) { - int outIndex = decompressed.arrayOffset() + decompressed.writerIndex(); - int length = outArray.length - outIndex; + int writerIndex = decompressed.writerIndex(); + int outIndex = decompressed.arrayOffset() + writerIndex; + int length = decompressed.writableBytes(); if (length == 0) { // completely filled the buffer allocate a new one and start to fill it @@ -186,7 +186,7 @@ public class JdkZlibDecoder extends ZlibDecoder { int outputLength = inflater.inflate(outArray, outIndex, length); if (outputLength > 0) { - decompressed.writerIndex(decompressed.writerIndex() + outputLength); + decompressed.writerIndex(writerIndex + outputLength); if (crc != null) { crc.update(outArray, outIndex, outputLength); } diff --git a/codec/src/test/java/io/netty/handler/codec/compression/ZlibTest.java b/codec/src/test/java/io/netty/handler/codec/compression/ZlibTest.java index 9cb36a919d..cc948a85f9 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/ZlibTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/ZlibTest.java @@ -25,6 +25,8 @@ import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.util.zip.DeflaterOutputStream; import java.util.zip.GZIPOutputStream; import static org.junit.Assert.*; @@ -33,6 +35,49 @@ public abstract class ZlibTest { private static final byte[] BYTES_SMALL = new byte[128]; private static final byte[] BYTES_LARGE = new byte[1024 * 1024]; + private static final byte[] BYTES_LARGE2 = ("\n" + + "\n" + + "
\n" + + "If you're seeing this page via a web browser, it means you've setup Tomcat successfully." + + " Congratulations!
\n" + + " \n" + + "This is the default Tomcat home page." +
+ " It can be found on the local filesystem at: /var/lib/tomcat7/webapps/ROOT/index.html
Tomcat7 veterans might be pleased to learn that this system instance of Tomcat is installed with" +
+ " CATALINA_HOME
in /usr/share/tomcat7
and CATALINA_BASE
in" +
+ " /var/lib/tomcat7
, following the rules from" +
+ " /usr/share/doc/tomcat7-common/RUNNING.txt.gz
.
You might consider installing the following packages, if you haven't already done so:
\n" + + '\n' + + "tomcat7-docs: This package installs a web application that allows to browse the Tomcat 7" + + " documentation locally. Once installed, you can access it by clicking here.
\n" + + '\n' + + "tomcat7-examples: This package installs a web application that allows to access the Tomcat" + + " 7 Servlet and JSP examples. Once installed, you can access it by clicking" + + " here.
\n" + + '\n' + + "tomcat7-admin: This package installs two web applications that can help managing this Tomcat" + + " instance. Once installed, you can access the manager webapp and" + + " the host-manager webapp.
\n" + + '\n' + + "
NOTE: For security reasons, using the manager webapp is restricted" +
+ " to users with role \"manager\"." +
+ " The host-manager webapp is restricted to users with role \"admin\". Users are " +
+ "defined in /etc/tomcat7/tomcat-users.xml
.