Skip to content

Commit

Permalink
Try fix readerIndex > writerIndex again
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Aug 11, 2024
1 parent 9259fa8 commit fb68104
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ public Type<? extends CustomPacketPayload> type() {
public void encode(ByteBuf dest, Payload src) {
src.buffer.readerIndex(0);
dest.writeInt(src.buffer.readableBytes());
dest.writeBytes(src.buffer);
dest.writeBytes(src.buffer, 0, src.buffer.readableBytes());
}

@Override
public Payload decode(ByteBuf src) {
final int length = src.readInt();
FriendlyByteBuf result = new FriendlyByteBuf(src.readBytes(length));
result.readerIndex(0);
return new Payload(result);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ public Type<? extends CustomPacketPayload> type() {
public void encode(ByteBuf dest, Payload src) {
src.buffer.readerIndex(0);
dest.writeInt(src.buffer.readableBytes());
dest.writeBytes(src.buffer);
dest.writeBytes(src.buffer, 0, src.buffer.readableBytes());
}

@Override
public Payload decode(ByteBuf src) {
final int length = src.readInt();
FriendlyByteBuf result = new FriendlyByteBuf(src.readBytes(length));
result.readerIndex(0);
return new Payload(result);
}
};
Expand Down

0 comments on commit fb68104

Please sign in to comment.