AndrewBourgeois
AndrewBourgeois

Reputation: 2765

netty 4: set default endianness of ByteBuf

Is there a way to tell Netty 4 that all ByteBuf instances it creates should have LITTLE_ENDIAN endianness?

Calling order(ByteOrder) in every handler is annoying.

It looks like Netty 3 supported this: Netty and ByteOrder

Upvotes: 1

Views: 1056

Answers (1)

parsifal
parsifal

Reputation: 646

I wouldn't expect one: big-endian is the ordering of network protocols, so makes sense as the default. And exposing a static variable to set the default would be an invitation for hard-to-diagnose bugs (particularly in a shared server).

I think your best approach is to create a new factory class, to produce the buffers you need. Assuming that you're currently using Unpooled (per recommendation), it should be a simple search-and replace operation.

You could also update Unpooled itself, providing variants that take a byte-order param, and submit it back to the project.

Upvotes: 2

Related Questions