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

贡献者指南