Submitted On 17-APR-2000
MatsA
What would the reason for NOT exposing the "true"
functionality from ZLIB be?
Submitted On 18-APR-2000
ScottEllsworth
The program in question does a very nice job of ssh, but it
does not perform the gzip compression that makes ssh
conserve bandwidth so well. If the appropriate
Z_PARTIAS_FLUSH were allowed, then this pure java
implementation of ssh would be doable.
As far as I can tell, there is very little downside, save
that if you decide to implement this in java rather than
native code, you would need to supply the same
functionality.
Submitted On 09-FEB-2001
jbwaters
This is the same as 4206909, by having it twice it dilutes
the votes for it. It is a very reasonable and general
request and should be very easy since the functionality is
already in zlib, you just need to add the wrapper for it.
This avoids the duplications of zlib that is needed now to
support streaming interactive compressions applications
like ssh. And avoids needed to run a java reimplimentation
of zlib also.
Submitted On 21-JUN-2001
charlieroche
I agree, I dont think this is an unreasonable request.
Submitted On 31-AUG-2001
tinca
As noted it is the same as bug 4206909. Sun has been
lamenting on this from 1999 on. One cannot deny the
importance of having pure java solution supported by
standard libs that allows to use compressed sockets. This
also affects RMI/EJB...
Submitted On 30-JAN-2002
lapo.luchini
In the meantime we can use http://www.jcraft.com/jzlib/ to
have compete compatibility with zlib.
But nonetheless having it "native" would be better...
Submitted On 23-JUN-2002
rsaddey
Extending DeflaterOutputStream and overriding flush() as
outlined below
yields a deflating OutputStream, that can be used for data
transmission
(e.g. SocketOutputStream).
Plase note, that InflaterInputStream should be subclassed
as well in
order to prevent false blocking on reads.
Furthermore (De/In)-flaters with nowrap == true should be
used
to ommit headers/trailers.
rws@saddey.com 23-jun-02
The output part:
public class CompressingOutputStream extends
DeflaterOutputStream {
public CompressingOutputStream (final OutputStream out)
{
// Using Deflater with nowrap == true will ommit
headers and trailers
super(out, new Deflater
(Deflater.DEFAULT_COMPRESSION,true));
}
private static final byte [] EMPTYBYTEARRAY = new byte
[0];
/**
* Insure all remaining data will be output.
*/
public void flush() throws IOException {
/**
* Now this is tricky: We force the Deflater to
flush
* its data by switching compression level.
* As yet, a perplexingly simple workaround for
*
http://developer.java.sun.com/developer/bugParade/bugs/42557
43.html
*/
def.setInput(EMPTYBYTEARRAY, 0, 0);
def.setLevel(Deflater.NO_COMPRESSION);
deflate();
def.setLevel(Deflater.DEFAULT_COMPRESSION);
deflate();
out.flush();
}
} // class
The input part:
public class DecompressingInputStream extends
InfalterInputStream {
public DecompressingInputStream (final InputStream in) {
// Using Inflater with nowrap == true will ommit
headers and trailers
super(in, new Inflater(true));
}
/**
* available() should return the number of bytes that
can be read without
* running into blocking wait. Accomplishing this feast
would eventually require
* to pre-inflate a huge chunk of data, so we rather
opt for a more relaxed
* contract (java.util.zip.InflaterInputStream does not
fit the bill).
* This code has been tested to work with
BufferedReader.readLine();
*/
public int available() throws IOException {
if (!inf.finished() && !inf.needsInput()) {
return 1;
} else {
return in.available();
}
}
} //class
Submitted On 24-JUL-2002
dhay
The workaround suggested by rsaddey works great except for
one small problem. The code in the 'flush' method needs to
run only if 'def.finished()' returns false. (e.g. if
(!def.finished()) { ... }
Submitted On 04-NOV-2002
lapo.luchini
I see no reason not to select this bug as a duplicate of bug
4206909... maybe Sun people just don't read bug reports 0_O
Let's move all our votes there (right now there are 20 here
and 38 there) so that the bug can get a little more
"importance".
Submitted On 01-JUN-2004
elizarov
The following changes has to be made:
1) Z_PARTIAL_FLUSH must be exposed.
2) DeflaterOutputStream must correctly implement flush() method.
It looks like authors of java.util.zip have only file compression in mind and had no clue whatsoever that one might want to compress messages that are being sent back and forth over network.
Submitted On 03-SEP-2004
nmgafter
It is because of the absence of this flushing functionality that a complete reimplementation of zlib in Java has been produced at <http://www.jcraft.com/jzlib/> under a BSD-style license. Hey, Sun, please consider replacing the native version with this! [And I'll see you on Tuesday]
Submitted On 05-JUN-2006
linuxhippy
man its a shame that this design _flaw_ still has not been fixed!
Submitted On 01-MAY-2008
what's about 1.7 ?
around 10 years, it's too long time.
JCraft implementation is good, but up to 8 times slowly than zlib :(
Submitted On 15-MAY-2008
Jess_Holle
I'm seeing cases where using flush as defined here gives an extra 0 byte on the end of the decompressed content.
I haven't managed to track down why...
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|