Oh, I think I see the issue. (.array buf) returns the backing array,
which is not necessarily the same dimension as the buffer. If, for
instance, you trim off the first four bytes, the backing array will
still contain them.
I'm looking at the implementation in aleph.formats, and it also has
this same bug, so I apologize if that's where you were getting the
approach from. It should look like:
(let [ary (byte-array (.remaining buf))]
(.get buf ary)
ary)
I'll be fixing aleph.formats to reflect this.
Zach