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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 1.4.0
    • Affects Version/s: 1.4.0
    • Component/s: 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.


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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: