Buggy code:
public class BSVCoprocessorEndPoint extends Execute implements Coprocessor , CoprocessorService { private RegionCoprocessorEnvironment env ; private BSVCoprocessorEndPoint . AggregationManager aggregationManager = null ; private boolean isMaterialize = false ; private String joinFamily = null ; private String joinQualifier = null ; private HTable joinTable = null ; @ Override public Service getService ( ) { } @ Override public void start ( CoprocessorEnvironment env ) throws IOException { } @ Override public void stop ( CoprocessorEnvironment env ) throws IOException { } @ Override public void batch ( RpcController controller , ParameterMessage request , RpcCallback < ResultMessage > done ) { System . out . println ( "============================================================" ) ; System . out . println ( ( ( new Date ( ) ) + "Begin<seq2seq4repair_space>to<seq2seq4repair_space>execute" ) ) ; aggregationManager = new BSVCoprocessorEndPoint . AggregationManager ( request ) ; Scan scan = new Scan ( ) ; scan . setMaxVersions ( 1 ) ; <START_BUG> if ( ( request . getJoinKey ( ) ) != null ) { <END_BUG> isMaterialize = true ; Configuration configuration = HBaseConfiguration . create ( ) ; try { joinTable = new HTable ( configuration , request . getJoinTable ( ) . toByteArray ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } joinFamily = request . getJoinKey ( ) . toStringUtf8 ( ) . split ( "\\." ) [ 0 ] ; joinQualifier = request . getJoinKey ( ) . toStringUtf8 ( ) . split ( "\\." ) [ 1 ] ; scan . addColumn ( joinFamily . getBytes ( ) , joinQualifier . getBytes ( ) ) ; } for ( BSVColumn bsvColumn : request . getColumnList ( ) ) { System . out . println ( ( ( ( new Date ( ) ) + "Begin<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>column:<seq2seq4repair_space>" ) + bsvColumn ) ) ; byte [ ] family = bsvColumn . getFamily ( ) . toByteArray ( ) ; byte [ ] column = bsvColumn . getColumn ( ) . toByteArray ( ) ; scan . addColumn ( family , column ) ; System . out . println ( ( ( ( new Date ( ) ) + "Finish<seq2seq4repair_space>adding<seq2seq4repair_space>column:<seq2seq4repair_space>" ) + bsvColumn ) ) ; } for ( Condition condition : request . getConditionList ( ) ) { System . out . println ( ( ( ( new Date ( ) ) + "Begin<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>condition<seq2seq4repair_space>column:<seq2seq4repair_space>" ) + condition ) ) ; byte [ ] family = condition . getColumn ( ) . getFamily ( ) . toByteArray ( ) ; byte [ ] column = condition . getColumn ( ) . getColumn ( ) . toByteArray ( ) ; scan . addColumn ( family , column ) ; } ResultMessage . Builder response = ResultMessage . newBuilder ( ) ; InternalScanner scanner = null ; try { scanner = env . getRegion ( ) . getScanner ( scan ) ; List < Cell > curVals = new ArrayList < Cell > ( ) ; List < List < Cell > > results = new ArrayList < List < Cell > > ( ) ; boolean finish = false ; Date begin = new Date ( ) ; System . out . println ( ( begin + "Begin<seq2seq4repair_space>to<seq2seq4repair_space>scan" ) ) ; do { curVals . clear ( ) ; finish = scanner . next ( curVals ) ; List < Cell > tmp = new ArrayList < Cell > ( curVals ) ; results . add ( tmp ) ; } while ( finish ) ; Date end = new Date ( ) ; System . out . println ( ( ( ( end + "<seq2seq4repair_space>Finish<seq2seq4repair_space>scanning<seq2seq4repair_space>in<seq2seq4repair_space>" ) + ( ( end . getTime ( ) ) - ( begin . getTime ( ) ) ) ) + "<seq2seq4repair_space>million<seq2seq4repair_space>seconds" ) ) ; System . out . println ( ( "Scann<seq2seq4repair_space>result<seq2seq4repair_space>are:<seq2seq4repair_space>" + ( results . toString ( ) ) ) ) ; long count = 0 ; System . out . println ( ( ( new Date ( ) ) + "Begin<seq2seq4repair_space>to<seq2seq4repair_space>build<seq2seq4repair_space>response<seq2seq4repair_space>message" ) ) ; for ( List < Cell > row : results ) { BSVRow . Builder bsvRow = BSVRow . newBuilder ( ) ; System . out . println ( ( ( ( new Date ( ) ) + "Building<seq2seq4repair_space>row<seq2seq4repair_space>no." ) + count ) ) ; boolean meetCondition = handleRow ( request , row , bsvRow ) ; if ( meetCondition ) { response . addRow ( bsvRow ) ; count ++ ; if ( isMaterialize ) { for ( Cell cell : row ) { String cellFamilyClone = new String ( CellUtil . cloneFamily ( cell ) ) ; String cellQualifierClone = new String ( CellUtil . cloneQualifier ( cell ) ) ; String cellString = ( cellFamilyClone + "." ) + cellQualifierClone ; if ( cellString . equals ( ( ( ( joinFamily ) + "." ) + ( joinQualifier ) ) ) ) { Put put = new Put ( cellString . getBytes ( ) ) ; for ( Cell cellForAdd : row ) { put . add ( cellForAdd ) ; } joinTable . put ( put ) ; } } } } } System . out . println ( ( ( new Date ( ) ) + "Finish<seq2seq4repair_space>building<seq2seq4repair_space>response<seq2seq4repair_space>message" ) ) ; response . setSize ( count ) ; BSVRow . Builder bsvRow = BSVRow . newBuilder ( ) ; for ( Map . Entry < String , List < BSVCoprocessorEndPoint . Aggregation > > entry : aggregationManager . getAggregations ( ) . entrySet ( ) ) { for ( BSVCoprocessorEndPoint . Aggregation aggregation : entry . getValue ( ) ) { KeyValue . Builder keyValue = KeyValue . newBuilder ( ) ; keyValue . setRowKey ( ByteString . copyFrom ( aggregation . getName ( ) . getBytes ( ) ) ) ; keyValue . setKey ( ByteString . copyFrom ( entry . getKey ( ) . getBytes ( ) ) ) ;

Fix:
if ( ! ( request . getJoinKey ( ) . toStringUtf8 ( ) . equals ( "" ) ) ) {