Skip to content

Commit 3f315d7

Browse files
YutSeanApache9
authored andcommitted
HBASE-26688 Threads shared EMPTY_RESULT may lead to unexpected client job down (#4073)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent a69e41d commit 3f315d7

File tree

2 files changed

+9
-9
lines changed
  • hbase-client/src/main/java/org/apache/hadoop/hbase/client
  • hbase-server/src/test/java/org/apache/hadoop/hbase/client

2 files changed

+9
-9
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ public CellScanner cellScanner() {
913913

914914
@Override
915915
public Cell current() {
916-
if (cells == null
916+
if (isEmpty()
917917
|| cellScannerIndex == INITIAL_CELLSCANNER_INDEX
918918
|| cellScannerIndex >= cells.length)
919919
return null;
@@ -922,7 +922,9 @@ public Cell current() {
922922

923923
@Override
924924
public boolean advance() {
925-
if (cells == null) return false;
925+
if (isEmpty()) {
926+
return false;
927+
}
926928
cellScannerIndex++;
927929
if (cellScannerIndex < this.cells.length) {
928930
return true;

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,12 @@ public void testCurrentOnEmptyCell() throws IOException {
125125
assertNull(r.current());
126126
}
127127

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

0 commit comments

Comments
 (0)