Nashatyrev commented on issue #88:
URL: https://github.com/apache/incubator-tuweni/issues/88#issuecomment-658412055


   > These are not features of the Bytes implementation in Tuweni
   
   And this is exactly the reason why I would expect from `Bytes` to wrap only 
readable `ByteBuf` content
   
   > Given Netty provides methods to present just the "readable" bytes as a 
ByteBuf, e.g. `Unpooled.wrappedBuffer(byteBuf)`
   
   `Unpooled.wrappedBuffer(byteBuf)` is actually was just an example. It is 
normally used to 'concat' several `ButeBuf`s. And it concats only readable 
bytes. 
   
   It is absolutely regular use case for Netty to receive a wire frame in a 
`ByteBuf` e.g. `| header | payload |` and then a lower-level decoder reads the 
header and then passes the same `ByteBuf` to a higher-level decoder with a 
`readerIndex` positioned to the beginning of  `| payload |` and the 
higher-level decoder treat that `ByteBuf` exactly as just only `| payload |`. 
   So in that case I would expect `Bytes.wrapByteBuf()` to return only payload 
bytes.
   
   You may also check Google results on ["netty bytebuf to 
array"](https://www.google.com/search?client=firefox-b-d&q=netty+bytebuf+to+array)
   
   If you think the existing behavior is the one which is expected (or may be 
already relied on by other libs), I would add a Javadoc comment and and an 
alternative method which wraps the `ByteBuf` readable contents only. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tuweni.apache.org
For additional commands, e-mail: dev-h...@tuweni.apache.org

Reply via email to