akka/akka-core

ByteString byte order is not preserved or set when converting it to ByteBuffer

Aperta

#24.402 aperta il 24 gen 2018

 (1 commento) (0 reazioni) (0 assegnatari)Scala (3547 fork)batch import
1 - triagedhelp wantedt:core

Metriche repository

Star
 (13.277 stelle)
Metriche merge PR
 (Merge medio 8g 19h) (10 PR mergiate in 30 g)

Descrizione

As @ktoso suggested, creating this issue here.

When using ByteString.asByteBuffer it should set ByteOrder automatically. Having to set it as an implicit value as well as in ByteBuffer.order() seems too much work.

implicit val byteOrder: ByteOrder = ByteOrder.nativeOrder()
val bx = ByteString.createBuilder
bx.putInt(8)
val res = bx.result().asByteBuffer.duplicate()
res.order(byteOrder)
println(res.getInt) // prints 8 correctly

Guida contributor