HBase
  1. HBase
  2. HBASE-10064

AggregateClient.validateParameters can throw NPE

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.94.14
    • Fix Version/s: 0.94.15
    • Component/s: Client
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      When using methods such as max(...), min(...) in AggregationClient, we will pass Scan as parameter. These methods will throw NullPointerException if users invoke scan.setStartRow(null) or scan.setStopRow(null) before passing the scan as parameter. The NullPointerException is thrown by validateParameters(Scan scan) which will be invoked before sending requests to server. The implementation of validateParameters is :

        private void validateParameters(Scan scan) throws IOException {
          if (scan == null
              || (Bytes.equals(scan.getStartRow(), scan.getStopRow()) && !Bytes
                  .equals(scan.getStartRow(), HConstants.EMPTY_START_ROW))
              || ((Bytes.compareTo(scan.getStartRow(), scan.getStopRow()) > 0) &&
              	!Bytes.equals(scan.getStopRow(), HConstants.EMPTY_END_ROW))) {
            throw new IOException(
                "Agg client Exception: Startrow should be smaller than Stoprow");
          } else if (scan.getFamilyMap().size() != 1) {
            throw new IOException("There must be only one family.");
          }
        }
      

      “Bytes.equals(scan.getStartRow(), HConstants.EMPTY_START_ROW)” will throw NullPointerException if the startRow of scan is set to null.

      1. 10064-0.94.patch
        0.7 kB
        Andrew Purtell
      2. HBASE-10064-0.94-v1.patch
        2 kB
        cuijianwei
      3. HBASE-10064-0.94-v2.patch
        1 kB
        cuijianwei

        Activity

        Hide
        cuijianwei added a comment -

        This patch resolve the problem by setting startRow/stopRow to EMPTY_START_ROW/EMPTY_END_ROW if user invokes scan.setStartRow(null)/scan.setStopRow(null)

        Show
        cuijianwei added a comment - This patch resolve the problem by setting startRow/stopRow to EMPTY_START_ROW/EMPTY_END_ROW if user invokes scan.setStartRow(null)/scan.setStopRow(null)
        Hide
        Andrew Purtell added a comment -

        Ok for 0.94 Lars Hofhansl?

        Show
        Andrew Purtell added a comment - Ok for 0.94 Lars Hofhansl ?
        Hide
        Lars Hofhansl added a comment -

        Sure. For something like this I would have a slight preference for
        this.startRow = startRow == null ? HConstants.EMPTY_START_ROW : startRow

        But this is fine. +1

        Show
        Lars Hofhansl added a comment - Sure. For something like this I would have a slight preference for this.startRow = startRow == null ? HConstants.EMPTY_START_ROW : startRow But this is fine. +1
        Hide
        cuijianwei added a comment -

        Thanks for your comments. I aggree with the idea of Lars Hofhansl and the code looks more concise. I polish the patch.

        Show
        cuijianwei added a comment - Thanks for your comments. I aggree with the idea of Lars Hofhansl and the code looks more concise. I polish the patch.
        Hide
        Andrew Purtell added a comment -

        Great, thanks for the polish cuijianwei. I will commit this shortly unless objection.

        Show
        Andrew Purtell added a comment - Great, thanks for the polish cuijianwei . I will commit this shortly unless objection.
        Hide
        Andrew Purtell added a comment -

        What I committed to 0.94 branch.

        Show
        Andrew Purtell added a comment - What I committed to 0.94 branch.
        Hide
        Hudson added a comment -

        SUCCESS: Integrated in HBase-0.94 #1219 (See https://builds.apache.org/job/HBase-0.94/1219/)
        HBASE-10064. AggregateClient.validateParameters can throw NPE (cuijianwei) (apurtell: rev 1548416)

        • /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/Scan.java
        Show
        Hudson added a comment - SUCCESS: Integrated in HBase-0.94 #1219 (See https://builds.apache.org/job/HBase-0.94/1219/ ) HBASE-10064 . AggregateClient.validateParameters can throw NPE (cuijianwei) (apurtell: rev 1548416) /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/Scan.java
        Hide
        Hudson added a comment -

        SUCCESS: Integrated in HBase-0.94-security #353 (See https://builds.apache.org/job/HBase-0.94-security/353/)
        HBASE-10064. AggregateClient.validateParameters can throw NPE (cuijianwei) (apurtell: rev 1548416)

        • /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/Scan.java
        Show
        Hudson added a comment - SUCCESS: Integrated in HBase-0.94-security #353 (See https://builds.apache.org/job/HBase-0.94-security/353/ ) HBASE-10064 . AggregateClient.validateParameters can throw NPE (cuijianwei) (apurtell: rev 1548416) /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/Scan.java

          People

          • Assignee:
            cuijianwei
            Reporter:
            cuijianwei
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development