akka/akka-core

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

開放

#24,402 建立於 2018年1月24日

 (1 則留言) (0 個反應) (0 位負責人)Scala (3,547 個分叉)batch import
1 - triagedhelp wantedt:core

倉庫指標

星標
 (13,277 顆星)
PR 合併指標
 (平均合併 8天 19小時) (30 天內合併 10 個 PR)

描述

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

貢獻者指南