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

(ch) ReadableByteChannel should note a possible IllegalArgumentException

XMLWordPrintable

    • b25
    • generic
    • generic

      A DESCRIPTION OF THE REQUEST :
      In the interface java.nio.channels.ReadableByteChannel, the read() method takes a ByteBuffer as an argument and writes the result of reading from the channel into the ByteBuffer. However, none of the error conditions noted in the documentation for this function consider the possibility that the ByteBuffer passed as an argument could be read-only, which would throw a ReadOnlyBufferException.

      JUSTIFICATION :
      Documenting this possible error condition would make it clearer that a read-only ByteBuffer should not be passed to the function and could perhaps prompt programmers to check or be certain that ByteBuffers they pass for reading are not read-only.

      Perhaps some wording in the comment alluding to the fact that the argument should not be a read-only ByteBuffer would probably be sufficient to serve this purpose.


            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: