Thrift type bytes currently gets generated as a java.nio.ByteBuffer. This type is mutable and if not careful defensive copying is used reading it changes it's internal position in the array. It supports asReadonlyBuffer but that can't be used if the bytes are sent via Thrift to clients, I see a java.nio.ReadOnlyBufferException thrown if done like that.
So to make this less painful I'd like Scrooge to support this type to be an io.twitter.util.Buf via configuration. Probably as the shared version.
Our workaround right now is defensive copying on the byte array itself or directly use list<byte> in Thrift but it feels like a workaround to me but i'm pretty new on this...
Thrift type
bytescurrently gets generated as ajava.nio.ByteBuffer. This type is mutable and if not careful defensive copying is used reading it changes it's internal position in the array. It supportsasReadonlyBufferbut that can't be used if the bytes are sent via Thrift to clients, I see ajava.nio.ReadOnlyBufferExceptionthrown if done like that.So to make this less painful I'd like Scrooge to support this type to be an
io.twitter.util.Bufvia configuration. Probably as the shared version.Our workaround right now is defensive copying on the byte array itself or directly use
list<byte>in Thrift but it feels like a workaround to me but i'm pretty new on this...