diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java index 3bd911fedf6..51c697cafa5 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java @@ -119,7 +119,7 @@ public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { // careful byte[] data = new byte[length]; buffer.getBytes(srcIndex, data, 0, length); - setBytes(0, data, index, length); + setBytes(index, data, 0, length); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java index c6e0c6ddee1..2c00e9499e2 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java @@ -37,13 +37,13 @@ public NettyBackedChannelBuffer(ByteBuf buffer) { this.buffer = buffer; } - + @Override public int capacity() { return buffer.capacity(); } - + @Override public ChannelBuffer copy(int index, int length) { return new NettyBackedChannelBuffer(buffer.copy(index, length)); @@ -55,25 +55,25 @@ public ChannelBufferFactory factory() { return null; } - + @Override public byte getByte(int index) { return buffer.getByte(index); } - + @Override public void getBytes(int index, byte[] dst, int dstIndex, int length) { buffer.getBytes(index, dst, dstIndex, length); } - + @Override public void getBytes(int index, ByteBuffer dst) { buffer.getBytes(index, dst); } - + @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { // careful @@ -82,70 +82,70 @@ public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { dst.setBytes(dstIndex, data, 0, length); } - + @Override public void getBytes(int index, OutputStream dst, int length) throws IOException { buffer.getBytes(index, dst, length); } - + @Override public boolean isDirect() { return buffer.isDirect(); } - + @Override public void setByte(int index, int value) { buffer.setByte(index, value); } - + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { buffer.setBytes(index, src, srcIndex, length); } - + @Override public void setBytes(int index, ByteBuffer src) { buffer.setBytes(index, src); } - + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { // careful byte[] data = new byte[length]; buffer.getBytes(srcIndex, data, 0, length); - setBytes(0, data, index, length); + setBytes(index, data, 0, length); } - + @Override public int setBytes(int index, InputStream src, int length) throws IOException { return buffer.setBytes(index, src, length); } - + @Override public ByteBuffer toByteBuffer(int index, int length) { return buffer.nioBuffer(index, length); } - + @Override public byte[] array() { return buffer.array(); } - + @Override public boolean hasArray() { return buffer.hasArray(); } - + @Override public int arrayOffset() { return buffer.arrayOffset(); @@ -155,44 +155,44 @@ public int arrayOffset() { // AbstractChannelBuffer - + @Override public void clear() { buffer.clear(); } - + @Override public ChannelBuffer copy() { return new NettyBackedChannelBuffer(buffer.copy()); } - + @Override public void discardReadBytes() { buffer.discardReadBytes(); } - + @Override public void ensureWritableBytes(int writableBytes) { buffer.ensureWritable(writableBytes); } - + @Override public void getBytes(int index, byte[] dst) { buffer.getBytes(index, dst); } - + @Override public void getBytes(int index, ChannelBuffer dst) { // careful getBytes(index, dst, dst.writableBytes()); } - + @Override public void getBytes(int index, ChannelBuffer dst, int length) { // careful @@ -203,62 +203,62 @@ public void getBytes(int index, ChannelBuffer dst, int length) { dst.writerIndex(dst.writerIndex() + length); } - + @Override public void markReaderIndex() { buffer.markReaderIndex(); } - + @Override public void markWriterIndex() { buffer.markWriterIndex(); } - + @Override public boolean readable() { return buffer.isReadable(); } - + @Override public int readableBytes() { return buffer.readableBytes(); } - + @Override public byte readByte() { return buffer.readByte(); } - + @Override public void readBytes(byte[] dst) { buffer.readBytes(dst); } - + @Override public void readBytes(byte[] dst, int dstIndex, int length) { buffer.readBytes(dst, dstIndex, length); } - + @Override public void readBytes(ByteBuffer dst) { buffer.readBytes(dst); } - + @Override public void readBytes(ChannelBuffer dst) { // careful readBytes(dst, dst.writableBytes()); } - + @Override public void readBytes(ChannelBuffer dst, int length) { // careful @@ -269,7 +269,7 @@ public void readBytes(ChannelBuffer dst, int length) { dst.writerIndex(dst.writerIndex() + length); } - + @Override public void readBytes(ChannelBuffer dst, int dstIndex, int length) { // careful @@ -281,56 +281,56 @@ public void readBytes(ChannelBuffer dst, int dstIndex, int length) { dst.setBytes(dstIndex, data, 0, length); } - + @Override public ChannelBuffer readBytes(int length) { return new NettyBackedChannelBuffer(buffer.readBytes(length)); } - + @Override public void resetReaderIndex() { buffer.resetReaderIndex(); } - + @Override public void resetWriterIndex() { buffer.resetWriterIndex(); } - + @Override public int readerIndex() { return buffer.readerIndex(); } - + @Override public void readerIndex(int readerIndex) { buffer.readerIndex(readerIndex); } - + @Override public void readBytes(OutputStream dst, int length) throws IOException { buffer.readBytes(dst, length); } - + @Override public void setBytes(int index, byte[] src) { buffer.setBytes(index, src); } - + @Override public void setBytes(int index, ChannelBuffer src) { // careful setBytes(index, src, src.readableBytes()); } - + @Override public void setBytes(int index, ChannelBuffer src, int length) { // careful @@ -341,68 +341,68 @@ public void setBytes(int index, ChannelBuffer src, int length) { src.readerIndex(src.readerIndex() + length); } - + @Override public void setIndex(int readerIndex, int writerIndex) { buffer.setIndex(readerIndex, writerIndex); } - + @Override public void skipBytes(int length) { buffer.skipBytes(length); } - + @Override public ByteBuffer toByteBuffer() { return buffer.nioBuffer(); } - + @Override public boolean writable() { return buffer.isWritable(); } - + @Override public int writableBytes() { return buffer.writableBytes(); } - + @Override public void writeByte(int value) { buffer.writeByte(value); } - + @Override public void writeBytes(byte[] src) { buffer.writeBytes(src); } - + @Override public void writeBytes(byte[] src, int index, int length) { buffer.writeBytes(src, index, length); } - + @Override public void writeBytes(ByteBuffer src) { buffer.writeBytes(src); } - + @Override public void writeBytes(ChannelBuffer src) { // careful writeBytes(src, src.readableBytes()); } - + @Override public void writeBytes(ChannelBuffer src, int length) { // careful @@ -413,7 +413,7 @@ public void writeBytes(ChannelBuffer src, int length) { src.readerIndex(src.readerIndex() + length); } - + @Override public void writeBytes(ChannelBuffer src, int srcIndex, int length) { // careful @@ -422,25 +422,25 @@ public void writeBytes(ChannelBuffer src, int srcIndex, int length) { writeBytes(data, 0, length); } - + @Override public int writeBytes(InputStream src, int length) throws IOException { return buffer.writeBytes(src, length); } - + @Override public int writerIndex() { return buffer.writerIndex(); } - + @Override public void writerIndex(int writerIndex) { buffer.writerIndex(writerIndex); } - + @Override public int compareTo(ChannelBuffer o) { return ChannelBuffers.compare(this, o);