Invalid argument exception when trying to seek FilePosition to LONG.MAX_VALUE

Alan Bateman Alan.Bateman at oracle.com
Tue Jun 4 18:15:28 UTC 2019


On 04/06/2019 18:13, Karan Mehta wrote:
> Hello everyone,
>
> Apache bookkeeper project uses Java NIO to read journal files from 
> disk. Recently a change was made that would seek the file to 
> LONG.MAX_VALUE. When we tried running this on a test inside a docker 
> container with openjdk:8-jdk image, it results in IOException. The 
> patch fix PR is here <https://github.com/apache/bookkeeper/pull/2105>. 
> Furthermore, running it inside the same container on different 
> hardware throws IOException either while seeking the file to 
> LONG.MAX_VALUE or when reading the file at that value as per the link 
> of the interface here 
> <https://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#position(long)>. 
> Checkout the comment here 
> <https://github.com/apache/bookkeeper/pull/2105#issuecomment-497583368>. 
> I am suspecting this to be a JNI related issue or bug. Let me know 
> what you all think and if there's any better way to figure this out.
I just checked this on macOS and Linux. macOS seems happy with lseek'ing 
to LONG.MAX_VALUE, Linux does not:

[pid 34168] lseek(4, 9223372036854775807, SEEK_SET) = -1 EINVAL (Invalid 
argument)

I see the man page on Linux includes "or beyond the end of a seekable 
device" in the possible reasons for EINVAL and I assume this is why it 
fails.

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


More information about the nio-dev mailing list