Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-26705 Backport HBASE-26688 to branch-1 #4061

Merged
merged 3 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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