The RegionInfo class uses
to read the protobuf magic marker from the beginning of the stream.
The code in RegionInfo assumes that the passed byte buffer will be filled, but the DataInputStream class only guarantees that it will read at most lengthOfPBMagic bytes.
This sometimes causes errors stating that region info file could not be parsed.
The fix is to simply issue multiple read calls until lengthOfPBMagic bytes have been read.