Skip to content

Commit

Permalink
HBASE-26705 Backport HBASE-26688 to branch-1 (#4061)
Browse files Browse the repository at this point in the history
* HBASE-26705 Backport HBASE-26688 to branch-1

* Remove TestResult#testAdvanceTwiceOnEmptyCell

* Added unit test
  • Loading branch information
YutSean authored Feb 24, 2022
1 parent 09fbf75 commit 5b26932
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ public CellScanner cellScanner() {

@Override
public Cell current() {
if (cells == null
if (isEmpty()
|| cellScannerIndex == INITIAL_CELLSCANNER_INDEX
|| cellScannerIndex >= cells.length)
return null;
Expand All @@ -975,7 +975,9 @@ public Cell current() {

@Override
public boolean advance() {
if (cells == null) return false;
if (isEmpty()) {
return false;
}
cellScannerIndex++;
if (cellScannerIndex < this.cells.length) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,12 @@ public void testCurrentOnEmptyCell() throws IOException {
assertNull(r.current());
}

public void testAdvanceTwiceOnEmptyCell() throws IOException {
public void testAdvanceMultipleOnEmptyCell() throws IOException {
Result r = Result.create(new Cell[0]);
assertFalse(r.advance());
try {
r.advance();
fail("NoSuchElementException should have been thrown!");
} catch (NoSuchElementException ex) {
LOG.debug("As expected: " + ex.getMessage());
// After HBASE-26688, advance of result with empty cell list will always return false.
// Here 10 is an arbitrary number to test the logic.
for (int i = 0; i < 10; i++) {
assertFalse(r.advance());
}
}

Expand Down

0 comments on commit 5b26932

Please sign in to comment.