nus-yam/ex-repair huggingface dataset:
Program: 61033
Project: 61033
Buggy source:
@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureSuspendedException {
  LOG.info("String_Node_Str" + this + "String_Node_Str"+ ntimeouts);
  if (ntimeouts.get() > maxTimeouts) {
    setAbortFailure("String_Node_Str","String_Node_Str" + ntimeouts.get());
    return null;
  }
  env.getProcedureScheduler().suspendEvent(event);
  if (env.getProcedureScheduler().waitEvent(event,this)) {
    setState(ProcedureState.WAITING_TIMEOUT);
    throw new ProcedureSuspendedException();
  }
  return null;
}

Fixed version (ground truth):
@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureSuspendedException {
  LOG.info("String_Node_Str" + this + "String_Node_Str"+ ntimeouts);
  if (ntimeouts.get() > maxTimeouts) {
    setAbortFailure("String_Node_Str","String_Node_Str" + ntimeouts.get());
    return null;
  }
  event.suspend();
  if (event.suspendIfNotReady(this)) {
    setState(ProcedureState.WAITING_TIMEOUT);
    throw new ProcedureSuspendedException();
  }
  return null;
}
Program: 61034
Project: 61034
Buggy source:
@Override protected boolean setTimeoutFailure(final TestProcEnv env){
  int n=ntimeouts.incrementAndGet();
  LOG.info("String_Node_Str" + this + "String_Node_Str"+ n);
  setState(ProcedureState.RUNNABLE);
  env.getProcedureScheduler().wakeEvent(event);
  return false;
}

Fixed version (ground truth):
@Override protected boolean setTimeoutFailure(final TestProcEnv env){
  int n=ntimeouts.incrementAndGet();
  LOG.info("String_Node_Str" + this + "String_Node_Str"+ n);
  setState(ProcedureState.RUNNABLE);
  event.wake((AbstractProcedureScheduler)env.getProcedureScheduler());
  return false;
}
Program: 61035
Project: 61035
Buggy source:
@Override protected void afterReplay(final TestProcEnv env){
  if (getState() == ProcedureState.WAITING_TIMEOUT) {
    env.getProcedureScheduler().suspendEvent(event);
    env.getProcedureScheduler().waitEvent(event,this);
  }
}

Fixed version (ground truth):
@Override protected void afterReplay(final TestProcEnv env){
  if (getState() == ProcedureState.WAITING_TIMEOUT) {
    event.suspend();
    event.suspendIfNotReady(this);
  }
}
Program: 61037
Project: 61037
Buggy source:
/** 
 * Calculates the splits that will serve as input for the map tasks.
 * @param context  The current job context.
 * @return The list of input splits.
 * @throws IOException When creating the list of splits fails.
 * @see org.apache.hadoop.mapreduce.InputFormat#getSplits(org.apache.hadoop.mapreduce.JobContext)
 */
@Override public List<InputSplit> getSplits(JobContext context) throws IOException {
  boolean closeOnFinish=false;
  if (table == null) {
    initialize(context);
    closeOnFinish=true;
  }
  try {
    if (getTable() == null) {
      throw new IOException(INITIALIZATION_ERROR);
    }
  }
 catch (  IllegalStateException exception) {
    throw new IOException(INITIALIZATION_ERROR,exception);
  }
  try {
    List<InputSplit> splits=oneInputSplitPerRegion();
    if (context.getConfiguration().get(NUM_MAPPERS_PER_REGION) != null) {
      int nSplitsPerRegion=context.getConfiguration().getInt(NUM_MAPPERS_PER_REGION,1);
      List<InputSplit> res=new ArrayList<>();
      for (int i=0; i < splits.size(); i++) {
        List<InputSplit> tmp=createNInputSplitsUniform(splits.get(i),nSplitsPerRegion);
        res.addAll(tmp);
      }
      return res;
    }
    if (context.getConfiguration().getBoolean(MAPREDUCE_INPUT_AUTOBALANCE,false) != false) {
      long maxAveRegionSize=context.getConfiguration().getInt(MAX_AVERAGE_REGION_SIZE,8 * 1073741824);
      return calculateAutoBalancedSplits(splits,maxAveRegionSize);
    }
    return splits;
  }
  finally {
    if (closeOnFinish) {
      closeTable();
    }
  }
}

Fixed version (ground truth):
/** 
 * Calculates the splits that will serve as input for the map tasks.
 * @param context  The current job context.
 * @return The list of input splits.
 * @throws IOException When creating the list of splits fails.
 * @see org.apache.hadoop.mapreduce.InputFormat#getSplits(org.apache.hadoop.mapreduce.JobContext)
 */
@Override public List<InputSplit> getSplits(JobContext context) throws IOException {
  boolean closeOnFinish=false;
  if (table == null) {
    initialize(context);
    closeOnFinish=true;
  }
  try {
    if (getTable() == null) {
      throw new IOException(INITIALIZATION_ERROR);
    }
  }
 catch (  IllegalStateException exception) {
    throw new IOException(INITIALIZATION_ERROR,exception);
  }
  try {
    List<InputSplit> splits=oneInputSplitPerRegion();
    if (context.getConfiguration().get(NUM_MAPPERS_PER_REGION) != null) {
      int nSplitsPerRegion=context.getConfiguration().getInt(NUM_MAPPERS_PER_REGION,1);
      List<InputSplit> res=new ArrayList<>();
      for (int i=0; i < splits.size(); i++) {
        List<InputSplit> tmp=createNInputSplitsUniform(splits.get(i),nSplitsPerRegion);
        res.addAll(tmp);
      }
      return res;
    }
    if (context.getConfiguration().getBoolean(MAPREDUCE_INPUT_AUTOBALANCE,false)) {
      long maxAveRegionSize=context.getConfiguration().getLong(MAX_AVERAGE_REGION_SIZE,8L * 1073741824);
      return calculateAutoBalancedSplits(splits,maxAveRegionSize);
    }
    return splits;
  }
  finally {
    if (closeOnFinish) {
      closeTable();
    }
  }
}
Program: 61038
Project: 61038
Buggy source:
int getValueLength(final Random r){
  if (this.opts.isValueRandom())   return Math.abs(r.nextInt() % opts.valueSize);
 else   if (this.opts.isValueZipf())   return Math.abs(this.zipf.nextInt());
 else   return opts.valueSize;
}

Fixed version (ground truth):
int getValueLength(final Random r){
  if (this.opts.isValueRandom()) {
    return r.nextInt(opts.valueSize);
  }
 else   if (this.opts.isValueZipf()) {
    return Math.abs(this.zipf.nextInt());
  }
 else {
    return opts.valueSize;
  }
}
Program: 61039
Project: 61039
Buggy source:
@Test @SuppressWarnings("String_Node_Str") public void testSplitTableCompareTo(){
  TableSplit aTableSplit=new TableSplit(Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),"String_Node_Str");
  TableSplit bTableSplit=new TableSplit(Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),"String_Node_Str");
  TableSplit cTableSplit=new TableSplit(Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),"String_Node_Str");
  assertTrue(aTableSplit.compareTo(aTableSplit) == 0);
  assertTrue(bTableSplit.compareTo(bTableSplit) == 0);
  assertTrue(cTableSplit.compareTo(cTableSplit) == 0);
  assertTrue(aTableSplit.compareTo(bTableSplit) < 0);
  assertTrue(bTableSplit.compareTo(aTableSplit) > 0);
  assertTrue(aTableSplit.compareTo(cTableSplit) < 0);
  assertTrue(cTableSplit.compareTo(aTableSplit) > 0);
  assertTrue(bTableSplit.compareTo(cTableSplit) < 0);
  assertTrue(cTableSplit.compareTo(bTableSplit) > 0);
  assertTrue(cTableSplit.compareTo(aTableSplit) > 0);
}

Fixed version (ground truth):
@Test @SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void testSplitTableCompareTo(){
  TableSplit aTableSplit=new TableSplit(Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),"String_Node_Str");
  TableSplit bTableSplit=new TableSplit(Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),"String_Node_Str");
  TableSplit cTableSplit=new TableSplit(Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),Bytes.toBytes("String_Node_Str"),"String_Node_Str");
  assertEquals(0,aTableSplit.compareTo(aTableSplit));
  assertEquals(0,bTableSplit.compareTo(bTableSplit));
  assertEquals(0,cTableSplit.compareTo(cTableSplit));
  assertTrue(aTableSplit.compareTo(bTableSplit) < 0);
  assertTrue(bTableSplit.compareTo(aTableSplit) > 0);
  assertTrue(aTableSplit.compareTo(cTableSplit) < 0);
  assertTrue(cTableSplit.compareTo(aTableSplit) > 0);
  assertTrue(bTableSplit.compareTo(cTableSplit) < 0);
  assertTrue(cTableSplit.compareTo(bTableSplit) > 0);
  assertTrue(cTableSplit.compareTo(aTableSplit) > 0);
}
Program: 61041
Project: 61041
Buggy source:
@Override protected void populatePut(byte[] lineBytes,ParsedLine parsed,Put put,int i) throws BadTsvLineException, IOException {
  KeyValue kv;
  kv=new KeyValue(lineBytes,parsed.getRowKeyOffset(),parsed.getRowKeyLength(),parser.getFamily(i),0,parser.getFamily(i).length,parser.getQualifier(i),0,parser.getQualifier(i).length,ts,KeyValue.Type.Put,lineBytes,parsed.getColumnOffset(i),parsed.getColumnLength(i));
  if (parsed.getIndividualAttributes() != null) {
    String[] attributes=parsed.getIndividualAttributes();
    for (    String attr : attributes) {
      String[] split=attr.split(ImportTsv.DEFAULT_ATTRIBUTES_SEPERATOR);
      if (split == null || split.length <= 1) {
        throw new BadTsvLineException("String_Node_Str" + attributes);
      }
 else {
        if (split[0].length() <= 0 || split[1].length() <= 0) {
          throw new BadTsvLineException("String_Node_Str" + attributes);
        }
        put.setAttribute(split[0],Bytes.toBytes(split[1]));
      }
    }
  }
  put.add(kv);
}

Fixed version (ground truth):
@Override protected void populatePut(byte[] lineBytes,ParsedLine parsed,Put put,int i) throws BadTsvLineException, IOException {
  KeyValue kv;
  kv=new KeyValue(lineBytes,parsed.getRowKeyOffset(),parsed.getRowKeyLength(),parser.getFamily(i),0,parser.getFamily(i).length,parser.getQualifier(i),0,parser.getQualifier(i).length,ts,KeyValue.Type.Put,lineBytes,parsed.getColumnOffset(i),parsed.getColumnLength(i));
  if (parsed.getIndividualAttributes() != null) {
    String[] attributes=parsed.getIndividualAttributes();
    for (    String attr : attributes) {
      String[] split=attr.split(ImportTsv.DEFAULT_ATTRIBUTES_SEPERATOR);
      if (split == null || split.length <= 1) {
        throw new BadTsvLineException(msg(attributes));
      }
 else {
        if (split[0].length() <= 0 || split[1].length() <= 0) {
          throw new BadTsvLineException(msg(attributes));
        }
        put.setAttribute(split[0],Bytes.toBytes(split[1]));
      }
    }
  }
  put.add(kv);
}
Program: 61043
Project: 61043
Buggy source:
public void testHTableExistsMethodSingleRegionMultipleGets() throws Exception {
  Table table=TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()),new byte[][]{FAMILY});
  Put put=new Put(ROW);
  put.addColumn(FAMILY,QUALIFIER,VALUE);
  table.put(put);
  List<Get> gets=new ArrayList<>();
  gets.add(new Get(ROW));
  gets.add(null);
  gets.add(new Get(ANOTHERROW));
  boolean[] results=table.existsAll(gets);
  assertEquals(results[0],true);
  assertEquals(results[1],false);
  assertEquals(results[2],false);
}

Fixed version (ground truth):
@Test public void testHTableExistsMethodSingleRegionMultipleGets() throws Exception {
  Table table=TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()),new byte[][]{FAMILY});
  Put put=new Put(ROW);
  put.addColumn(FAMILY,QUALIFIER,VALUE);
  table.put(put);
  List<Get> gets=new ArrayList<>();
  gets.add(new Get(ROW));
  gets.add(new Get(ANOTHERROW));
  boolean[] results=table.exists(gets);
  assertTrue(results[0]);
  assertFalse(results[1]);
}
Program: 61046
Project: 61046
Buggy source:
/** 
 * Test that on a major compaction, if all cells are expired or deleted, then we'll end up with no product. Make sure scanner over region returns right answer in this case - and that it just basically works.
 * @throws IOException
 */
public void testMajorCompactingToNoOutputWithReverseScan() throws IOException {
  createStoreFile(r);
  for (int i=0; i < compactionThreshold; i++) {
    createStoreFile(r);
  }
  Scan scan=new Scan();
  scan.setReversed(true);
  InternalScanner s=r.getScanner(scan);
  do {
    List<Cell> results=new ArrayList<>();
    boolean result=s.next(results);
    assertTrue(!results.isEmpty());
    r.delete(new Delete(CellUtil.cloneRow(results.get(0))));
    if (!result)     break;
  }
 while (true);
  s.close();
  r.flush(true);
  r.compact(true);
  scan=new Scan();
  scan.setReversed(true);
  s=r.getScanner(scan);
  int counter=0;
  do {
    List<Cell> results=new ArrayList<>();
    boolean result=s.next(results);
    if (!result)     break;
    counter++;
  }
 while (true);
  s.close();
  assertEquals(0,counter);
}

Fixed version (ground truth):
/** 
 * Test that on a major compaction, if all cells are expired or deleted, then we'll end up with no product. Make sure scanner over region returns right answer in this case - and that it just basically works.
 * @throws IOException
 */
@Test public void testMajorCompactingToNoOutputWithReverseScan() throws IOException {
  createStoreFile(r);
  for (int i=0; i < compactionThreshold; i++) {
    createStoreFile(r);
  }
  Scan scan=new Scan();
  scan.setReversed(true);
  InternalScanner s=r.getScanner(scan);
  do {
    List<Cell> results=new ArrayList<>();
    boolean result=s.next(results);
    assertTrue(!results.isEmpty());
    r.delete(new Delete(CellUtil.cloneRow(results.get(0))));
    if (!result)     break;
  }
 while (true);
  s.close();
  r.flush(true);
  r.compact(true);
  scan=new Scan();
  scan.setReversed(true);
  s=r.getScanner(scan);
  int counter=0;
  do {
    List<Cell> results=new ArrayList<>();
    boolean result=s.next(results);
    if (!result)     break;
    counter++;
  }
 while (true);
  s.close();
  assertEquals(0,counter);
}
Program: 61047
Project: 61047
Buggy source:
@Override public boolean equals(Object obj){
  if (obj == null || !(obj instanceof MemStoreSize)) {
    return false;
  }
  MemStoreSize other=(MemStoreSize)obj;
  return this.dataSize == other.dataSize && this.heapSize == other.heapSize;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (obj == null || getClass() != obj.getClass()) {
    return false;
  }
  MemStoreSize other=(MemStoreSize)obj;
  return this.dataSize == other.dataSize && this.heapSize == other.heapSize;
}
Program: 61048
Project: 61048
Buggy source:
@Override public boolean equals(Object obj){
  if (obj == null || !(obj instanceof MemStoreSizing)) {
    return false;
  }
  MemStoreSizing other=(MemStoreSizing)obj;
  return this.dataSize == other.dataSize && this.heapSize == other.heapSize;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (obj == null || (getClass() != obj.getClass())) {
    return false;
  }
  MemStoreSizing other=(MemStoreSizing)obj;
  return this.dataSize == other.dataSize && this.heapSize == other.heapSize;
}
Program: 61049
Project: 61049
Buggy source:
private int createCellReference(ByteBufferKeyValue cell,ByteBuffer idxBuffer,int idxOffset){
  int offset=idxOffset;
  int dataChunkID=cell.getChunkId();
  Chunk c=ChunkCreator.getInstance().saveChunkFromGC(dataChunkID);
  assert(c != null);
  offset=ByteBufferUtils.putInt(idxBuffer,offset,dataChunkID);
  offset=ByteBufferUtils.putInt(idxBuffer,offset,cell.getOffset());
  offset=ByteBufferUtils.putInt(idxBuffer,offset,KeyValueUtil.length(cell));
  offset=ByteBufferUtils.putLong(idxBuffer,offset,cell.getSequenceId());
  return offset;
}

Fixed version (ground truth):
private int createCellReference(ByteBufferKeyValue cell,ByteBuffer idxBuffer,int idxOffset){
  int offset=idxOffset;
  int dataChunkID=cell.getChunkId();
  offset=ByteBufferUtils.putInt(idxBuffer,offset,dataChunkID);
  offset=ByteBufferUtils.putInt(idxBuffer,offset,cell.getOffset());
  offset=ByteBufferUtils.putInt(idxBuffer,offset,KeyValueUtil.length(cell));
  offset=ByteBufferUtils.putLong(idxBuffer,offset,cell.getSequenceId());
  return offset;
}
Program: 61050
Project: 61050
Buggy source:
private void removeChunks(Set<Integer> chunkIDs){
  this.weakChunkIdMap.keySet().removeAll(chunkIDs);
  this.strongChunkIdMap.keySet().removeAll(chunkIDs);
}

Fixed version (ground truth):
private void removeChunks(Set<Integer> chunkIDs){
  this.chunkIdMap.keySet().removeAll(chunkIDs);
}
Program: 61051
Project: 61051
Buggy source:
/** 
 * Creates the chunk either onheap or offheap
 * @param pool indicates if the chunks have to be created which will be used by the Pool
 * @return the chunk
 */
private Chunk createChunk(boolean pool){
}

Fixed version (ground truth):
/** 
 * Creates the chunk either onheap or offheap
 * @param pool indicates if the chunks have to be created which will be used by the Pool
 * @param chunkIndexType
 * @return the chunk
 */
private Chunk createChunk(boolean pool,CompactingMemStore.IndexType chunkIndexType){
}
Program: 61052
Project: 61052
Buggy source:
/** 
 * Poll a chunk from the pool, reset it if not null, else create a new chunk to return if we have not yet created max allowed chunks count. When we have already created max allowed chunks and no free chunks as of now, return null. It is the responsibility of the caller to make a chunk then. Note: Chunks returned by this pool must be put back to the pool after its use.
 * @return a chunk
 * @see #putbackChunks(Set)
 */
Chunk getChunk(){
  Chunk chunk=reclaimedChunks.poll();
  if (chunk != null) {
    chunk.reset();
    reusedChunkCount.incrementAndGet();
  }
 else {
    while (true) {
      long created=this.chunkCount.get();
      if (created < this.maxCount) {
        if (this.chunkCount.compareAndSet(created,created + 1)) {
          chunk=createChunk(true);
          break;
        }
      }
 else {
        break;
      }
    }
  }
  return chunk;
}

Fixed version (ground truth):
/** 
 * Poll a chunk from the pool, reset it if not null, else create a new chunk to return if we have not yet created max allowed chunks count. When we have already created max allowed chunks and no free chunks as of now, return null. It is the responsibility of the caller to make a chunk then. Note: Chunks returned by this pool must be put back to the pool after its use.
 * @return a chunk
 * @see #putbackChunks(Chunk)
 */
Chunk getChunk(){
  Chunk chunk=reclaimedChunks.poll();
  if (chunk != null) {
    chunk.reset();
    reusedChunkCount.incrementAndGet();
  }
 else {
    while (true) {
      long created=this.chunkCount.get();
      if (created < this.maxCount) {
        if (this.chunkCount.compareAndSet(created,created + 1)) {
          chunk=createChunk(true,CompactingMemStore.IndexType.ARRAY_MAP);
          break;
        }
      }
 else {
        break;
      }
    }
  }
  return chunk;
}
Program: 61053
Project: 61053
Buggy source:
MemStoreChunkPool(int maxCount,int initialCount,float poolSizePercentage){
  this.maxCount=maxCount;
  this.poolSizePercentage=poolSizePercentage;
  this.reclaimedChunks=new LinkedBlockingQueue<>();
  for (int i=0; i < initialCount; i++) {
    Chunk chunk=createChunk(true);
    chunk.init();
    reclaimedChunks.add(chunk);
  }
  chunkCount.set(initialCount);
  final String n=Thread.currentThread().getName();
  scheduleThreadPool=Executors.newScheduledThreadPool(1,new ThreadFactoryBuilder().setNameFormat(n + "String_Node_Str").setDaemon(true).build());
  this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(),statThreadPeriod,statThreadPeriod,TimeUnit.SECONDS);
}

Fixed version (ground truth):
MemStoreChunkPool(int maxCount,int initialCount,float poolSizePercentage){
  this.maxCount=maxCount;
  this.poolSizePercentage=poolSizePercentage;
  this.reclaimedChunks=new LinkedBlockingQueue<>();
  for (int i=0; i < initialCount; i++) {
    Chunk chunk=createChunk(true,CompactingMemStore.IndexType.ARRAY_MAP);
    chunk.init();
    reclaimedChunks.add(chunk);
  }
  chunkCount.set(initialCount);
  final String n=Thread.currentThread().getName();
  scheduleThreadPool=Executors.newScheduledThreadPool(1,new ThreadFactoryBuilder().setNameFormat(n + "String_Node_Str").setDaemon(true).build());
  this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(),statThreadPeriod,statThreadPeriod,TimeUnit.SECONDS);
}
Program: 61054
Project: 61054
Buggy source:
Chunk removeChunk(int chunkId){
  WeakReference<Chunk> weak=this.weakChunkIdMap.remove(chunkId);
  Chunk strong=this.strongChunkIdMap.remove(chunkId);
  if (weak != null) {
    return weak.get();
  }
  return strong;
}

Fixed version (ground truth):
Chunk removeChunk(int chunkId){
  return this.chunkIdMap.remove(chunkId);
}
Program: 61055
Project: 61055
Buggy source:
@VisibleForTesting void clearChunkIds(){
  this.strongChunkIdMap.clear();
  this.weakChunkIdMap.clear();
}

Fixed version (ground truth):
@VisibleForTesting void clearChunkIds(){
  this.chunkIdMap.clear();
}
Program: 61056
Project: 61056
Buggy source:
/** 
 * Initializes the instance of MSLABChunkCreator
 * @param chunkSize the chunkSize
 * @param offheap indicates if the chunk is to be created offheap or not
 * @param globalMemStoreSize  the global memstore size
 * @param poolSizePercentage pool size percentage
 * @param initialCountPercentage the initial count of the chunk pool if any
 * @param heapMemoryManager the heapmemory manager
 * @return singleton MSLABChunkCreator
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") @VisibleForTesting public static ChunkCreator initialize(int chunkSize,boolean offheap,long globalMemStoreSize,float poolSizePercentage,float initialCountPercentage,HeapMemoryManager heapMemoryManager){
  if (INSTANCE != null)   return INSTANCE;
  INSTANCE=new ChunkCreator(chunkSize,offheap,globalMemStoreSize,poolSizePercentage,initialCountPercentage,heapMemoryManager);
  return INSTANCE;
}

Fixed version (ground truth):
/** 
 * Initializes the instance of ChunkCreator
 * @param chunkSize the chunkSize
 * @param offheap indicates if the chunk is to be created offheap or not
 * @param globalMemStoreSize  the global memstore size
 * @param poolSizePercentage pool size percentage
 * @param initialCountPercentage the initial count of the chunk pool if any
 * @param heapMemoryManager the heapmemory manager
 * @return singleton MSLABChunkCreator
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") @VisibleForTesting public static ChunkCreator initialize(int chunkSize,boolean offheap,long globalMemStoreSize,float poolSizePercentage,float initialCountPercentage,HeapMemoryManager heapMemoryManager){
  if (INSTANCE != null)   return INSTANCE;
  INSTANCE=new ChunkCreator(chunkSize,offheap,globalMemStoreSize,poolSizePercentage,initialCountPercentage,heapMemoryManager);
  return INSTANCE;
}
Program: 61057
Project: 61057
Buggy source:
synchronized void putbackChunks(Set<Integer> chunks){
  if (pool != null) {
    pool.putbackChunks(chunks);
  }
 else {
    this.removeChunks(chunks);
  }
}

Fixed version (ground truth):
synchronized void putbackChunks(Set<Integer> chunks){
  if (pool == null) {
    this.removeChunks(chunks);
    return;
  }
  for (  int chunkID : chunks) {
    Chunk chunk=ChunkCreator.this.getChunk(chunkID);
    if (chunk != null) {
      pool.putbackChunks(chunk);
    }
  }
  return;
}
Program: 61058
Project: 61058
Buggy source:
private void replaceAtIndex(int idx,ImmutableSegment newSegment){
  pipeline.set(idx,newSegment);
  readOnlyCopy=new LinkedList<>(pipeline);
}

Fixed version (ground truth):
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") private void replaceAtIndex(int idx,ImmutableSegment newSegment){
  pipeline.set(idx,newSegment);
  readOnlyCopy=new LinkedList<>(pipeline);
  version++;
}
Program: 61059
Project: 61059
Buggy source:
private void swapSuffix(List<? extends Segment> suffix,ImmutableSegment segment,boolean closeSegmentsInSuffix){
  if (closeSegmentsInSuffix) {
    for (    Segment itemInSuffix : suffix) {
      itemInSuffix.close();
    }
  }
  pipeline.removeAll(suffix);
  if (segment != null)   pipeline.addLast(segment);
}

Fixed version (ground truth):
private void swapSuffix(List<? extends Segment> suffix,ImmutableSegment segment,boolean closeSegmentsInSuffix){
  pipeline.removeAll(suffix);
  if (segment != null)   pipeline.addLast(segment);
  if (closeSegmentsInSuffix) {
    for (    Segment itemInSuffix : suffix) {
      itemInSuffix.close();
    }
  }
}
Program: 61060
Project: 61060
Buggy source:
@Override public Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions,List<ServerName> servers) throws HBaseIOException {
  Map<ServerName,List<HRegionInfo>> assignments=Maps.newHashMap();
  ListMultimap<String,HRegionInfo> regionMap=ArrayListMultimap.create();
  ListMultimap<String,ServerName> serverMap=ArrayListMultimap.create();
  generateGroupMaps(regions,servers,regionMap,serverMap);
  for (  String groupKey : regionMap.keySet()) {
    if (regionMap.get(groupKey).size() > 0) {
      Map<ServerName,List<HRegionInfo>> result=this.internalBalancer.roundRobinAssignment(regionMap.get(groupKey),serverMap.get(groupKey));
      if (result != null) {
        assignments.putAll(result);
      }
    }
  }
  return assignments;
}

Fixed version (ground truth):
@Override public Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions,List<ServerName> servers) throws HBaseIOException {
  Map<ServerName,List<HRegionInfo>> assignments=Maps.newHashMap();
  ListMultimap<String,HRegionInfo> regionMap=ArrayListMultimap.create();
  ListMultimap<String,ServerName> serverMap=ArrayListMultimap.create();
  generateGroupMaps(regions,servers,regionMap,serverMap);
  for (  String groupKey : regionMap.keySet()) {
    if (regionMap.get(groupKey).size() > 0) {
      Map<ServerName,List<HRegionInfo>> result=this.internalBalancer.roundRobinAssignment(regionMap.get(groupKey),serverMap.get(groupKey));
      if (result != null) {
        if (result.containsKey(LoadBalancer.BOGUS_SERVER_NAME) && assignments.containsKey(LoadBalancer.BOGUS_SERVER_NAME)) {
          assignments.get(LoadBalancer.BOGUS_SERVER_NAME).addAll(result.get(LoadBalancer.BOGUS_SERVER_NAME));
        }
 else {
          assignments.putAll(result);
        }
      }
    }
  }
  return assignments;
}
Program: 61062
Project: 61062
Buggy source:
@Override public Result[] addAndGet(Result[] results,boolean isHeartbeatMessage) throws IOException {
  if (results.length == 0) {
    return EMPTY_RESULT_ARRAY;
  }
  int i;
  for (i=0; i < results.length; i++) {
    Result r=filterCells(results[i],lastCell);
    if (r != null) {
      results[i]=r;
      break;
    }
  }
  if (i == results.length) {
    return EMPTY_RESULT_ARRAY;
  }
  updateLastCell(results[results.length - 1]);
  if (i > 0) {
    return Arrays.copyOfRange(results,i,results.length);
  }
 else {
    return results;
  }
}

Fixed version (ground truth):
@Override public Result[] addAndGet(Result[] results,boolean isHeartbeatMessage) throws IOException {
  if (results.length == 0) {
    if (!isHeartbeatMessage && lastResultPartial) {
      numberOfCompleteRows++;
    }
    return EMPTY_RESULT_ARRAY;
  }
  int i;
  for (i=0; i < results.length; i++) {
    Result r=filterCells(results[i],lastCell);
    if (r != null) {
      results[i]=r;
      break;
    }
  }
  if (i == results.length) {
    return EMPTY_RESULT_ARRAY;
  }
  if (lastResultPartial && !CellUtil.matchingRow(lastCell,results[0].getRow())) {
    numberOfCompleteRows++;
  }
  recordLastResult(results[results.length - 1]);
  if (i > 0) {
    results=Arrays.copyOfRange(results,i,results.length);
  }
  for (  Result result : results) {
    if (!result.mayHaveMoreCellsInRow()) {
      numberOfCompleteRows++;
    }
  }
  return results;
}
Program: 61063
Project: 61063
Buggy source:
synchronized boolean prepare(ScanResponse resp,int numberOfIndividualRows){
  if (state == ScanResumerState.RESUMED) {
    return false;
  }
  state=ScanResumerState.SUSPENDED;
  this.resp=resp;
  this.numberOfIndividualRows=numberOfIndividualRows;
  if (resp.getMoreResultsInRegion()) {
    scheduleRenewLeaseTask();
  }
  return true;
}

Fixed version (ground truth):
synchronized boolean prepare(ScanResponse resp,int numberOfCompleteRows){
  if (state == ScanResumerState.RESUMED) {
    return false;
  }
  state=ScanResumerState.SUSPENDED;
  this.resp=resp;
  this.numberOfCompleteRows=numberOfCompleteRows;
  if (resp.getMoreResultsInRegion()) {
    scheduleRenewLeaseTask();
  }
  return true;
}
Program: 61064
Project: 61064
Buggy source:
private void completeOrNext(ScanResponse resp,int numIndividualRows){
}

Fixed version (ground truth):
private void completeOrNext(ScanResponse resp,int numberOfCompleteRows){
}
Program: 61065
Project: 61065
Buggy source:
@Override public void resume(){
  ScanResponse localResp;
  int localNumberOfIndividualRows;
synchronized (this) {
    if (state == ScanResumerState.INITIALIZED) {
      state=ScanResumerState.RESUMED;
      return;
    }
    if (state == ScanResumerState.RESUMED) {
      return;
    }
    state=ScanResumerState.RESUMED;
    if (leaseRenewer != null) {
      leaseRenewer.cancel();
    }
    localResp=this.resp;
    localNumberOfIndividualRows=this.numberOfIndividualRows;
  }
  completeOrNext(localResp,localNumberOfIndividualRows);
}

Fixed version (ground truth):
@Override public void resume(){
  ScanResponse localResp;
  int localNumberOfCompleteRows;
synchronized (this) {
    if (state == ScanResumerState.INITIALIZED) {
      state=ScanResumerState.RESUMED;
      return;
    }
    if (state == ScanResumerState.RESUMED) {
      return;
    }
    state=ScanResumerState.RESUMED;
    if (leaseRenewer != null) {
      leaseRenewer.cancel();
    }
    localResp=this.resp;
    localNumberOfCompleteRows=this.numberOfCompleteRows;
  }
  completeOrNext(localResp,localNumberOfCompleteRows);
}
Program: 61066
Project: 61066
Buggy source:
private void onComplete(HBaseRpcController controller,ScanResponse resp){
  if (controller.failed()) {
    onError(controller.getFailed());
    return;
  }
  updateServerSideMetrics(scanMetrics,resp);
  boolean isHeartbeatMessage=resp.hasHeartbeatMessage() && resp.getHeartbeatMessage();
  Result[] results;
  try {
    Result[] rawResults=ResponseConverter.getResults(controller.cellScanner(),resp);
    updateResultsMetrics(scanMetrics,rawResults,isHeartbeatMessage);
    results=resultCache.addAndGet(Optional.ofNullable(rawResults).orElse(ScanResultCache.EMPTY_RESULT_ARRAY),isHeartbeatMessage);
  }
 catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    completeWhenError(true);
    return;
  }
  int numberOfIndividualRows=numberOfIndividualRows(Arrays.asList(results));
  ScanControllerImpl scanController=new ScanControllerImpl();
  if (results.length == 0) {
    consumer.onHeartbeat(scanController);
  }
 else {
    updateNextStartRowWhenError(results[results.length - 1]);
    consumer.onNext(results,scanController);
  }
  ScanControllerState state=scanController.destroy();
  if (state == ScanControllerState.TERMINATED) {
    if (resp.getMoreResultsInRegion()) {
      closeScanner();
    }
    completeNoMoreResults();
    return;
  }
  if (state == ScanControllerState.SUSPENDED) {
    if (scanController.resumer.prepare(resp,numberOfIndividualRows)) {
      return;
    }
  }
  completeOrNext(resp,numberOfIndividualRows);
}

Fixed version (ground truth):
private void onComplete(HBaseRpcController controller,ScanResponse resp){
  if (controller.failed()) {
    onError(controller.getFailed());
    return;
  }
  updateServerSideMetrics(scanMetrics,resp);
  boolean isHeartbeatMessage=resp.hasHeartbeatMessage() && resp.getHeartbeatMessage();
  Result[] results;
  int numberOfCompleteRowsBefore=resultCache.numberOfCompleteRows();
  try {
    Result[] rawResults=ResponseConverter.getResults(controller.cellScanner(),resp);
    updateResultsMetrics(scanMetrics,rawResults,isHeartbeatMessage);
    results=resultCache.addAndGet(Optional.ofNullable(rawResults).orElse(ScanResultCache.EMPTY_RESULT_ARRAY),isHeartbeatMessage);
  }
 catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    completeWhenError(true);
    return;
  }
  ScanControllerImpl scanController=new ScanControllerImpl();
  if (results.length > 0) {
    updateNextStartRowWhenError(results[results.length - 1]);
    consumer.onNext(results,scanController);
  }
 else   if (resp.hasHeartbeatMessage() && resp.getHeartbeatMessage()) {
    consumer.onHeartbeat(scanController);
  }
  ScanControllerState state=scanController.destroy();
  if (state == ScanControllerState.TERMINATED) {
    if (resp.getMoreResultsInRegion()) {
      closeScanner();
    }
    completeNoMoreResults();
    return;
  }
  int numberOfCompleteRows=resultCache.numberOfCompleteRows() - numberOfCompleteRowsBefore;
  if (state == ScanControllerState.SUSPENDED) {
    if (scanController.resumer.prepare(resp,numberOfCompleteRows)) {
      return;
    }
  }
  completeOrNext(resp,numberOfCompleteRows);
}
Program: 61067
Project: 61067
Buggy source:
private Result createCompletedResult() throws IOException {
  Result result=Result.createCompleteResult(partialResults);
  partialResults.clear();
  numCellsOfPartialResults=0;
  return result;
}

Fixed version (ground truth):
private Result createCompletedResult() throws IOException {
  numberOfCompleteRows++;
  Result result=Result.createCompleteResult(partialResults);
  partialResults.clear();
  numCellsOfPartialResults=0;
  return result;
}
Program: 61068
Project: 61068
Buggy source:
@Override public Result[] addAndGet(Result[] results,boolean isHeartbeatMessage) throws IOException {
  if (results.length == 0) {
    if (!partialResults.isEmpty() && !isHeartbeatMessage) {
      return new Result[]{createCompletedResult()};
    }
    return EMPTY_RESULT_ARRAY;
  }
  List<Result> regroupedResults=new ArrayList<>();
  for (  Result result : results) {
    result=filterCells(result,lastCell);
    if (result == null) {
      continue;
    }
    if (!partialResults.isEmpty() && !Bytes.equals(partialResults.peek().getRow(),result.getRow())) {
      regroupedResults.add(createCompletedResult());
    }
    Result regroupedResult=regroupResults(result);
    if (regroupedResult != null) {
      regroupedResults.add(regroupedResult);
      updateLastCell(regroupedResult);
    }
    if (!result.mayHaveMoreCellsInRow() && !partialResults.isEmpty()) {
      regroupedResults.add(createCompletedResult());
    }
  }
  return regroupedResults.toArray(new Result[0]);
}

Fixed version (ground truth):
@Override public Result[] addAndGet(Result[] results,boolean isHeartbeatMessage) throws IOException {
  if (results.length == 0) {
    if (!isHeartbeatMessage) {
      if (!partialResults.isEmpty()) {
        return new Result[]{createCompletedResult()};
      }
      if (lastResultPartial) {
        numberOfCompleteRows++;
      }
    }
    return EMPTY_RESULT_ARRAY;
  }
  List<Result> regroupedResults=new ArrayList<>();
  for (  Result result : results) {
    result=filterCells(result,lastCell);
    if (result == null) {
      continue;
    }
    if (!partialResults.isEmpty()) {
      if (!Bytes.equals(partialResults.peek().getRow(),result.getRow())) {
        regroupedResults.add(createCompletedResult());
      }
    }
 else     if (lastResultPartial && !CellUtil.matchingRow(lastCell,result.getRow())) {
      numberOfCompleteRows++;
    }
    if (!partialResults.isEmpty() && !Bytes.equals(partialResults.peek().getRow(),result.getRow())) {
      regroupedResults.add(createCompletedResult());
    }
    Result regroupedResult=regroupResults(result);
    if (regroupedResult != null) {
      if (!regroupedResult.mayHaveMoreCellsInRow()) {
        numberOfCompleteRows++;
      }
      regroupedResults.add(regroupedResult);
      recordLastResult(regroupedResult);
    }
    if (!result.mayHaveMoreCellsInRow() && !partialResults.isEmpty()) {
      regroupedResults.add(createCompletedResult());
    }
  }
  return regroupedResults.toArray(new Result[0]);
}
Program: 61071
Project: 61071
Buggy source:
@Override public List<Segment> getSegments(){
  List<Segment> pipelineList=pipeline.getSegments();
  List<Segment> list=new ArrayList<Segment>(pipelineList.size() + 2);
  list.add(this.active);
  list.addAll(pipelineList);
  list.add(this.snapshot);
  return list;
}

Fixed version (ground truth):
@VisibleForTesting @Override protected List<Segment> getSegments(){
  List<Segment> pipelineList=pipeline.getSegments();
  List<Segment> list=new ArrayList<Segment>(pipelineList.size() + 2);
  list.add(this.active);
  list.addAll(pipelineList);
  list.add(this.snapshot);
  return list;
}
Program: 61072
Project: 61072
Buggy source:
private void pushTailToSnapshot(){
  ImmutableSegment tail=pipeline.pullTail();
  if (!tail.isEmpty()) {
    this.snapshot=tail;
  }
}

Fixed version (ground truth):
private void pushTailToSnapshot(){
  VersionedSegmentsList segments=pipeline.getVersionedTail();
  pushToSnapshot(segments.getStoreSegments());
  pipeline.swap(segments,null,false);
}
Program: 61074
Project: 61074
Buggy source:
public VersionedSegmentsList getVersionedList(){
synchronized (pipeline) {
    LinkedList<ImmutableSegment> segmentList=new LinkedList<ImmutableSegment>(pipeline);
    VersionedSegmentsList res=new VersionedSegmentsList(segmentList,version);
    return res;
  }
}

Fixed version (ground truth):
public VersionedSegmentsList getVersionedList(){
synchronized (pipeline) {
    List<ImmutableSegment> segmentList=new ArrayList<>(pipeline);
    return new VersionedSegmentsList(segmentList,version);
  }
}
Program: 61075
Project: 61075
Buggy source:
private void swapSuffix(List<ImmutableSegment> suffix,ImmutableSegment segment,boolean closeSegmentsInSuffix){
  version++;
  if (closeSegmentsInSuffix) {
    for (    Segment itemInSuffix : suffix) {
      itemInSuffix.close();
    }
  }
  pipeline.removeAll(suffix);
  pipeline.addLast(segment);
}

Fixed version (ground truth):
private void swapSuffix(List<ImmutableSegment> suffix,ImmutableSegment segment,boolean closeSegmentsInSuffix){
  version++;
  if (closeSegmentsInSuffix) {
    for (    Segment itemInSuffix : suffix) {
      itemInSuffix.close();
    }
  }
  pipeline.removeAll(suffix);
  if (segment != null)   pipeline.addLast(segment);
}
Program: 61076
Project: 61076
Buggy source:
public CompactionPipeline(RegionServicesForStores region){
  this.region=region;
  this.pipeline=new LinkedList<ImmutableSegment>();
  this.version=0;
}

Fixed version (ground truth):
public CompactionPipeline(RegionServicesForStores region){
  this.region=region;
  this.pipeline=new LinkedList<>();
  this.version=0;
}
Program: 61077
Project: 61077
Buggy source:
public List<Segment> getSegments(){
synchronized (pipeline) {
    List<Segment> res=new LinkedList<Segment>(pipeline);
    return res;
  }
}

Fixed version (ground truth):
public List<Segment> getSegments(){
synchronized (pipeline) {
    return new LinkedList<>(pipeline);
  }
}
Program: 61078
Project: 61078
Buggy source:
public VersionedSegmentsList(LinkedList<ImmutableSegment> storeSegments,long version){
  this.storeSegments=storeSegments;
  this.version=version;
}

Fixed version (ground truth):
public VersionedSegmentsList(List<ImmutableSegment> storeSegments,long version){
  this.storeSegments=storeSegments;
  this.version=version;
}
Program: 61079
Project: 61079
Buggy source:
@BeforeClass public static void setUp() throws Exception {
  TEST_UTIL.getConfiguration().set(TABLES_ON_MASTER,"String_Node_Str");
  TEST_UTIL.getConfiguration().setLong(HBASE_CLIENT_META_OPERATION_TIMEOUT,60000L);
  TEST_UTIL.getConfiguration().setLong(HBASE_RPC_READ_TIMEOUT_KEY,1000L);
  TEST_UTIL.getConfiguration().setInt(HBASE_CLIENT_RETRIES_NUMBER,1000);
  TEST_UTIL.getConfiguration().setInt(ByteBufferPool.MAX_POOL_SIZE_KEY,100);
  TEST_UTIL.startMiniCluster(5);
  SPLIT_KEYS=new byte[8][];
  for (int i=111; i < 999; i+=111) {
    SPLIT_KEYS[i / 111 - 1]=Bytes.toBytes(String.format("String_Node_Str",i));
  }
  TEST_UTIL.createTable(TABLE_NAME,FAMILY);
  TEST_UTIL.waitTableAvailable(TABLE_NAME);
  CONN=ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration());
  CONN.getRawTable(TABLE_NAME).putAll(IntStream.range(0,COUNT).mapToObj(i -> new Put(Bytes.toBytes(String.format("String_Node_Str",i))).addColumn(FAMILY,QUALIFIER,Bytes.toBytes(i))).collect(Collectors.toList())).get();
}

Fixed version (ground truth):
protected static void setUp(HColumnDescriptor.MemoryCompaction memoryCompaction) throws Exception {
  TEST_UTIL.getConfiguration().set(TABLES_ON_MASTER,"String_Node_Str");
  TEST_UTIL.getConfiguration().setLong(HBASE_CLIENT_META_OPERATION_TIMEOUT,60000L);
  TEST_UTIL.getConfiguration().setLong(HBASE_RPC_READ_TIMEOUT_KEY,1000L);
  TEST_UTIL.getConfiguration().setInt(HBASE_CLIENT_RETRIES_NUMBER,1000);
  TEST_UTIL.getConfiguration().setInt(ByteBufferPool.MAX_POOL_SIZE_KEY,100);
  TEST_UTIL.getConfiguration().set(CompactingMemStore.COMPACTING_MEMSTORE_TYPE_KEY,String.valueOf(memoryCompaction));
  TEST_UTIL.startMiniCluster(5);
  SPLIT_KEYS=new byte[8][];
  for (int i=111; i < 999; i+=111) {
    SPLIT_KEYS[i / 111 - 1]=Bytes.toBytes(String.format("String_Node_Str",i));
  }
  TEST_UTIL.createTable(TABLE_NAME,FAMILY);
  TEST_UTIL.waitTableAvailable(TABLE_NAME);
  CONN=ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration());
  CONN.getRawTable(TABLE_NAME).putAll(IntStream.range(0,COUNT).mapToObj(i -> new Put(Bytes.toBytes(String.format("String_Node_Str",i))).addColumn(FAMILY,QUALIFIER,Bytes.toBytes(i))).collect(Collectors.toList())).get();
}
Program: 61080
Project: 61080
Buggy source:
private void run(AtomicBoolean stop) throws InterruptedException, ExecutionException {
  while (!stop.get()) {
    int i=ThreadLocalRandom.current().nextInt(COUNT);
    assertEquals(i,Bytes.toInt(CONN.getRawTable(TABLE_NAME).get(new Get(Bytes.toBytes(String.format("String_Node_Str",i)))).get().getValue(FAMILY,QUALIFIER)));
  }
}

Fixed version (ground truth):
private void run(AtomicBoolean stop) throws InterruptedException, ExecutionException {
  while (!stop.get()) {
    for (int i=0; i < COUNT; i++) {
      assertEquals(i,Bytes.toInt(CONN.getRawTable(TABLE_NAME).get(new Get(Bytes.toBytes(String.format("String_Node_Str",i)))).get().getValue(FAMILY,QUALIFIER)));
    }
  }
}
Program: 61082
Project: 61082
Buggy source:
public BufferedMutatorParams clone(){
  BufferedMutatorParams clone=new BufferedMutatorParams(this.tableName);
  clone.writeBufferSize=this.writeBufferSize;
  clone.maxKeyValueSize=maxKeyValueSize;
  clone.pool=this.pool;
  clone.listener=this.listener;
  clone.implementationClassName=this.implementationClassName;
  return clone;
}

Fixed version (ground truth):
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") public BufferedMutatorParams clone(){
  BufferedMutatorParams clone=new BufferedMutatorParams(this.tableName);
  clone.writeBufferSize=this.writeBufferSize;
  clone.maxKeyValueSize=maxKeyValueSize;
  clone.pool=this.pool;
  clone.listener=this.listener;
  clone.implementationClassName=this.implementationClassName;
  return clone;
}
Program: 61084
Project: 61084
Buggy source:
/** 
 * Bulkloads the current file.
 * @param connection to use to get admin/RegionLocator
 * @param table The current table.
 * @param bulkloadDirectory The path of bulkload directory.
 * @param fileName The current file name.
 * @throws IOException if IO failure is encountered
 */
private void bulkloadRefFile(Connection connection,Table table,Path bulkloadDirectory,String fileName) throws IOException {
  try {
    LoadIncrementalHFiles bulkload=new LoadIncrementalHFiles(conf);
    bulkload.doBulkLoad(bulkloadDirectory,connection.getAdmin(),table,connection.getRegionLocator(table.getName()));
  }
 catch (  Exception e) {
    throw new IOException(e);
  }
}

Fixed version (ground truth):
/** 
 * Bulkloads the current file.
 * @param connection to use to get admin/RegionLocator
 * @param table The current table.
 * @param bulkloadDirectory The path of bulkload directory.
 * @param fileName The current file name.
 * @throws IOException if IO failure is encountered
 */
private void bulkloadRefFile(Connection connection,Table table,Path bulkloadDirectory,String fileName) throws IOException {
  try {
    LoadIncrementalHFiles bulkload=new LoadIncrementalHFiles(conf);
    bulkload.doBulkLoad(bulkloadDirectory,connection.getAdmin(),table,connection.getRegionLocator(table.getName()));
  }
 catch (  Exception e) {
    deletePath(new Path(mobFamilyDir,fileName));
    throw new IOException(e);
  }
 finally {
    deletePath(bulkloadDirectory);
  }
}
Program: 61086
Project: 61086
Buggy source:
private void createStoreFiles(Path basePath,String family,String qualifier,int count,Type type,boolean sameStartKey) throws IOException {
  HFileContext meta=new HFileContextBuilder().withBlockSize(8 * 1024).build();
  String startKey="String_Node_Str";
  MobFileName mobFileName=null;
  for (int i=0; i < count; i++) {
    byte[] startRow;
    if (sameStartKey) {
      startRow=Bytes.toBytes(startKey);
      mobSuffix=UUID.randomUUID().toString().replaceAll("String_Node_Str","String_Node_Str");
      delSuffix=UUID.randomUUID().toString().replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str";
    }
 else {
      startRow=Bytes.toBytes(startKey + i);
    }
    if (type.equals(Type.Delete)) {
      mobFileName=MobFileName.create(startRow,MobUtils.formatDate(new Date()),delSuffix);
    }
    if (type.equals(Type.Put)) {
      mobFileName=MobFileName.create(startRow,MobUtils.formatDate(new Date()),mobSuffix);
    }
    StoreFileWriter mobFileWriter=new StoreFileWriter.Builder(conf,cacheConf,fs).withFileContext(meta).withFilePath(new Path(basePath,mobFileName.getFileName())).build();
    writeStoreFile(mobFileWriter,startRow,Bytes.toBytes(family),Bytes.toBytes(qualifier),type,(i + 1) * 1000);
  }
}

Fixed version (ground truth):
/** 
 * Creates store files.
 * @param basePath the path to create file
 * @family the family name
 * @qualifier the column qualifier
 * @count the store file number
 * @type the key type
 */
private void createStoreFiles(Path basePath,String family,String qualifier,int count,Type type) throws IOException {
  HFileContext meta=new HFileContextBuilder().withBlockSize(8 * 1024).build();
  String startKey="String_Node_Str";
  MobFileName mobFileName=null;
  for (int i=0; i < count; i++) {
    byte[] startRow=Bytes.toBytes(startKey + i);
    if (type.equals(Type.Delete)) {
      mobFileName=MobFileName.create(startRow,MobUtils.formatDate(new Date()),delSuffix);
    }
    if (type.equals(Type.Put)) {
      mobFileName=MobFileName.create(Bytes.toBytes(startKey + i),MobUtils.formatDate(new Date()),mobSuffix);
    }
    StoreFileWriter mobFileWriter=new StoreFileWriter.Builder(conf,cacheConf,fs).withFileContext(meta).withFilePath(new Path(basePath,mobFileName.getFileName())).build();
    writeStoreFile(mobFileWriter,startRow,Bytes.toBytes(family),Bytes.toBytes(qualifier),type,(i + 1) * 1000);
  }
}
Program: 61087
Project: 61087
Buggy source:
@BeforeClass public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.getConfiguration().setInt("String_Node_Str",3);
  TEST_UTIL.getConfiguration().setClass("String_Node_Str",FaultyDistributedFileSystem.class,DistributedFileSystem.class);
  TEST_UTIL.startMiniCluster(1);
  pool=createThreadPool();
}

Fixed version (ground truth):
@BeforeClass public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.getConfiguration().setInt("String_Node_Str",3);
  TEST_UTIL.startMiniCluster(1);
  pool=createThreadPool();
}
Program: 61088
Project: 61088
Buggy source:
/** 
 * Bulkloads the current file.
 * @param connection to use to get admin/RegionLocator
 * @param table The current table.
 * @param bulkloadDirectory The path of bulkload directory.
 * @param fileName The current file name.
 * @throws IOException if IO failure is encountered
 */
private void bulkloadRefFile(Connection connection,Table table,Path bulkloadDirectory,String fileName) throws IOException {
  try {
    LoadIncrementalHFiles bulkload=new LoadIncrementalHFiles(conf);
    bulkload.doBulkLoad(bulkloadDirectory,connection.getAdmin(),table,connection.getRegionLocator(table.getName()));
  }
 catch (  Exception e) {
    deletePath(new Path(mobFamilyDir,fileName));
    throw new IOException(e);
  }
 finally {
    deletePath(bulkloadDirectory);
  }
}

Fixed version (ground truth):
/** 
 * Bulkloads the current file.
 * @param connection to use to get admin/RegionLocator
 * @param table The current table.
 * @param bulkloadDirectory The path of bulkload directory.
 * @param fileName The current file name.
 * @throws IOException if IO failure is encountered
 */
private void bulkloadRefFile(Connection connection,Table table,Path bulkloadDirectory,String fileName) throws IOException {
  try {
    LoadIncrementalHFiles bulkload=new LoadIncrementalHFiles(conf);
    bulkload.doBulkLoad(bulkloadDirectory,connection.getAdmin(),table,connection.getRegionLocator(table.getName()));
  }
 catch (  Exception e) {
    throw new IOException(e);
  }
}