Skip to content

Commit

Permalink
HBASE-25859 Reference class incorrectly parses the protobuf magic mar…
Browse files Browse the repository at this point in the history
…ker (#3236)

Co-authored-by: Catalin Luca <luca@adobe.com>
Signed-off-by: stack <stack@apache.org>
  • Loading branch information
2 people authored and saintstack committed May 10, 2021
1 parent 63d49cb commit 4e507cc
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.InputStream;
import java.util.Arrays;

import org.apache.commons.io.IOUtils;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
Expand Down Expand Up @@ -174,10 +175,7 @@ public static Reference read(final FileSystem fs, final Path p)
int pblen = ProtobufUtil.lengthOfPBMagic();
in.mark(pblen);
byte [] pbuf = new byte[pblen];
int read = in.read(pbuf);
if (read != pblen) {
throw new IOException("read=" + read + ", wanted=" + pblen);
}
IOUtils.readFully(in, pbuf,0, pblen);
// WATCHOUT! Return in middle of function!!!
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.
Expand Down

0 comments on commit 4e507cc

Please sign in to comment.