NioDatagramChannel invalid usage of internalNioBuffer
Motivation: NioDatagramChannel attempts to unpack a AddressedEnvelope and unconditionally uses internalNioBuffer. However if the ByteBuf is a CompositeByteBuf with more than 1 components, the write will fail and throw an exception. Modifications: - NioDatagramChannel should check the nioBufferCount before attempting to use internalNioBuffer Result: No more failure to write UDP packets on NIO when a CompositeByteBuf is used.
This commit is contained in:
parent
8b273983f0
commit
7928a6fef3
@ -286,7 +286,8 @@ public final class NioDatagramChannel
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ByteBuffer nioData = data.internalNioBuffer(data.readerIndex(), dataLen);
|
final ByteBuffer nioData = data.nioBufferCount() == 1 ? data.internalNioBuffer(data.readerIndex(), dataLen)
|
||||||
|
: data.nioBuffer(data.readerIndex(), dataLen);
|
||||||
final int writtenBytes;
|
final int writtenBytes;
|
||||||
if (remoteAddress != null) {
|
if (remoteAddress != null) {
|
||||||
writtenBytes = javaChannel().send(nioData, remoteAddress);
|
writtenBytes = javaChannel().send(nioData, remoteAddress);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user