RFC on java/nio/channels/FileChannel/InterruptDeadlock.java
Brian Burkhalter
brian.burkhalter at oracle.com
Tue Feb 28 22:43:22 UTC 2017
I don’t know whether [1] could be related to this, but it looks to me as if the test InterruptDeadlock.java is incorrect at line 61 [2]. It appears that the value of pos will reach fc.size() which is 1024*1024 + 1 and remain there for all subsequent iterations of the loop in which case fc.read() at line 57 would no longer read any bytes. It seems that the greater-than (>) at line 61 should instead be greater-than-or-equal (>=). This would be consistent with the specification of FileChannel.read(ByteBuffer,long) [3] which states that it will return -1 if the position is greater than or equal to the file’s current size.
Thanks,
Brian
[1] https://bugs.openjdk.java.net/browse/JDK-8151862
[2] http://hg.openjdk.java.net/jdk9/dev/jdk/file/49b54a4d9e84/test/java/nio/channels/FileChannel/InterruptDeadlock.java#l51
[3] http://download.java.net/java/jdk9/docs/api/java/nio/channels/FileChannel.html#read-java.nio.ByteBuffer-long-
More information about the nio-dev
mailing list