hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1391219 - /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Date Thu, 27 Sep 2012 21:07:13 GMT
Author: mbautin
Date: Thu Sep 27 21:07:13 2012
New Revision: 1391219

URL: http://svn.apache.org/viewvc?rev=1391219&view=rev
Log:
[HBASE-3793] NPE for checkAndPut API when client passes a NULL as the expected value

Author: liyintang

Summary:
There is a NPE when the client passes a NULL as the expected value for the checkAndPut API.
According to the javadoc, the NULL expected value means HBase shall atomically execute a Put
if that row does NOT has a value currently.  However, the code has a bug when handling this
NULL expected value.

Test Plan: not tested. Going to test it on the ods shadow.

Reviewers: kannan, kranganathan

Reviewed By: kannan

CC: hbase-eng@, vinodv

Differential Revision: https://phabricator.fb.com/D585826

Task ID: 1761087

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1391219&r1=1391218&r2=1391219&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Thu Sep 27 21:07:13 2012
@@ -2172,23 +2172,24 @@ public class HRegion implements HeapSize
       Get get = new Get(row, lock);
       checkFamily(family);
       get.addColumn(family, qualifier);
-
       // Lock row
       Integer lid = getLock(lockId, get.getRow(), true);
       List<KeyValue> result = new ArrayList<KeyValue>();
       try {
         result = get(get);
-
         boolean matches = false;
-        if (result.size() == 0
-            && (expectedValue == null || expectedValue.length == 0)) {
-          matches = true;
+        
+        if (result.size() == 0) {
+          if (expectedValue == null ) {
+            matches = true;
+          }
         } else if (result.size() == 1) {
-          // Compare the expected value with the actual value without copying anything
-          KeyValue kv = result.get(0);
-          matches = Bytes.equals(
-              expectedValue, 0, expectedValue.length,
-              kv.getBuffer(), kv.getValueOffset(), kv.getValueLength());
+          if (expectedValue != null) {
+            // Compare the expected value with the actual value without copying anything
+            KeyValue kv = result.get(0);
+            matches = Bytes.equals(expectedValue, 0, expectedValue.length,
+                kv.getBuffer(), kv.getValueOffset(), kv.getValueLength());
+          }
         } else {
           throw new IOException("Internal error: more than one result returned for row/column");
         }



Mime
View raw message