Skip to content

Commit 183aae3

Browse files
virajjasaniapurtell
authored andcommitted
HBASE-22520 Avoid possible NPE while performing seekBefore in Hal… (#281)
HBASE-22520 Avoid possible NPE while performing seekBefore in HalfStoreFileReader
1 parent bc737d1 commit 183aae3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/io/HalfStoreFileReader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ public class HalfStoreFileReader extends StoreFileReader {
6060
// i.e. empty column and a timestamp of LATEST_TIMESTAMP.
6161
protected final byte [] splitkey;
6262

63-
protected final Cell splitCell;
63+
private final Cell splitCell;
6464

65-
private Optional<Cell> firstKey = null;
65+
private Optional<Cell> firstKey = Optional.empty();
6666

6767
private boolean firstKeySeeked = false;
6868

@@ -269,7 +269,8 @@ public int reseekTo(Cell key) throws IOException {
269269
public boolean seekBefore(Cell key) throws IOException {
270270
if (top) {
271271
Optional<Cell> fk = getFirstKey();
272-
if (PrivateCellUtil.compareKeyIgnoresMvcc(getComparator(), key, fk.get()) <= 0) {
272+
if (fk.isPresent() &&
273+
PrivateCellUtil.compareKeyIgnoresMvcc(getComparator(), key, fk.get()) <= 0) {
273274
return false;
274275
}
275276
} else {

0 commit comments

Comments
 (0)