HBASE-26901 delete with null columnQualifier occurs NullPointerException when NewVersionBehavior is on (#4295)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
(cherry picked from commit 7ac9e0be27
)
This commit is contained in:
parent
43af814d1a
commit
f4ec10b958
|
@ -165,9 +165,7 @@ public class NewVersionBehaviorTracker implements ColumnTracker, DeleteTracker {
|
|||
* Else return MAX_VALUE.
|
||||
*/
|
||||
protected long prepare(Cell cell) {
|
||||
boolean matchCq =
|
||||
PrivateCellUtil.matchingQualifier(cell, lastCqArray, lastCqOffset, lastCqLength);
|
||||
if (!matchCq) {
|
||||
if (isColumnQualifierChanged(cell)) {
|
||||
// The last cell is family-level delete and this is not, or the cq is changed,
|
||||
// we should construct delColMap as a deep copy of delFamMap.
|
||||
delColMap.clear();
|
||||
|
@ -175,8 +173,7 @@ public class NewVersionBehaviorTracker implements ColumnTracker, DeleteTracker {
|
|||
delColMap.put(e.getKey(), e.getValue().getDeepCopy());
|
||||
}
|
||||
countCurrentCol = 0;
|
||||
}
|
||||
if (matchCq && !PrivateCellUtil.isDelete(lastCqType) && lastCqType == cell.getTypeByte()
|
||||
} else if (!PrivateCellUtil.isDelete(lastCqType) && lastCqType == cell.getTypeByte()
|
||||
&& lastCqTs == cell.getTimestamp()) {
|
||||
// Put with duplicate timestamp, ignore.
|
||||
return lastCqMvcc;
|
||||
|
@ -190,6 +187,15 @@ public class NewVersionBehaviorTracker implements ColumnTracker, DeleteTracker {
|
|||
return Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
private boolean isColumnQualifierChanged(Cell cell) {
|
||||
if (delColMap.isEmpty() && lastCqArray == null && cell.getQualifierLength() == 0
|
||||
&& (PrivateCellUtil.isDeleteColumns(cell) || PrivateCellUtil.isDeleteColumnVersion(cell))) {
|
||||
// for null columnQualifier
|
||||
return true;
|
||||
}
|
||||
return !PrivateCellUtil.matchingQualifier(cell, lastCqArray, lastCqOffset, lastCqLength);
|
||||
}
|
||||
|
||||
// DeleteTracker
|
||||
@Override
|
||||
public void add(Cell cell) {
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.regionserver;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
|
@ -358,4 +359,14 @@ public class TestNewVersionBehaviorFromClientSide {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullColumnQualifier() throws IOException {
|
||||
try (Table t = createTable()) {
|
||||
Delete del = new Delete(ROW);
|
||||
del.addColumn(FAMILY, null);
|
||||
t.delete(del);
|
||||
Result r = t.get(new Get(ROW)); //NPE
|
||||
assertTrue(r.isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue