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

(ch) Scattering reads to a subsequence of buffers ignores length

XMLWordPrintable

    • b32
    • Verified

      Below method seems to be ignoring the length value passed to it. This code change was made when Direct I/O support was added.

      src/java.base/share/classes/sun/nio/ch/IOUtil.java


          static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length,
                           NativeDispatcher nd)
              throws IOException
          {
              return read(fd, bufs, offset, bufs.length, false, -1, nd);
          }

      Internal user reporting issue :
      ====
      Whereas before, the length variable was being used. Now in our case, we are passing an array in bufs, whose length is 2, the first element is not null, second element is null, but the length we pass is 1.

      now even though the length being passed is 1, bufs.length is being taken, since the second element is null, a NullPointerException is being thrown in the line "if (buf.isReadOnly())"
      ====

            bpb Brian Burkhalter
            coffeys Sean Coffey
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: