[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-core-libs-dev
Subject: Re: ZipInputStream#readAllBytes should clarify it doesn't read the whole stream?
From: Jaikiran Pai <jai.forums2013 () gmail ! com>
Date: 2021-02-26 2:24:26
Message-ID: a47b464c-3eb1-dc65-331b-baf351e66fb6 () gmail ! com
[Download RAW message or body]
I just created https://bugs.openjdk.java.net/browse/JDK-8262435 to track
this.
-Jaikiran
On 25/02/21 9:05 pm, Jaikiran Pai wrote:
>
> Thank you Lance and Alan. I do have access to JBS, I'll file one
> tomorrow with the details.
>
> -Jaikiran
>
> On 25/02/21 9:04 pm, Lance Andersen wrote:
> > Hi Jaikiran,
> >
> > Yes I believe this makes sense.
> >
> > It would also require a CSR.
> >
> > I can login a bug if you do not have access to do so.
> >
> > Best
> > Lance
> >
> > > On Feb 24, 2021, at 10:56 PM, Jaikiran Pai <jai.forums2013@gmail.com
> > > <mailto:jai.forums2013@gmail.com>> wrote:
> > >
> > > The javadoc of InputStream#readAllBytes() states[1] that it reads
> > > all the remaining bytes of the stream. The
> > > java.util.zip.ZipInputStream doesn't override this method and thus
> > > "inherits" this javadoc. The implementation of
> > > InputStream#readAllBytes() ultimately ends up calling
> > > ZipInputStream#read()[2], so the implementation correctly reads only
> > > till the end of the current ZipEntry and not the entire
> > > ZipInputStream. However, because the javadoc gets inherited, reading
> > > any code like the following doesn't make it clear that it's only
> > > reading till the end of the current entry:
> > >
> > > zis = ... // ZipInputStream
> > > while ((e = zis.getNextEntry()) != null) {
> > > String name = e.getName();
> > > zis.readAllBytes(); // gives an impression that all bytes of the
> > > stream are read
> > > ...
> > > }
> > >
> > > Should the ZipInputStream override the readAllBytes(), just so as to
> > > add a very specific javadoc to this method which explains that it
> > > reads only till the end of current entry and other related
> > > semantics? Perhaps the same should be done for
> > > ZipInputStream#readNBytes(...)?
> > >
> > >
> > > [1]
> > > https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/io/InputStream.html#readAllBytes() \
> > > <https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/io/InputStream.html#readAllBytes()>
> > > [2]
> > > https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/zip/ZipInputStream.html#read(byte%5B%5D,int,int) \
> > > <https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/zip/ZipInputStream.html#read(byte%5B%5D,int,int)>
> > >
> > > -Jaikiran
> > >
> >
> >
> >
> >
> > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
> > Oracle Java Engineering
> > 1 Network Drive
> > Burlington, MA 01803
> > Lance.Andersen@oracle.com <mailto:Lance.Andersen@oracle.com>
> >
> >
> >
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic