You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/08/29 01:57:36 UTC
svn commit: r1378389 -
/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/FlushableGZIPOutputStream.java
Author: markt
Date: Tue Aug 28 23:57:35 2012
New Revision: 1378389
URL: http://svn.apache.org/viewvc?rev=1378389&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53725
Flushing the single byte needs special handling to avoid corruption in some edge cases. There may still be other edge cases where this fails.
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/FlushableGZIPOutputStream.java
Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/FlushableGZIPOutputStream.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/FlushableGZIPOutputStream.java?rev=1378389&r1=1378388&r2=1378389&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/FlushableGZIPOutputStream.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/FlushableGZIPOutputStream.java Tue Aug 28 23:57:35 2012
@@ -41,6 +41,7 @@ public class FlushableGZIPOutputStream e
*/
private byte[] lastByte = new byte[1];
private boolean hasLastByte = false;
+ private boolean flushingLastByte = false;
@Override
public void write(byte[] bytes) throws IOException {
@@ -98,7 +99,9 @@ public class FlushableGZIPOutputStream e
if (hasLastByte) {
// Clear the flag first, because write() may fail
hasLastByte = false;
+ flushingLastByte = true;
super.write(lastByte, 0, 1);
+ flushingLastByte = false;
}
}
@@ -137,6 +140,6 @@ public class FlushableGZIPOutputStream e
if (len > 0) {
out.write(buf, 0, len);
}
- } while (len > 0 || !def.needsInput());
+ } while (len !=0 && !flushingLastByte || !def.needsInput());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org