HBASE-2920 HTable.checkAndPut/Delete doesn't handle null values

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@989296 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2010-08-25 18:58:43 +00:00
parent 6e72b3cef3
commit 7abfcbc22c
3 changed files with 11 additions and 1 deletions

View File

@ -487,6 +487,7 @@ Release 0.21.0 - Unreleased
code, ensure we log and rethrow as IOE
(Karthik Ranganathan via Stack)
HBASE-2915 Deadlock between HRegion.ICV and HRegion.close
HBASE-2920 HTable.checkAndPut/Delete doesn't handle null values
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -1473,7 +1473,8 @@ public class HRegion implements HeapSize { // , Writable{
result = get(get);
boolean matches = false;
if (result.size() == 0 && expectedValue.length == 0) {
if (result.size() == 0 &&
(expectedValue == null || expectedValue.length == 0)) {
matches = true;
} else if (result.size() == 1) {
//Compare the expected value with the actual value

View File

@ -489,6 +489,14 @@ public class TestHRegion extends HBaseTestCase {
res = region.checkAndMutate(row1, fam1, qf1, emptyVal, delete, lockId,
true);
assertTrue(res);
//checkAndPut looking for a null value
put = new Put(row1);
put.add(fam1, qf1, val1);
res = region.checkAndMutate(row1, fam1, qf1, null, put, lockId, true);
assertTrue(res);
}
public void testCheckAndMutate_WithWrongValue() throws IOException{