Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-3793

HBASE-3468 Broke checkAndPut with null value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 0.92.0
    • 0.92.0
    • regionserver
    • None
    • Reviewed

    Description

      The previous code called Bytes.equal() which does a check for "null" on the left or right argument. Now the comparator calls Bytes.compareTo() - which has no check for null. But this is a valid input and checks for existence. I actually noticed this running

      https://github.com/larsgeorge/hbase-book/blob/master/ch04/src/main/java/client/CheckAndPutExample.java

      This used to work, now it throws an NPE

      Caused by: java.lang.NullPointerException
      	at org.apache.hadoop.hbase.util.Bytes.compareTo(Bytes.java:854)
      	at org.apache.hadoop.hbase.filter.WritableByteArrayComparable.compareTo(WritableByteArrayComparable.java:63)
      	at org.apache.hadoop.hbase.regionserver.HRegion.checkAndMutate(HRegion.java:1681)
      	at org.apache.hadoop.hbase.regionserver.HRegionServer.checkAndMutate(HRegionServer.java:1693)
      	... 6 more
      
      
      	at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getRegionServerWithRetries(HConnectionManager.java:1026)
      	at org.apache.hadoop.hbase.client.HTable.checkAndPut(HTable.java:750)
      	at client.CheckAndPutExample.main(CheckAndPutExample.java:33)
      

      Easy fixable, just needs to handle the null value before even calling comparator.compareTo().

      Attachments

        1. D5835.1.patch
          2 kB
          Phabricator
        2. HBASE-3793-TRUNK.patch
          3 kB
          Ming Ma
        3. HBASE-3793.patch
          0.8 kB
          Lars George

        Activity

          People

            mingma Ming Ma
            larsgeorge Lars George
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: