FrameDecoder and ByteOrder

Trustin Lee tlee at redhat.com
Thu May 21 08:03:28 EDT 2009


Hi Denis,

Thanks for reporting the problem.  I found that FrameDecoder and
ReplayingDecoder creates its internal buffer too early, even before
your configuration attempt is made.  I checked in the fix that creates
the buffer only on demand so that you have a chance to configure the
buffer factory.  Revision 1294 in trunk should fix your problem.

If it still doesn't fix your problem, you might be using an
ExecutionHandler in the pipeline.  In such a case, please move the
configuration code to the 'channelOpen()' handler.

The most preferred way to configure the channel could be using
Bootstrap.setOption():

    serverBootstrap.setOption("child.bufferFactory", new
HeapChannelBufferFactory(ByteOrder.LITTLE_ENDIAN));
    ... or ...
    clientBootstrap.setOption("bufferFactory", new
HeapChannelBufferFactory(ByteOrder.LITTLE_ENDIAN));

Please let me know if the problem didn't go away.

Thanks,

— Trustin Lee, http://gleamynode.net/

On Tue, May 19, 2009 at 7:32 PM, DenisG2 <denis_konev at inbox.ru> wrote:
>
> Hi!
> I had a following problem with FrameDecoder:
> Data decoding demands ByteOrder.LITTLE_ENDIAN.
> I do in SimpleChannelHandler extension:
>
>
>   public void channelConnected(
>            ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
> {
>
>        e.getChannel().getConfig().setOption("bufferFactory", new
> HeapChannelBufferFactory(ByteOrder.LITTLE_ENDIAN));
>        ...
>
>
> Here a decoder part:
>
>
>    protected Object decode(
>            ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf)
> throws Exception {
>
>        System.out.println("buffer class: " + buf.getClass());
>        System.out.println("buffer byte order: " + buf.order());
>        ...
>        short addr = buf.readShort(); // in little endian
>        ...
>
>
> As a result to me comes LittleEndianHeapChannelBuffer only for the first
> time, and all subsequent times comes already DynamicChannelBuffer with
> ByteOrder.BIG_ENDIAN
>
> russian bear.
>
> --
> View this message in context: http://n2.nabble.com/FrameDecoder-and-ByteOrder-tp2938740p2938740.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>




More information about the netty-users mailing list