[#1717] Perform a copy if Netty isn't using a direct address for any reason.
This commit is contained in:
parent
a0f2c42d38
commit
8490d611bf
@ -11,6 +11,8 @@ import java.util.List;
|
|||||||
public class Varint21FrameDecoder extends ByteToMessageDecoder
|
public class Varint21FrameDecoder extends ByteToMessageDecoder
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static boolean DIRECT_WARNING;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
|
||||||
{
|
{
|
||||||
@ -40,8 +42,22 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
out.add( in.slice( in.readerIndex(), length ).retain() );
|
if ( in.hasMemoryAddress() )
|
||||||
in.skipBytes( length );
|
{
|
||||||
|
out.add( in.slice( in.readerIndex(), length ).retain() );
|
||||||
|
in.skipBytes( length );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if ( !DIRECT_WARNING )
|
||||||
|
{
|
||||||
|
DIRECT_WARNING = true;
|
||||||
|
System.err.println( "[WARN] Netty is not using direct IO buffers." );
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuf dst = ctx.alloc().directBuffer( length );
|
||||||
|
in.readBytes( dst );
|
||||||
|
out.add( dst );
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user