- All Implemented Interfaces:
Closeable, AutoCloseable
- Enclosing class:
ResettableGZIPInputStream
Unsupported: - available() doesn't include the extra byte - skip() doesn't skip the extra byte
Why? otherwise the inflater finished() is wrong when the compressed payload (in between the 10 byte header and the 8 byte footer) is a multiple of 512 bytes, which caused read(buf, off, len) above to fail. Happened every time with 1042 byte compressed router infos, for example.
Details:
Warning with Inflater nowrap = true:
"Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations."
This is for sure:
"This is not nearly specific enough to be useful. Where in the compressed byte array is the extra 'dummy' byte" expected? What is it to contain? When calling setInput() is the 'len' argument incremented to include the dummy byte or not?"
This is useless:
This seems to be the definitive answer:
"The fix simply involves copying the byte array and tacking a single null byte on to the end."
http://code.google.com/p/google-apps-sso-sample/issues/detail?id=8
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanTrue once the dummy byte was sent.private static final byteThe dummy byte appended at the end.Fields inherited from class FilterInputStream
inConstructor Summary
ConstructorsMethod Summary
All MethodsMethods inherited from class FilterInputStream
available, mark, markSupported, read, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
Field Details
DUMMY
_extraSent
private boolean _extraSentTrue once the dummy byte was sent.
Constructor Details
ExtraByteInputStream
Appends one dummy byte to a stream.- Parameters:
in- the stream to wrap
Method Details
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
reset
getInputStream