-------- 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.
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.
- relates to
-
JDK-4494818 Pipe.SourceChannel.read - inconsistent behavior
-
- Closed
-