java.util.zip.Deflater: needsInput() returns true after finish() (original) (raw)
Zhong Yu zhong.j.yu at gmail.com
Sat Mar 10 03:59:12 UTC 2012
- Previous message: hg: jdk8/tl/langtools: 7151802: compiler update caused sqe test failed
- Next message: 7152866: Tests not run because they are missing the @run tag
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In java.util.zip.Deflater, after finish() is called, needsInput() may still return true. This is counter-intuitive.
It's probably not an issue in blocking style IO, since state is implied by context, code (lexically) after finish() knows it doesn't make sense to call needsInput().
In non-blocking IO, code needs another flag to remember that finish() has been called, so that it won't call needsInput() again (which may return a misleading true). That's an unnecessary chore, since Deflater already contains the flag.
Suggested fix:
java.util.zip.Deflater public boolean needsInput() { synchronized (zsRef) { return !finish && len <= 0; } }
(I don't understand the synchronized (zsRef)
part; this class should
only be used serially anyway. But if other methods require
synchronization, this method requires it too)
Regards, Zhong Yu
- Previous message: hg: jdk8/tl/langtools: 7151802: compiler update caused sqe test failed
- Next message: 7152866: Tests not run because they are missing the @run tag
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]