HBASE-22520 Avoid possible NPE while performing seekBefore in Hal… (#281)

HBASE-22520 Avoid possible NPE while performing seekBefore in HalfStoreFileReader
This commit is contained in:
virajjasani 2019-06-07 04:13:36 +05:30 committed by Michael Stack
parent 6ea2566ac3
commit 13c5af38da
1 changed files with 4 additions and 3 deletions

View File

@ -60,9 +60,9 @@ public class HalfStoreFileReader extends StoreFileReader {
// i.e. empty column and a timestamp of LATEST_TIMESTAMP. // i.e. empty column and a timestamp of LATEST_TIMESTAMP.
protected final byte [] splitkey; protected final byte [] splitkey;
protected final Cell splitCell; private final Cell splitCell;
private Optional<Cell> firstKey = null; private Optional<Cell> firstKey = Optional.empty();
private boolean firstKeySeeked = false; private boolean firstKeySeeked = false;
@ -269,7 +269,8 @@ public class HalfStoreFileReader extends StoreFileReader {
public boolean seekBefore(Cell key) throws IOException { public boolean seekBefore(Cell key) throws IOException {
if (top) { if (top) {
Optional<Cell> fk = getFirstKey(); Optional<Cell> fk = getFirstKey();
if (PrivateCellUtil.compareKeyIgnoresMvcc(getComparator(), key, fk.get()) <= 0) { if (fk.isPresent() &&
PrivateCellUtil.compareKeyIgnoresMvcc(getComparator(), key, fk.get()) <= 0) {
return false; return false;
} }
} else { } else {