MultiByteBuff.put(int destOffset, ByteBuff src, int srcOffset, int length) has some obvious bugs:
- It seems mix up items in src MutiByteBuff and items in the dest MultiByteBuff , just as line 749 and line 754 illustrated. The logic is only right when src ByteBuff is also a MultiByteBuff and byte size of every ByteBuffer in src.items has exactly the same size as every ByteBuffer in the dest.items,but looking the usage of this method in the hbase project, obviously the assumption is not right.
- If src is SingleByteBuff and its remaining space is fewer than length，when remaining space is exhausted, this MultiByteBuff.put method would not throw any exception and continue to put src ByteBuff once again from position 0 because following MultiByteBuff.getItemByteBuffer ignores index paramter for SingleByteBuff . Obviously, this behavior is much strange and unexpected.
Why seems tests is OK with too much bugs? Because in normal cases, we just use SingleByteBuff not MultiByteBuff.