RFC on java/nio/channels/FileChannel/InterruptDeadlock.java

Daniel Fuchs daniel.fuchs at oracle.com
Wed Mar 1 08:01:22 UTC 2017


Hi Brian,

Your proposed change looks reasonable to me.

I doubt that it is related to [1] though.
Or if it is, then it might be better not do the change ;-(

As a measure of safety did you verify the test worked as expected
after making the change?

best regards,

-- daniel

On 28/02/17 22:43, Brian Burkhalter wrote:
> 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