Closed pepijnve closed 6 years ago
The assumption is that buffer is filled outside and then passed to the encode method, like:
Xdr xdr = ...;
ButeByffer buf = ...;
but.put(....);
xdr. xdrEncodeByteBuffer(buf);
Does it makes sense? To me it works as designed, but documentation is missing of course.
Typically you work with Buffer as in WritableByteChannel.html#write. In other words, the caller does the flip and the consumer consumes as many bytes as reported by remaining
.
I can get it to work, it's just a bit surprising and makes certain usages impossible.
Well, if you have a use case, then we can change the behavior. I just check the places where we use it and it's not an issue for us to adjust our code.
@paulmillar What do you think about it? Shall we change the behavior and if yes, shall we fix it in 3.0 (which I have tagged today)? To it it looks like was a bad design decision to flip in xdrEncodeByteBuffer
Sounds OK to me
@pepijnve Today we have release 3.0.1 which includes desired change.
That was fast. Thanks!
Xdr#xdrEncodeByteBuffer
callsBuffer#flip
on the input parameter before using it. This is rather surprising sinceBuffer
based APIs normally use the position and limit of aBuffer
to communicate which range of data should be used. Callingflip
on the buffer makes it impossible to use any other position than 0. Is this intentional or a bug?