Hi,

I think that's looking pretty good.  One thing:

InputStream.java

 515      * @param      n   the number of bytes to be skipped.

How about an @param for throwOnEOF, too?


Regarding the tests:

NullInputStream.java

 237     @Test(groups = "closed")
 238     public static void testSkipNBytesClosed() {

Can this method also use the "expectedExceptions" attribute of @Test ?

--
Skip.java

Is there a test for skipNBytes() where the skip() call skips < n bytes ? I'm thinking about code coverage of:

588 // If not enough skipped, read and discard bytes, failing on EOF
 589             if (ns != n) {
 590                 discardNBytes(n - ns, true);
 591             }

If not, maybe MyInputStream could override skip(long), with a mode where it would skip < n bytes.

Thanks,
-Brent

On 10/23/18 3:02 PM, Brian Burkhalter wrote:
Here is an updated version which hopefully addresses the shortcoming pointed out below:

http://cr.openjdk.java.net/~bpb/6516099/webrev.02/ <http://cr.openjdk.java.net/%7Ebpb/6516099/webrev.02/>

The remaining assumption here is that skip(long) never returns a negative value.

Thanks,

Brian

On Oct 23, 2018, at 11:29 AM, Brian Burkhalter <brian.burkhal...@oracle.com <mailto:brian.burkhal...@oracle.com>> wrote:

That is exactly why version .00 of the patch implemented skipNBytes() in a fixed way in terms of read(). I think that there is a good compromise however and I shall update the patch accordingly.

On Oct 22, 2018, at 12:55 PM, Brent Christian <brent.christ...@oracle.com <mailto:brent.christ...@oracle.com>> wrote:

562     public void skipNBytes(long n) throws IOException {
563         if (n > 0 && skip(n) != n) {
564             throw new EOFException("End of stream before enough bytes skipped");
565         }
566     }

If an overrided skip() method were to skip < n bytes but not yet be at EOF, which I think the skip() spec allows, then wouldn't skipNBytes() throw an EOFException ?

Reply via email to