JDK-8176394 : Incorrect relational operator in java/nio/channels/FileChannel/InterruptDeadlock.java
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-03-08
  • Updated: 2017-03-20
  • Resolved: 2017-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9 b161Fixed
Related Reports
Relates :  
Description
In this test there is a loop

                long pos = 0L;
                for (;;) {
                    bb.clear();
                    int n = fc.read(bb, pos);
                    if (n > 0)
                        pos += n;
                    // fc.size is important here as it is position sensitive
                    if (pos > fc.size()) // incorrect relational operator: should be >=
                        pos = 0L;
                }

which is supposed to read continuously from a FileChannel. This will not happen however because 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() would no longer read any bytes. The relational operator ">" should be changed to ">=".