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 Andrew Purtell
parent ef412ceea2
commit 332575fa22
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
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.
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;
@ -269,7 +269,8 @@ public class HalfStoreFileReader extends StoreFileReader {
public boolean seekBefore(Cell key) throws IOException {
if (top) {
Optional<Cell> fk = getFirstKey();
if (PrivateCellUtil.compareKeyIgnoresMvcc(getComparator(), key, fk.get()) <= 0) {
if (fk.isPresent() &&
PrivateCellUtil.compareKeyIgnoresMvcc(getComparator(), key, fk.get()) <= 0) {
return false;
}
} else {