Details
Description
The JavaDoc for batchCoprocessorService() reads:
* @param startKey * start region selection with region containing this row. If {@code null}, the * selection will start with the first table region. * @param endKey * select regions up to and including the region containing this row. If {@code null}, * selection will continue through the last table region.
Setting the call to null keys like so
Map<byte[], CountResponse> results = table.batchCoprocessorService( RowCountService.getDescriptor().findMethodByName("getRowCount"), request, null, null, CountResponse.getDefaultInstance());
yields an exception:
java.lang.NullPointerException at org.apache.hadoop.hbase.util.Bytes.compareTo(Bytes.java:1187) at org.apache.hadoop.hbase.client.HTable.getKeysAndRegionsInRange(HTable.java:744) at org.apache.hadoop.hbase.client.HTable.getKeysAndRegionsInRange(HTable.java:723) at org.apache.hadoop.hbase.client.HTable.batchCoprocessorService(HTable.java:1801) at org.apache.hadoop.hbase.client.HTable.batchCoprocessorService(HTable.java:1778) at coprocessor.EndpointBatchExample.main(EndpointBatchExample.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
This is caused by the call shipping off the keys to getStartKeysInRange() as-is and that method uses Bytes.compareTo() on the null keys and fails.
One can work around using HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW instead, but that is not documented, nor standard behavior. Need to handle null keys as advertised.