Program: 112391
Project: 112391
Buggy source:
/** 
 * Test writing edits into an region, closing it, splitting logs, opening Region again. Verify seqids.
 * @throws Exception on failure
 */
@Test public void testReplayEditsWrittenViaHRegion() throws Exception {
  final String tableNameStr="String_Node_Str";
  final RegionInfo hri=RegionInfoBuilder.newBuilder(org.apache.hadoop.hbase.TableName.valueOf(tableNameStr)).setSplit(false).build();
  final Path basedir=FSUtils.getTableDir(hbaseRootDir,org.apache.hadoop.hbase.TableName.valueOf(tableNameStr));
  deleteDir(basedir);
  final TableDescriptor htd=createBasic3FamilyHTD(tableNameStr);
  byte[] family=new byte[]{'a'};
  ColumnGroup fam1=new ColumnGroup(INDEX_TABLE_NAME);
  fam1.add(new CoveredColumn(family,CoveredColumn.ALL_QUALIFIERS));
  CoveredColumnIndexSpecifierBuilder builder=new CoveredColumnIndexSpecifierBuilder();
  builder.addIndexGroup(fam1);
  builder.build(htd);
  WALFactory walFactory=new WALFactory(this.conf,null,"String_Node_Str");
  WAL wal=createWAL(this.conf,walFactory);
  HRegion region0=HRegion.createHRegion(hri,hbaseRootDir,this.conf,htd,wal);
  region0.close();
  region0.getWAL().close();
  HRegionServer mockRS=Mockito.mock(HRegionServer.class);
  when(mockRS.getWAL(null)).thenReturn(wal);
  RegionServerAccounting rsa=Mockito.mock(RegionServerAccounting.class);
  when(mockRS.getRegionServerAccounting()).thenReturn(rsa);
  ServerName mockServerName=Mockito.mock(ServerName.class);
  when(mockServerName.getServerName()).thenReturn(tableNameStr + "String_Node_Str");
  when(mockRS.getServerName()).thenReturn(mockServerName);
  HRegion region=spy(new HRegion(basedir,wal,this.fs,this.conf,hri,htd,mockRS));
  region.initialize();
  byte[] rowkey=Bytes.toBytes("String_Node_Str");
  Put p=new Put(rowkey);
  p.addColumn(family,Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"));
  region.put(p);
  Mockito.verify(mockRS,Mockito.times(1)).abort(Mockito.anyString(),Mockito.any(Exception.class));
  TestIndexManagementUtil.createIndexTable(UTIL.getAdmin(),INDEX_TABLE_NAME);
  runWALSplit(this.conf,walFactory);
  WAL wal2=createWAL(this.conf,walFactory);
  HRegion region1=new HRegion(basedir,wal2,this.fs,this.conf,hri,htd,mockRS);
  region1.initialize();
  org.apache.hadoop.hbase.client.Connection hbaseConn=ConnectionFactory.createConnection(UTIL.getConfiguration());
  Table index=hbaseConn.getTable(org.apache.hadoop.hbase.TableName.valueOf(INDEX_TABLE_NAME));
  int indexSize=getKeyValueCount(index);
  assertEquals("String_Node_Str",1,indexSize);
  Get g=new Get(rowkey);
  final Result result=region1.get(g);
  assertEquals("String_Node_Str",1,result.size());
  Admin admin=UTIL.getAdmin();
  admin.disableTable(TableName.valueOf(INDEX_TABLE_NAME));
  admin.deleteTable(TableName.valueOf(INDEX_TABLE_NAME));
  admin.close();
}

Fixed version (ground truth):
/** 
 * Test writing edits into an region, closing it, splitting logs, opening Region again. Verify seqids.
 * @throws Exception on failure
 */
@Test public void testReplayEditsWrittenViaHRegion() throws Exception {
  final String tableNameStr="String_Node_Str";
  final RegionInfo hri=RegionInfoBuilder.newBuilder(org.apache.hadoop.hbase.TableName.valueOf(tableNameStr)).setSplit(false).build();
  final Path basedir=FSUtils.getTableDir(hbaseRootDir,org.apache.hadoop.hbase.TableName.valueOf(tableNameStr));
  deleteDir(basedir);
  final TableDescriptor htd=createBasic3FamilyHTD(tableNameStr);
  byte[] family=new byte[]{'a'};
  ColumnGroup fam1=new ColumnGroup(INDEX_TABLE_NAME);
  fam1.add(new CoveredColumn(family,CoveredColumn.ALL_QUALIFIERS));
  CoveredColumnIndexSpecifierBuilder builder=new CoveredColumnIndexSpecifierBuilder();
  builder.addIndexGroup(fam1);
  builder.build(htd);
  WALFactory walFactory=new WALFactory(this.conf,"String_Node_Str");
  WAL wal=createWAL(this.conf,walFactory);
  HRegion region0=HRegion.createHRegion(hri,hbaseRootDir,this.conf,htd,wal);
  region0.close();
  region0.getWAL().close();
  HRegionServer mockRS=Mockito.mock(HRegionServer.class);
  when(mockRS.getWAL(null)).thenReturn(wal);
  RegionServerAccounting rsa=Mockito.mock(RegionServerAccounting.class);
  when(mockRS.getRegionServerAccounting()).thenReturn(rsa);
  ServerName mockServerName=Mockito.mock(ServerName.class);
  when(mockServerName.getServerName()).thenReturn(tableNameStr + "String_Node_Str");
  when(mockRS.getServerName()).thenReturn(mockServerName);
  HRegion region=spy(new HRegion(basedir,wal,this.fs,this.conf,hri,htd,mockRS));
  region.initialize();
  byte[] rowkey=Bytes.toBytes("String_Node_Str");
  Put p=new Put(rowkey);
  p.addColumn(family,Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"));
  region.put(p);
  Mockito.verify(mockRS,Mockito.times(1)).abort(Mockito.anyString(),Mockito.any(Exception.class));
  TestIndexManagementUtil.createIndexTable(UTIL.getAdmin(),INDEX_TABLE_NAME);
  runWALSplit(this.conf,walFactory);
  WAL wal2=createWAL(this.conf,walFactory);
  HRegion region1=new HRegion(basedir,wal2,this.fs,this.conf,hri,htd,mockRS);
  region1.initialize();
  org.apache.hadoop.hbase.client.Connection hbaseConn=ConnectionFactory.createConnection(UTIL.getConfiguration());
  Table index=hbaseConn.getTable(org.apache.hadoop.hbase.TableName.valueOf(INDEX_TABLE_NAME));
  int indexSize=getKeyValueCount(index);
  assertEquals("String_Node_Str",1,indexSize);
  Get g=new Get(rowkey);
  final Result result=region1.get(g);
  assertEquals("String_Node_Str",1,result.size());
  Admin admin=UTIL.getAdmin();
  admin.disableTable(TableName.valueOf(INDEX_TABLE_NAME));
  admin.deleteTable(TableName.valueOf(INDEX_TABLE_NAME));
  admin.close();
}