Use the right ByteOrder for the ByteBuffer on read(..). See #484
This commit is contained in:
parent
95cf6a4a71
commit
40685a030d
@ -58,12 +58,13 @@ public class NioWorker extends AbstractNioWorker {
|
|||||||
final ReceiveBufferSizePredictor predictor =
|
final ReceiveBufferSizePredictor predictor =
|
||||||
channel.getConfig().getReceiveBufferSizePredictor();
|
channel.getConfig().getReceiveBufferSizePredictor();
|
||||||
final int predictedRecvBufSize = predictor.nextReceiveBufferSize();
|
final int predictedRecvBufSize = predictor.nextReceiveBufferSize();
|
||||||
|
final ChannelBufferFactory bufferFactory = channel.getConfig().getBufferFactory();
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int readBytes = 0;
|
int readBytes = 0;
|
||||||
boolean failure = true;
|
boolean failure = true;
|
||||||
|
|
||||||
ByteBuffer bb = recvBufferPool.get(predictedRecvBufSize);
|
ByteBuffer bb = recvBufferPool.get(predictedRecvBufSize).order(bufferFactory.getDefaultOrder());
|
||||||
try {
|
try {
|
||||||
while ((ret = ch.read(bb)) > 0) {
|
while ((ret = ch.read(bb)) > 0) {
|
||||||
readBytes += ret;
|
readBytes += ret;
|
||||||
@ -81,8 +82,6 @@ public class NioWorker extends AbstractNioWorker {
|
|||||||
if (readBytes > 0) {
|
if (readBytes > 0) {
|
||||||
bb.flip();
|
bb.flip();
|
||||||
|
|
||||||
final ChannelBufferFactory bufferFactory =
|
|
||||||
channel.getConfig().getBufferFactory();
|
|
||||||
final ChannelBuffer buffer = bufferFactory.getBuffer(readBytes);
|
final ChannelBuffer buffer = bufferFactory.getBuffer(readBytes);
|
||||||
buffer.setBytes(0, bb);
|
buffer.setBytes(0, bb);
|
||||||
buffer.writerIndex(readBytes);
|
buffer.writerIndex(readBytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user