Program: 60922
Project: 60922
Buggy source:
/** 
 * Tests the four different scanner-opening methods (with and without a stoprow, with and without a timestamp).
 */
public void doTestTableScanners() throws Exception {
  ThriftServerRunner.HBaseHandler handler=new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname,getColumnDescriptors());
  long time1=System.currentTimeMillis();
  handler.mutateRowTs(tableAname,rowAname,getMutations(),time1,null);
  Thread.sleep(1000);
  long time2=System.currentTimeMillis();
  handler.mutateRowsTs(tableAname,getBatchMutations(),time2,null);
  time1+=1;
  int scanner1=handler.scannerOpen(tableAname,rowAname,getColumnList(true,true),null);
  TRowResult rowResult1a=handler.scannerGet(scanner1).get(0);
  assertEquals(rowResult1a.row,rowAname);
  assertEquals(rowResult1a.columns.size(),1);
  assertEquals(rowResult1a.columns.get(columnBname).value,valueCname);
  TRowResult rowResult1b=handler.scannerGet(scanner1).get(0);
  assertEquals(rowResult1b.row,rowBname);
  assertEquals(rowResult1b.columns.size(),2);
  assertEquals(rowResult1b.columns.get(columnAname).value,valueCname);
  assertEquals(rowResult1b.columns.get(columnBname).value,valueDname);
  closeScanner(scanner1,handler);
  int scanner2=handler.scannerOpenTs(tableAname,rowAname,getColumnList(true,true),time1,null);
  TRowResult rowResult2a=handler.scannerGet(scanner2).get(0);
  assertEquals(rowResult2a.columns.size(),1);
  assertEquals(rowResult2a.columns.get(columnBname).value,valueBname);
  closeScanner(scanner2,handler);
  int scanner3=handler.scannerOpenWithStop(tableAname,rowAname,rowBname,getColumnList(true,false),null);
  closeScanner(scanner3,handler);
  int scanner4=handler.scannerOpenWithStopTs(tableAname,rowAname,rowBname,getColumnList(false,true),time1,null);
  TRowResult rowResult4a=handler.scannerGet(scanner4).get(0);
  assertEquals(rowResult4a.columns.size(),1);
  assertEquals(rowResult4a.columns.get(columnBname).value,valueBname);
  TScan scanNoSortColumns=new TScan();
  scanNoSortColumns.setStartRow(rowAname);
  scanNoSortColumns.setStopRow(rowBname);
  int scanner5=handler.scannerOpenWithScan(tableAname,scanNoSortColumns,null);
  TRowResult rowResult5=handler.scannerGet(scanner5).get(0);
  assertEquals(rowResult5.columns.size(),1);
  assertEquals(rowResult5.columns.get(columnBname).value,valueCname);
  TScan scanSortColumns=new TScan();
  scanSortColumns.setStartRow(rowAname);
  scanSortColumns.setStopRow(rowBname);
  scanSortColumns=scanSortColumns.setSortColumns(true);
  int scanner6=handler.scannerOpenWithScan(tableAname,scanSortColumns,null);
  TRowResult rowResult6=handler.scannerGet(scanner6).get(0);
  assertEquals(rowResult6.sortedColumns.size(),1);
  assertEquals(rowResult6.sortedColumns.get(0).getCell().value,valueCname);
  List<Mutation> rowBmutations=new ArrayList<>(20);
  for (int i=0; i < 20; i++) {
    rowBmutations.add(new Mutation(false,asByteBuffer("String_Node_Str" + i),valueCname,true));
  }
  ByteBuffer rowC=asByteBuffer("String_Node_Str");
  handler.mutateRow(tableAname,rowC,rowBmutations,null);
  TScan scanSortMultiColumns=new TScan();
  scanSortMultiColumns.setStartRow(rowC);
  scanSortMultiColumns=scanSortMultiColumns.setSortColumns(true);
  int scanner7=handler.scannerOpenWithScan(tableAname,scanSortMultiColumns,null);
  TRowResult rowResult7=handler.scannerGet(scanner7).get(0);
  ByteBuffer smallerColumn=asByteBuffer("String_Node_Str");
  for (int i=0; i < 20; i++) {
    ByteBuffer currentColumn=rowResult7.sortedColumns.get(i).columnName;
    assertTrue(Bytes.compareTo(smallerColumn.array(),currentColumn.array()) < 0);
    smallerColumn=currentColumn;
  }
  TScan reversedScan=new TScan();
  reversedScan.setReversed(true);
  reversedScan.setStartRow(rowBname);
  reversedScan.setStopRow(rowAname);
  int scanner8=handler.scannerOpenWithScan(tableAname,reversedScan,null);
  List<TRowResult> results=handler.scannerGet(scanner8);
  handler.scannerClose(scanner8);
  assertEquals(results.size(),1);
  assertEquals(ByteBuffer.wrap(results.get(0).getRow()),rowBname);
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
}

Fixed version (ground truth):
/** 
 * Tests the four different scanner-opening methods (with and without a stoprow, with and without a timestamp).
 */
public void doTestTableScanners() throws Exception {
  ThriftServerRunner.HBaseHandler handler=new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname,getColumnDescriptors());
  long time1=System.currentTimeMillis();
  handler.mutateRowTs(tableAname,rowAname,getMutations(),time1,null);
  Thread.sleep(1000);
  long time2=System.currentTimeMillis();
  handler.mutateRowsTs(tableAname,getBatchMutations(),time2,null);
  time1+=1;
  int scanner1=handler.scannerOpen(tableAname,rowAname,getColumnList(true,true),null);
  TRowResult rowResult1a=handler.scannerGet(scanner1).get(0);
  assertEquals(rowResult1a.row,rowAname);
  assertEquals(1,rowResult1a.columns.size());
  assertEquals(rowResult1a.columns.get(columnBname).value,valueCname);
  TRowResult rowResult1b=handler.scannerGet(scanner1).get(0);
  assertEquals(rowResult1b.row,rowBname);
  assertEquals(2,rowResult1b.columns.size());
  assertEquals(rowResult1b.columns.get(columnAname).value,valueCname);
  assertEquals(rowResult1b.columns.get(columnBname).value,valueDname);
  closeScanner(scanner1,handler);
  int scanner2=handler.scannerOpenTs(tableAname,rowAname,getColumnList(true,true),time1,null);
  TRowResult rowResult2a=handler.scannerGet(scanner2).get(0);
  assertEquals(1,rowResult2a.columns.size());
  assertEquals(rowResult2a.columns.get(columnBname).value,valueBname);
  closeScanner(scanner2,handler);
  int scanner3=handler.scannerOpenWithStop(tableAname,rowAname,rowBname,getColumnList(true,false),null);
  closeScanner(scanner3,handler);
  int scanner4=handler.scannerOpenWithStopTs(tableAname,rowAname,rowBname,getColumnList(false,true),time1,null);
  TRowResult rowResult4a=handler.scannerGet(scanner4).get(0);
  assertEquals(1,rowResult4a.columns.size());
  assertEquals(rowResult4a.columns.get(columnBname).value,valueBname);
  TScan scanNoSortColumns=new TScan();
  scanNoSortColumns.setStartRow(rowAname);
  scanNoSortColumns.setStopRow(rowBname);
  int scanner5=handler.scannerOpenWithScan(tableAname,scanNoSortColumns,null);
  TRowResult rowResult5=handler.scannerGet(scanner5).get(0);
  assertEquals(1,rowResult5.columns.size());
  assertEquals(rowResult5.columns.get(columnBname).value,valueCname);
  TScan scanSortColumns=new TScan();
  scanSortColumns.setStartRow(rowAname);
  scanSortColumns.setStopRow(rowBname);
  scanSortColumns=scanSortColumns.setSortColumns(true);
  int scanner6=handler.scannerOpenWithScan(tableAname,scanSortColumns,null);
  TRowResult rowResult6=handler.scannerGet(scanner6).get(0);
  assertEquals(1,rowResult6.sortedColumns.size());
  assertEquals(rowResult6.sortedColumns.get(0).getCell().value,valueCname);
  List<Mutation> rowBmutations=new ArrayList<>(20);
  for (int i=0; i < 20; i++) {
    rowBmutations.add(new Mutation(false,asByteBuffer("String_Node_Str" + i),valueCname,true));
  }
  ByteBuffer rowC=asByteBuffer("String_Node_Str");
  handler.mutateRow(tableAname,rowC,rowBmutations,null);
  TScan scanSortMultiColumns=new TScan();
  scanSortMultiColumns.setStartRow(rowC);
  scanSortMultiColumns=scanSortMultiColumns.setSortColumns(true);
  int scanner7=handler.scannerOpenWithScan(tableAname,scanSortMultiColumns,null);
  TRowResult rowResult7=handler.scannerGet(scanner7).get(0);
  ByteBuffer smallerColumn=asByteBuffer("String_Node_Str");
  for (int i=0; i < 20; i++) {
    ByteBuffer currentColumn=rowResult7.sortedColumns.get(i).columnName;
    assertTrue(Bytes.compareTo(smallerColumn.array(),currentColumn.array()) < 0);
    smallerColumn=currentColumn;
  }
  TScan reversedScan=new TScan();
  reversedScan.setReversed(true);
  reversedScan.setStartRow(rowBname);
  reversedScan.setStopRow(rowAname);
  int scanner8=handler.scannerOpenWithScan(tableAname,reversedScan,null);
  List<TRowResult> results=handler.scannerGet(scanner8);
  handler.scannerClose(scanner8);
  assertEquals(1,results.size());
  assertEquals(ByteBuffer.wrap(results.get(0).getRow()),rowBname);
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
}