8227609: (fs) Files.newInputStream(...).skip(n) should allow skipping beyond file size

Brian Burkhalter brian.burkhalter at oracle.com
Fri Jul 26 15:58:20 UTC 2019


> On Jul 26, 2019, at 8:44 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> On 26/07/2019 16:06, Florian Weimer wrote:
>> :
>> On ext4?  The EINVAL depends on the file system.  XFS supports arbitrary
>> offsets, but ext4 does not, for example.
>> 
>> We discussed this recently on another thread:
>> 
> Right, the recent thread on this topic is here:
> 
> https://mail.openjdk.java.net/pipermail/nio-dev/2019-June/006226.html <https://mail.openjdk.java.net/pipermail/nio-dev/2019-June/006226.html>
The seek to Long.MAX_VALUE occurs due to this change at line 128 to ChannelInputStream at line 128:
 124             long pos = sbc.position();
 <> 125             long newPos;
 126             if (n > 0) {
 127                 newPos = pos + n;
 128                 if (newPos < 0) newPos = Long.MAX_VALUE;
 129             } else {
 130                 newPos = Long.max(pos + n, 0);
 131             }
 <> 132             sbc.position(newPos);
Note that in the version prior to the patch [1] for [2], ChannelInputStream.skip() would devolve to InputStream.skip() and would skip only to the end of the stream for the case of pos + n overflowing so the above looks like a change in behavior.

Thanks,

Brian

[1] http://hg.openjdk.java.net/jdk/jdk/rev/8c19519114e7
[2] https://bugs.openjdk.java.net/browse/JDK-8227080

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190726/1acda238/attachment.html>


More information about the nio-dev mailing list