HBASE-25859 Reference class incorrectly parses the protobuf magic marker (#3236)
Co-authored-by: Catalin Luca <luca@adobe.com> Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
8c2332d465
commit
2b6a91a1da
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
@ -174,10 +175,7 @@ public class Reference {
|
||||||
int pblen = ProtobufUtil.lengthOfPBMagic();
|
int pblen = ProtobufUtil.lengthOfPBMagic();
|
||||||
in.mark(pblen);
|
in.mark(pblen);
|
||||||
byte [] pbuf = new byte[pblen];
|
byte [] pbuf = new byte[pblen];
|
||||||
int read = in.read(pbuf);
|
IOUtils.readFully(in, pbuf,0, pblen);
|
||||||
if (read != pblen) {
|
|
||||||
throw new IOException("read=" + read + ", wanted=" + pblen);
|
|
||||||
}
|
|
||||||
// WATCHOUT! Return in middle of function!!!
|
// WATCHOUT! Return in middle of function!!!
|
||||||
if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in));
|
if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in));
|
||||||
// Else presume Writables. Need to reset the stream since it didn't start w/ pb.
|
// Else presume Writables. Need to reset the stream since it didn't start w/ pb.
|
||||||
|
|
Loading…
Reference in New Issue