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.