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

Pipe.SourceChannel.read in blocking mode returns -1 when reading zero bytes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • beta2
    • sparc
    • solaris_7
    • Verified

      -------- test code --------
      java.nio.channels.Pipe pipe = Pipe.open();
      Pipe.SourceChannel sourcechannel = pipe.source();
      Pipe.SinkChannel sinkchannel = pipe.sink();
      byte[] data = {} ;
      ByteBuffer dstBuffer = ByteBuffer.allocate(data.length) ;
      int bytesWritten = sinkchannel.write(ByteBuffer.wrap(data));
      System.out.println("bytesWritten:" + bytesWritten);
      int bytesRead = sourcechannel.read(dstBuffer);
      System.out.println("bytesRead:" + bytesRead);

      // PipeChannel:LoopBackTest01()
      ----------- results --------
      bytesWritten:0
      bytesRead:-1
      ----------------------------

      This is incosisitent with the spec. ReadableByteChannel.read:
      "It is guaranteed, however, that unless a channel is in non-blocking mode an invocation of this method will block until at least one byte can be read."


      Merlin Beta build B-74.

      Fails on Solaris, Linux, Windows NT.
      This call however blocks on Windows 2000.


            mmcclosksunw Michael Mccloskey (Inactive)
            hvilekar Harshad Vilekar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: