The ChannelBufferInputStream.available() method is:
@Override
public int available() throws IOException {
return endIndex - buffer.readerIndex();
}
Wouldn't this break if you write to the buffer after the input stream has been initialized?
Shouldn't this actually be
return buffer.writerIndex() - buffer.readerIndex();
I am trying to do something like this: Initialize the buffers and streams and read/write to the ChannelBuffer. What am I missing here?
final ChannelBuffer _channelBuffer = ChannelBuffers.dynamicBuffer();
final ChannelBufferOutputStream _outputStream = new ChannelBufferOutputStream(_channelBuffer);
final ChannelBufferInputStream _inputStream = new ChannelBufferInputStream(_channelBuffer);
Edit: According to the constructor documentation of ChannelBufferedInputStream: "Creates a new stream which reads data from the specified buffer starting at the current readerIndex and ending at the current writerIndex."
In that case it makes sense. But is there a way to achieve what I am trying to do? Have a single backed buffer and the read operation waits for the write operation to complete.