* ChannelBuffer.writeBytes(InputStream, ...) must return an integer
* Fixed a problem where DynamicChannelBuffer doesn't expand itself for some writeBytes() calls
This commit is contained in:
parent
1895864d38
commit
35b08df70a
@ -418,10 +418,13 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
writerIndex += length;
|
||||
}
|
||||
|
||||
public void writeBytes(InputStream in, int length)
|
||||
public int writeBytes(InputStream in, int length)
|
||||
throws IOException {
|
||||
setBytes(writerIndex, in, length);
|
||||
writerIndex += length;
|
||||
int writtenBytes = setBytes(writerIndex, in, length);
|
||||
if (writtenBytes > 0) {
|
||||
writerIndex += writtenBytes;
|
||||
}
|
||||
return writtenBytes;
|
||||
}
|
||||
|
||||
public int writeBytes(ScatteringByteChannel in, int length)
|
||||
|
@ -1228,12 +1228,14 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
||||
*
|
||||
* @param length the number of bytes to transfer
|
||||
*
|
||||
* @return the actual number of bytes read in from the specified stream
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if {@code length} is greater than {@code this.writableBytes}
|
||||
* @throws IOException
|
||||
* if the specified stream threw an exception during I/O
|
||||
*/
|
||||
void writeBytes(InputStream in, int length) throws IOException;
|
||||
int writeBytes(InputStream in, int length) throws IOException;
|
||||
|
||||
/**
|
||||
* Transfers the content of the specified channel to this buffer
|
||||
|
@ -216,6 +216,19 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
super.writeBytes(src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writeBytes(InputStream in, int length) throws IOException {
|
||||
ensureWritableBytes(length);
|
||||
return super.writeBytes(in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writeBytes(ScatteringByteChannel in, int length)
|
||||
throws IOException {
|
||||
ensureWritableBytes(length);
|
||||
return super.writeBytes(in, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeZero(int length) {
|
||||
ensureWritableBytes(length);
|
||||
|
@ -502,7 +502,7 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
public void writeBytes(InputStream in, int length) throws IOException {
|
||||
public int writeBytes(InputStream in, int length) throws IOException {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user