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

(ch) Channels.newChannel({In|Out}putStream) missing null check

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • core-libs
    • None
    • b39
    • generic
    • generic

      The method Channels.newChannel() does not throw NullPointerException on null input.

      public class ChannelsNewChannelTest {
           public static void main(String[] args) throws Exception {
      ReadableByteChannel channel = Channels.newChannel((InputStream)null);
      ByteBuffer buffer = ByteBuffer.allocate(100);
      channel.read(buffer);
           }
      }

      OUTPUT:
      Exception in thread "main" java.lang.NullPointerException
               at
      java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:196)
               at ChannelsNewChannelTest.main(ChannelsNewChannelTest.java:16)


      The exception should be thrown by Channels.newChannel((InputStream)null), not read().

      A similar problem exists for Channels.newChannel((OutputStream)null).

      ###@###.### 2005-03-31 20:41:56 GMT

            sjiang Shanliang Jiang (Inactive)
            iris Iris Clark
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: