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

(ch) ReadableByteChannel returned by Channels.newChannel(InputStream) throws ReadOnlyBufferException

XMLWordPrintable

    • b20
    • generic
    • generic
    • Verified

      Such a ReadableByteChannel should throw an IllegalArgumentException. This may be demonstrated by modifying java/nio/channels/Channels/Basic.java as:

      @@ -296,6 +296,12 @@ public class Basic {
               byte data[] = new byte[messageSize+1];
               ByteBuffer bb = ByteBuffer.wrap(data);
       
      + try {
      + rbc.read(bb.asReadOnlyBuffer());
      + } catch (IllegalArgumentException expected) {
      + // ignore it
      + }
      +
               int bytesRead = 0;
               int totalRead = 0;
               while (bytesRead != -1) {

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

              Created:
              Updated:
              Resolved: