[#1920] Fix IndexOutOfBoundsException when using PooledByteBufAllocator with SCTP and NIO Datagram channels
This commit is contained in:
parent
ef139306af
commit
da1418e269
@ -274,14 +274,14 @@ public class NioSctpChannel extends AbstractNioMessageChannel implements io.nett
|
||||
ByteBuf buffer = allocHandle.allocate(config().getAllocator());
|
||||
boolean free = true;
|
||||
try {
|
||||
ByteBuffer data = buffer.nioBuffer(buffer.writerIndex(), buffer.writableBytes());
|
||||
ByteBuffer data = buffer.internalNioBuffer(buffer.writerIndex(), buffer.writableBytes());
|
||||
int pos = data.position();
|
||||
|
||||
MessageInfo messageInfo = ch.receive(data, null, notificationHandler);
|
||||
if (messageInfo == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data.flip();
|
||||
buf.add(new SctpMessage(messageInfo, buffer.writerIndex(buffer.writerIndex() + data.remaining())));
|
||||
buf.add(new SctpMessage(messageInfo, buffer.writerIndex(buffer.writerIndex() + (data.position() - pos))));
|
||||
free = false;
|
||||
return 1;
|
||||
} catch (Throwable cause) {
|
||||
|
@ -205,14 +205,14 @@ public final class NioDatagramChannel
|
||||
ByteBuf data = allocHandle.allocate(config.getAllocator());
|
||||
boolean free = true;
|
||||
try {
|
||||
ByteBuffer nioData = data.nioBuffer(data.writerIndex(), data.writableBytes());
|
||||
|
||||
ByteBuffer nioData = data.internalNioBuffer(data.writerIndex(), data.writableBytes());
|
||||
int pos = nioData.position();
|
||||
InetSocketAddress remoteAddress = (InetSocketAddress) ch.receive(nioData);
|
||||
if (remoteAddress == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int readBytes = nioData.position();
|
||||
int readBytes = nioData.position() - pos;
|
||||
data.writerIndex(data.writerIndex() + readBytes);
|
||||
allocHandle.record(readBytes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user