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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P4
    • Resolution: Fixed
    • 18
    • 18
    • core-libs
    • b20
    • generic
    • generic
    • Verified

    Description

      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) {

      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: