Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8176394

Incorrect relational operator in java/nio/channels/FileChannel/InterruptDeadlock.java

    XMLWordPrintable

Details

    • b161

    Backports

      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 ">=".

        Attachments

          Issue Links

            Activity

              People

                bpb Brian Burkhalter
                bpb Brian Burkhalter
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: