You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/02/15 12:38:20 UTC
[hbase] branch branch-2.5 updated: HBASE-26688 Threads shared EMPTY_RESULT may lead to unexpected client job down (#4073)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new 3803b8b HBASE-26688 Threads shared EMPTY_RESULT may lead to unexpected client job down (#4073)
3803b8b is described below
commit 3803b8be2c3e813bc55e32ee190f95af2d3141ba
Author: Yutong Xiao <yu...@gmail.com>
AuthorDate: Tue Feb 15 20:28:00 2022 +0800
HBASE-26688 Threads shared EMPTY_RESULT may lead to unexpected client job down (#4073)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../src/main/java/org/apache/hadoop/hbase/client/Result.java | 6 ++++--
.../test/java/org/apache/hadoop/hbase/client/TestResult.java | 12 +++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index 1ef1633..46b5963 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -913,7 +913,7 @@ public class Result implements CellScannable, CellScanner {
@Override
public Cell current() {
- if (cells == null
+ if (isEmpty()
|| cellScannerIndex == INITIAL_CELLSCANNER_INDEX
|| cellScannerIndex >= cells.length)
return null;
@@ -922,7 +922,9 @@ public class Result implements CellScannable, CellScanner {
@Override
public boolean advance() {
- if (cells == null) return false;
+ if (isEmpty()) {
+ return false;
+ }
cellScannerIndex++;
if (cellScannerIndex < this.cells.length) {
return true;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java
index e763aa6..5d9566b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java
@@ -132,14 +132,12 @@ public class TestResult {
}
@Test
- 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());
}
}