RFR JDK-7031075: GZIPInputStream's available() reports 1, but read() gives -1.
pavel.rappo at oracle.com
Tue Jul 12 22:38:37 UTC 2016
A quick question. Is "inf.finished()" the only condition that needs to be
checked in order to determine reachEOF? In read(), for instance, they use union:
if (inf.finished() || inf.needsDictionary())
reachEOF = true;
Otherwise it seems to me it could be the case that read() returns -1 while
available() returns 0. Or I am missing something obvious.
> On 12 Jul 2016, at 23:06, Xueming Shen <xueming.shen at oracle.com> wrote:
> ping. simple fix.
> On 7/11/16, 3:53 PM, Xueming Shen wrote:
>> Please help review the change for JDK-7031075.
>> issue: https://bugs.openjdk.java.net/browse/JDK-7031075
>> webrev: http://cr.openjdk.java.net/~sherman/7031075/webrev
>> This is a corner case in current implementation, in which the "readEOF"
>> flag is only set when/after the read/skip method is invoked and the "eof"
>> is "explicitly" reached. Which means even the inflater has reached the
>> "end of the compressed stream" (inf.finished() == true) during the last
>> read/skip invocation (since there are still data available, so the date gets
>> read/returned successfully), the readEOF is not set, and therefor the
>> available() return > 0 if checked.
>> The proposed change here is to do an extra check of the inf.finished(),
>> if it returns true, means there is no more data inside the inflater the
>> end of compressed stream has been reached, available() returns true
>> in this case.
More information about the core-libs-dev