nus-yam/ex-repair huggingface dataset:
Program: 81193
Project: 81193
Buggy source:
public TrimPersistedBatchReadyListener(File file,SerializationStrategy<E,T> serializationStrategy,Handler handler,int maxQueueSize,int trimToSize,int mode,PersistedBatchCallback<T> persistedBatchCallback,TrimmedBatchCallback trimmedBatchCallback){
  super(file,serializationStrategy,handler,persistedBatchCallback);
  if (trimToSize > maxQueueSize) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.trimSize=trimToSize;
  this.queueSize=maxQueueSize;
  this.handler=handler;
  this.mode=mode;
  this.trimListener=trimmedBatchCallback;
}

Fixed version (ground truth):
public TrimPersistedBatchReadyListener(File file,SerializationStrategy<E,T> serializationStrategy,Handler handler,int maxQueueSize,int trimSize,int mode,PersistedBatchCallback<T> persistedBatchCallback,TrimmedBatchCallback trimmedBatchCallback){
  super(file,serializationStrategy,handler,persistedBatchCallback);
  if (trimSize > maxQueueSize) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.trimSize=trimSize;
  this.queueSize=maxQueueSize;
  this.handler=handler;
  this.mode=mode;
  this.trimListener=trimmedBatchCallback;
}
Program: 81194
Project: 81194
Buggy source:
/** 
 * Backoff time to retry the batch for 5XX Server errors.
 * @return
 */
private int exponentialBackOff(){
  mCurrentTimeoutMs+=(mCurrentTimeoutMs * defaultBackoffMultiplier);
  return mCurrentTimeoutMs;
}

Fixed version (ground truth):
/** 
 * Backoff time to retry the batch for 5XX Server errors.
 * @return
 */
private int exponentialBackOff(){
  int timeout=mCurrentTimeoutMs;
  mCurrentTimeoutMs+=(mCurrentTimeoutMs * defaultBackoffMultiplier);
  return timeout;
}
Program: 81195
Project: 81195
Buggy source:
public void setDefaultTimeoutMs(int defaultTimeoutMs){
  this.defaultTimeoutMs=defaultTimeoutMs;
}

Fixed version (ground truth):
public void setDefaultTimeoutMs(int defaultTimeoutMs){
  this.defaultTimeoutMs=defaultTimeoutMs;
  this.mCurrentTimeoutMs=defaultTimeoutMs;
}
Program: 81196
Project: 81196
Buggy source:
@Override public boolean equals(Object o){
  if (o instanceof SizeBatch) {
    return ((SizeBatch)o).getMaxBatchSize() == maxBatchSize;
  }
  return super.equals(o);
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (o instanceof SizeBatch) {
    return ((SizeBatch)o).getMaxBatchSize() == maxBatchSize && super.equals(o);
  }
  return super.equals(o);
}
Program: 81197
Project: 81197
Buggy source:
@Override public boolean equals(Object o){
  if (o instanceof TimeBatch) {
    return ((TimeBatch)o).getTimeOut() == timeOut;
  }
  return super.equals(o);
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (o instanceof TimeBatch) {
    return ((TimeBatch)o).getTimeOut() == timeOut && super.equals(o);
  }
  return super.equals(o);
}
Program: 81201
Project: 81201
Buggy source:
@Override public boolean equals(Object o){
  if (o instanceof DataCollection) {
    return ((DataCollection)o).dataCollection.equals(((DataCollection)o).dataCollection);
  }
 else {
    return super.equals(o);
  }
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (o instanceof DataCollection) {
    return (dataCollection.equals(((DataCollection)o).dataCollection));
  }
 else {
    return super.equals(o);
  }
}
Program: 81205
Project: 81205
Buggy source:
@Test public void testSizeBatchInfo(){
  SizeBatchingStrategy.SizeBatch sizeBatchInfo=new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5),5);
  SizeBatchingStrategy.SizeBatch sizeBatchInfo1=new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5),5);
  Assert.assertTrue(sizeBatchInfo.equals(sizeBatchInfo1));
  Assert.assertTrue(!sizeBatchInfo.equals("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testSizeBatchInfo(){
  ArrayList<Data> list1=Utils.fakeCollection(5);
  ArrayList<Data> list2=new ArrayList<>(list1);
  SizeBatchingStrategy.SizeBatch sizeBatchInfo=new SizeBatchingStrategy.SizeBatch<>(list1,5);
  SizeBatchingStrategy.SizeBatch sizeBatchInfo1=new SizeBatchingStrategy.SizeBatch<>(list2,5);
  Assert.assertTrue(sizeBatchInfo.equals(sizeBatchInfo1));
  Assert.assertTrue(!sizeBatchInfo.equals("String_Node_Str"));
}
Program: 81206
Project: 81206
Buggy source:
@Test public void testTagBatchingInfo(){
  TagBatchingStrategy.TagBatch tagBatchInfo=new TagBatchingStrategy.TagBatch(AD_TAG,new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5),5));
  TagBatchingStrategy.TagBatch tagBatchInfo1=new TagBatchingStrategy.TagBatch(AD_TAG,new SizeBatchingStrategy.SizeBatch<>(Utils.fakeCollection(5),5));
  Assert.assertNotNull(tagBatchInfo.getTag());
  Assert.assertTrue(tagBatchInfo.equals(tagBatchInfo1));
  Assert.assertTrue(!tagBatchInfo.equals("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testTagBatchingInfo(){
  ArrayList<Data> list1=Utils.fakeCollection(5);
  ArrayList<Data> list2=new ArrayList<>(list1);
  TagBatchingStrategy.TagBatch tagBatchInfo=new TagBatchingStrategy.TagBatch(AD_TAG,new SizeBatchingStrategy.SizeBatch<>(list1,5));
  TagBatchingStrategy.TagBatch tagBatchInfo1=new TagBatchingStrategy.TagBatch(AD_TAG,new SizeBatchingStrategy.SizeBatch<>(list2,5));
  Assert.assertNotNull(tagBatchInfo.getTag());
  Assert.assertTrue(tagBatchInfo.equals(tagBatchInfo1));
  Assert.assertTrue(!tagBatchInfo.equals("String_Node_Str"));
}
Program: 81207
Project: 81207
Buggy source:
@Test public void testTimeBatchingInfo(){
  TimeBatchingStrategy.TimeBatch timeBatchInfo=new TimeBatchingStrategy.TimeBatch<>(Utils.fakeCollection(2),5000);
  TimeBatchingStrategy.TimeBatch timeBatchInfo1=new TimeBatchingStrategy.TimeBatch<>(Utils.fakeCollection(2),5000);
  Assert.assertTrue(timeBatchInfo.equals(timeBatchInfo1));
  Assert.assertTrue(!timeBatchInfo.equals("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testTimeBatchingInfo(){
  ArrayList<Data> list1=Utils.fakeCollection(2);
  ArrayList<Data> list2=new ArrayList<>(list1);
  TimeBatchingStrategy.TimeBatch timeBatchInfo=new TimeBatchingStrategy.TimeBatch<>(list1,5000);
  TimeBatchingStrategy.TimeBatch timeBatchInfo1=new TimeBatchingStrategy.TimeBatch<>(list2,5000);
  Assert.assertTrue(timeBatchInfo.equals(timeBatchInfo1));
  Assert.assertTrue(!timeBatchInfo.equals("String_Node_Str"));
}
Program: 81209
Project: 81209
Buggy source:
@Override public void onPersistSuccess(TagBatchingStrategy.TagBatch<TagData> batch){
  SystemClock.sleep(2000);
  dgListener.finish(batch);
  Log.e("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override public void onPersistSuccess(TagBatchingStrategy.TagBatch<TagData> batch){
  dgListener.finish(batch);
  Log.e("String_Node_Str","String_Node_Str");
}
Program: 81210
Project: 81210
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public boolean onNavigationItemSelected(MenuItem item){
  int id=item.getItemId();
  if (id == R.id.nav_camera) {
    batchManager.addToBatch(Collections.singleton(new TagData(perfTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_gallery) {
    batchManager.addToBatch(Collections.singleton(new TagData(dgTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_slideshow) {
    batchManager.addToBatch(Collections.singleton(new TagData(debugTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_manage) {
    batchManager.addToBatch(Collections.singleton(new TagData(perfTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_share) {
    batchManager.addToBatch(Collections.singleton(new TagData(dgTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_send) {
    batchManager.addToBatch(Collections.singleton(new TagData(perfTag,"String_Node_Str")));
  }
  DrawerLayout drawer=(DrawerLayout)findViewById(R.id.drawer_layout);
  drawer.closeDrawer(GravityCompat.START);
  return true;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public boolean onNavigationItemSelected(MenuItem item){
  int id=item.getItemId();
  if (id == R.id.nav_camera) {
    batchManager.addToBatch(Collections.singleton(new TagData(perfTag,"String_Node_Str" + System.currentTimeMillis())));
  }
 else   if (id == R.id.nav_gallery) {
    batchManager.addToBatch(Collections.singleton(new TagData(dgTag,"String_Node_Str" + System.currentTimeMillis())));
  }
 else   if (id == R.id.nav_slideshow) {
    batchManager.addToBatch(Collections.singleton(new TagData(debugTag,"String_Node_Str" + System.currentTimeMillis())));
  }
 else   if (id == R.id.nav_manage) {
    batchManager.addToBatch(Collections.singleton(new TagData(perfTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_share) {
    batchManager.addToBatch(Collections.singleton(new TagData(dgTag,"String_Node_Str")));
  }
 else   if (id == R.id.nav_send) {
    batchManager.addToBatch(Collections.singleton(new TagData(perfTag,"String_Node_Str")));
  }
  DrawerLayout drawer=(DrawerLayout)findViewById(R.id.drawer_layout);
  drawer.closeDrawer(GravityCompat.START);
  return true;
}
Program: 81211
Project: 81211
Buggy source:
@Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer,int par2){
  ItemStack itemstack=null;
  Slot slot=(Slot)this.inventorySlots.get(par2);
  if (slot != null && slot.getHasStack()) {
    ItemStack itemstack1=slot.getStack();
    itemstack=itemstack1.copy();
    if (par2 < 27) {
      if (!this.mergeItemStack(itemstack1,27,63,true)) {
        return null;
      }
    }
 else     if (!this.mergeItemStack(itemstack1,0,27,false)) {
      return null;
    }
    if (itemstack1.stackSize == 0) {
      slot.putStack((ItemStack)null);
    }
 else {
      slot.onSlotChanged();
    }
    if (itemstack1.stackSize == itemstack.stackSize) {
      return null;
    }
    slot.onPickupFromSlot(par1EntityPlayer,itemstack1);
  }
  return itemstack;
}

Fixed version (ground truth):
@Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer,int par2){
  ItemStack itemstack=null;
  Slot slot=(Slot)inventorySlots.get(par2);
  if (slot != null && slot.getHasStack()) {
    ItemStack itemstack1=slot.getStack();
    itemstack=itemstack1.copy();
    if (par2 < 27) {
      if (!mergeItemStack(itemstack1,27,63,true)) {
        return null;
      }
    }
 else     if (!mergeItemStack(itemstack1,0,27,false)) {
      return null;
    }
    if (itemstack1.stackSize == 0) {
      slot.putStack((ItemStack)null);
    }
 else {
      slot.onSlotChanged();
    }
    if (itemstack1.stackSize == itemstack.stackSize) {
      return null;
    }
    slot.onPickupFromSlot(par1EntityPlayer,itemstack1);
  }
  return itemstack;
}
Program: 81212
Project: 81212
Buggy source:
public ContainerCanvasBag(ItemStack bag,IInventory playerInventory,IInventory canvasBagInventory){
  this.bag=bag;
  int i=-1 * 18;
  canvasBagInventory.openInventory();
  for (int j=0; j < 3; ++j) {
    for (int k=0; k < 9; ++k) {
      this.addSlotToContainer(new SlotExclude(canvasBagInventory,k + j * 9,8 + k * 18,18 + j * 18,BPItems.canvas_bag));
    }
  }
  for (int j=0; j < 3; ++j) {
    for (int k=0; k < 9; ++k) {
      this.addSlotToContainer(new Slot(playerInventory,k + j * 9 + 9,8 + k * 18,103 + j * 18 + i));
    }
  }
  for (int j=0; j < 9; ++j) {
    if (playerInventory.getStackInSlot(j) == ((InventoryItem)canvasBagInventory).getItem()) {
      this.addSlotToContainer(new SlotLocked(playerInventory,j,8 + j * 18,161 + i));
    }
 else {
      this.addSlotToContainer(new Slot(playerInventory,j,8 + j * 18,161 + i));
    }
    this.addSlotToContainer(new Slot(playerInventory,j,8 + j * 18,161 + i));
  }
  this.canvasBagInventory=canvasBagInventory;
}

Fixed version (ground truth):
public ContainerCanvasBag(ItemStack bag,IInventory playerInventory,IInventory canvasBagInventory){
  this.bag=bag;
  int i=-1 * 18;
  canvasBagInventory.openInventory();
  for (int j=0; j < 3; ++j) {
    for (int k=0; k < 9; ++k) {
      addSlotToContainer(new SlotExclude(canvasBagInventory,k + j * 9,8 + k * 18,18 + j * 18,BPItems.canvas_bag));
    }
  }
  for (int j=0; j < 3; ++j) {
    for (int k=0; k < 9; ++k) {
      addSlotToContainer(new Slot(playerInventory,k + j * 9 + 9,8 + k * 18,103 + j * 18 + i));
    }
  }
  for (int j=0; j < 9; ++j) {
    if (playerInventory.getStackInSlot(j) == ((InventoryItem)canvasBagInventory).getItem()) {
      addSlotToContainer(new SlotLocked(playerInventory,j,8 + j * 18,161 + i));
    }
 else {
      addSlotToContainer(new Slot(playerInventory,j,8 + j * 18,161 + i));
    }
    addSlotToContainer(new Slot(playerInventory,j,8 + j * 18,161 + i));
  }
  this.canvasBagInventory=canvasBagInventory;
}
Program: 81214
Project: 81214
Buggy source:
private void addOreToGenerate(int veinCount,int veinSize,int minY,int maxY,Block block,World world,int chunkX,int chunkZ){
  Random rand=new Random(Integer.valueOf(chunkX).hashCode() + Integer.valueOf(chunkZ).hashCode());
  for (int i=0; i < veinCount; i++) {
    int x=chunkX * 16 + rand.nextInt(16);
    int y=rand.nextInt(maxY - minY) + minY;
    int z=chunkZ * 16 + rand.nextInt(16);
    (new WorldGenMinable(block,veinSize)).generate(world,rand,x,y,z);
  }
}

Fixed version (ground truth):
private void addOreToGenerate(Random random,int veinCount,int veinSize,int minY,int maxY,Block block,World world,int chunkX,int chunkZ){
  for (int i=0; i < veinCount; i++) {
    int x=chunkX * 16 + random.nextInt(16);
    int y=random.nextInt(maxY - minY) + minY;
    int z=chunkZ * 16 + random.nextInt(16);
    (new WorldGenMinable(block,veinSize)).generate(world,random,x,y,z);
  }
}
Program: 81216
Project: 81216
Buggy source:
/** 
 * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
 */
@Override public boolean canBlockStay(World world,int x,int y,int z){
  if (world.getBlock(x,y,z) != this)   return super.canBlockStay(world,x,y,z);
  if ((world.getBlock(x,y - 1,z) instanceof BlockFarmland) || (world.getBlock(x,y - 1,z) instanceof BlockCrop)) {
    return true;
  }
 else   return false;
}

Fixed version (ground truth):
/** 
 * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
 */
@Override public boolean canBlockStay(World world,int x,int y,int z){
  if (world.getBlock(x,y,z) != this)   return super.canBlockStay(world,x,y,z);
  return (world.getBlock(x,y - 1,z) instanceof BlockFarmland) || (world.getBlock(x,y - 1,z) instanceof BlockCrop);
}
Program: 81219
Project: 81219
Buggy source:
private void generateLavaColumn(World world,int x,int topY,int z,Random rand){
  if (rand.nextDouble() < Config.volcanoActiveToInactiveRatio) {
    world.setBlock(x,topY,z,BPBlocks.cracked_basalt);
  }
 else {
    world.setBlock(x,topY + 1,z,Blocks.lava);
    world.setBlock(x,topY,z,Blocks.lava);
  }
  for (int y=10; y < topY; y++) {
    world.setBlock(x + 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x - 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z + 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z - 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z,Blocks.lava,0,0);
  }
}

Fixed version (ground truth):
private void generateLavaColumn(World world,int x,int topY,int z,Random rand){
  if (rand.nextDouble() < Config.volcanoActiveToInactiveRatio) {
    world.setBlock(x,topY,z,BPBlocks.cracked_basalt);
  }
 else {
    world.setBlock(x,topY + 1,z,Blocks.lava);
    world.setBlock(x,topY,z,Blocks.lava);
  }
  for (int y=topY - 1; y >= 10; y--) {
    world.setBlock(x + 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x - 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z + 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z - 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z,Blocks.lava,0,0);
  }
}
Program: 81220
Project: 81220
Buggy source:
private void generateLavaColumn(World world,int x,int topY,int z,Random rand){
  if (rand.nextDouble() < Config.volcanoActiveToInactiveRatio) {
    world.setBlock(x,topY,z,BPBlocks.cracked_basalt);
  }
 else {
    world.setBlock(x,topY + 1,z,Blocks.lava);
    world.setBlock(x,topY,z,Blocks.lava);
  }
  for (int y=10; y < topY; y++) {
    world.setBlock(x,y,z,Blocks.lava,0,0);
    world.setBlock(x + 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x - 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z + 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z - 1,BPBlocks.basalt,0,0);
  }
}

Fixed version (ground truth):
private void generateLavaColumn(World world,int x,int topY,int z,Random rand){
  if (rand.nextDouble() < Config.volcanoActiveToInactiveRatio) {
    world.setBlock(x,topY,z,BPBlocks.cracked_basalt);
  }
 else {
    world.setBlock(x,topY + 1,z,Blocks.lava);
    world.setBlock(x,topY,z,Blocks.lava);
  }
  for (int y=10; y < topY; y++) {
    world.setBlock(x + 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x - 1,y,z,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z + 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z - 1,BPBlocks.basalt,0,0);
    world.setBlock(x,y,z,Blocks.lava,0,0);
  }
}
Program: 81221
Project: 81221
Buggy source:
public void generate(World world,Random rand,int middleX,int vulcanoHeight,int middleZ){
  List<Pos>[] distMap=calculateDistMap();
  boolean first=true;
  for (int dist=0; dist < distMap.length; dist++) {
    List<Pos> distList=distMap[dist];
    boolean isFinished=true;
    for (    Pos p : distList) {
      int worldHeight=world.getHeightValue(p.x + middleX,p.z + middleZ) - 1;
      int posHeight=first ? vulcanoHeight : getNewVulcanoHeight(worldHeight,p,rand,dist);
      if (posHeight >= 0 && (posHeight > worldHeight || canReplace(world,p.x + middleX,posHeight,p.z + middleZ))) {
        vulcanoMap.put(p,posHeight);
        if (!first) {
          for (int i=posHeight; i > 0 && (i > worldHeight || canReplace(world,p.x + middleX,i,p.z + middleZ)); i--) {
            world.setBlock(p.x + middleX,i,p.z + middleZ,BPBlocks.basalt,0,0);
          }
          for (int i=posHeight + 1; i < vulcanoHeight; i++) {
            if (canReplace(world,p.x + middleX,i,p.z + middleZ))             world.setBlock(p.x + middleX,i,p.z + middleZ,Blocks.air,0,0);
          }
        }
        isFinished=false;
      }
      first=false;
    }
    if (isFinished)     break;
  }
  generateLavaColumn(world,middleX,vulcanoHeight,middleZ,rand);
}

Fixed version (ground truth):
public void generate(World world,Random rand,int middleX,int vulcanoHeight,int middleZ){
  List<Pos>[] distMap=calculateDistMap();
  boolean first=true;
  for (int dist=0; dist < distMap.length; dist++) {
    List<Pos> distList=distMap[dist];
    boolean isFinished=true;
    for (    Pos p : distList) {
      int worldHeight=world.getHeightValue(p.x + middleX,p.z + middleZ) - 1;
      int posHeight=first ? vulcanoHeight : getNewVulcanoHeight(worldHeight,p,rand,dist);
      if (posHeight >= 0 && (posHeight > worldHeight || canReplace(world,p.x + middleX,posHeight,p.z + middleZ))) {
        vulcanoMap.put(p,posHeight);
        if (!first) {
          for (int i=posHeight; i > 0 && (i > worldHeight || canReplace(world,p.x + middleX,i,p.z + middleZ)); i--) {
            world.setBlock(p.x + middleX,i,p.z + middleZ,BPBlocks.basalt,0,0);
          }
          for (int i=posHeight + 1; i < vulcanoHeight; i++) {
            if (canReplace(world,p.x + middleX,i,p.z + middleZ) && world.getBlock(p.x + middleX,i,p.z + middleZ).getMaterial() != Material.water)             world.setBlock(p.x + middleX,i,p.z + middleZ,Blocks.air,0,0);
          }
        }
        isFinished=false;
      }
      first=false;
    }
    if (isFinished)     break;
  }
  generateLavaColumn(world,middleX,vulcanoHeight,middleZ,rand);
}
Program: 81222
Project: 81222
Buggy source:
@Override public int getLightValue(IBlockAccess world,int x,int y,int z){
}

Fixed version (ground truth):
@Override public int getLightValue(IBlockAccess world,int x,int y,int z){
  int metadata=world.getBlockMetadata(x,y,z);
  if ((metadata & 8) != 0) {
    return 13;
  }
  return 0;
}
Program: 81223
Project: 81223
Buggy source:
@Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side,int meta){
}

Fixed version (ground truth):
@Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side,int meta){
  ForgeDirection s=ForgeDirection.getOrientation(side);
  if ((meta & 7) == side) {
    if ((meta & 8) != 0) {
      return this.textureFrontOn;
    }
 else {
      return this.textureFrontOff;
    }
  }
switch (s) {
case UP:
    return textureTop;
case DOWN:
  return textureBottom;
case EAST:
case NORTH:
case SOUTH:
case WEST:
case UNKNOWN:
return textureSide;
default :
break;
}
return null;
}
Program: 81224
Project: 81224
Buggy source:
/** 
 * Function gets called every tick. Do not forget to call the super method!
 */
@Override public void updateEntity(){
}

Fixed version (ground truth):
/** 
 * Function gets called every tick. Do not forget to call the super method!
 */
@Override public void updateEntity(){
  super.updateEntity();
  if (!metaSet) {
    metaSet=true;
    int newMeta=getBlockMetadata();
    newMeta=newMeta & 7;
    newMeta|=(isActive == true ? 8 : 0);
    getWorldObj().setBlockMetadataWithNotify(xCoord,yCoord,zCoord,newMeta,2);
  }
}
Program: 81225
Project: 81225
Buggy source:
/** 
 * Ticks the block if it's been scheduled
 */
public void updateTick(World world,int x,int y,int z,Random random){
  super.updateTick(world,x,y,z,random);
  if (world.getBlockLightValue(x,y + 1,z) >= 9) {
    int l=world.getBlockMetadata(x,y,z);
    if (l < 7) {
      float f=this.func_149864_n(world,x,y,z);
      if (random.nextInt((int)(25.0F / f) + 1) == 0) {
        ++l;
        world.setBlockMetadataWithNotify(x,y,z,l,2);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Ticks the block if it's been scheduled
 */
public void updateTick(World world,int x,int y,int z,Random random){
  super.updateTick(world,x,y,z,random);
  if (world.getBlockLightValue(x,y + 1,z) >= 9) {
    int meta=world.getBlockMetadata(x,y,z);
    if ((meta == 4) || (meta == 5)) {
      return;
    }
    if ((world.getBlock(x,y - 1,z) != Blocks.farmland) || (world.getBlock(x,y - 1,z) == Blocks.air) || (!world.isAirBlock(x,y + 1,z))) {
      return;
    }
    if (random.nextInt(30) == 0) {
      world.setBlockMetadataWithNotify(x,y,z,meta + 1,2);
      if (meta == 3)       world.setBlock(x,y + 1,z,BPBlocks.flax_crop,5,2);
    }
  }
}
Program: 81227
Project: 81227
Buggy source:
public boolean onItemUse(ItemStack itemStack,EntityPlayer player,World world,int x,int y,int z,int side,float hitX,float hitY,float hitZ){
  if (side != 1) {
    return false;
  }
 else   if (player.canPlayerEdit(x,y,z,side,itemStack) && player.canPlayerEdit(x,y + 1,z,side,itemStack)) {
    if (world.getBlock(x,y,z).canSustainPlant(world,x,y,z,ForgeDirection.UP,this) && world.isAirBlock(x,y + 1,z)) {
      world.setBlock(x,y + 1,z,this.field_150925_a);
      --itemStack.stackSize;
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean onItemUse(ItemStack itemStack,EntityPlayer player,World world,int x,int y,int z,int side,float hitX,float hitY,float hitZ){
  if (side != 1) {
    return false;
  }
 else   if (player.canPlayerEdit(x,y,z,side,itemStack) && player.canPlayerEdit(x,y + 1,z,side,itemStack)) {
    if (world.getBlock(x,y,z).canSustainPlant(world,x,y,z,ForgeDirection.UP,this) && world.isAirBlock(x,y + 1,z)) {
      world.setBlock(x,y + 1,z,this.field_150925_a,0,2);
      --itemStack.stackSize;
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}
Program: 81228
Project: 81228
Buggy source:
public BlockCrop(){
  this.setTickRandomly(true);
  float f=0.5F;
  this.setBlockBounds(0.5F - f,0.0F,0.5F - f,0.5F + f,0.25F,0.5F + f);
  this.setCreativeTab((CreativeTabs)null);
  this.setHardness(0.0F);
  this.setStepSound(soundTypeGrass);
  this.disableStats();
  this.setBlockName(Refs.FLAXCROP_NAME);
}

Fixed version (ground truth):
public BlockCrop(){
  this.setTickRandomly(true);
  float f=0.5F;
  this.setBlockBounds(0.5F - f,0.0F,0.5F - f,0.5F + f,0.25F,0.5F + f);
  this.setCreativeTab((CreativeTabs)null);
  this.setHardness(0.0F);
  this.setStepSound(soundTypeGrass);
  this.disableStats();
  this.setBlockName(Refs.FLAXCROP_NAME);
  this.setBlockTextureName(Refs.MODID + "String_Node_Str" + Refs.FLAXCROP_NAME);
}
Program: 81229
Project: 81229
Buggy source:
@EventHandler public void PreInit(FMLPreInitializationEvent event){
  event.getModMetadata().version=Refs.fullVersionString();
  Logger log=event.getModLog();
  Configuration config=new Configuration(event.getSuggestedConfigurationFile());
  config.load();
  Config.setUp(config);
  config.save();
  Blocks.init();
  Items.init();
}

Fixed version (ground truth):
@EventHandler public void PreInit(FMLPreInitializationEvent event){
  event.getModMetadata().version=Refs.fullVersionString();
  Logger log=event.getModLog();
  Configuration config=new Configuration(event.getSuggestedConfigurationFile());
  CustomTabs.init();
  config.load();
  Config.setUp(config);
  config.save();
  Blocks.init();
  Items.init();
}
Program: 81230
Project: 81230
Buggy source:
public BlockGemOre(String type){
  super(Material.iron);
  this.setCreativeTab(BluePower.creativeTab);
  this.setStepSound(soundTypeStone);
  this.setHardness(2.5F);
  this.setResistance(10.0F);
  this.textureName=Refs.MODID + "String_Node_Str" + type;
  this.setBlockName(type);
}

Fixed version (ground truth):
public BlockGemOre(String type){
  super(Material.iron);
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
  this.setStepSound(soundTypeStone);
  this.setHardness(2.5F);
  this.setResistance(10.0F);
  this.textureName=Refs.MODID + "String_Node_Str" + type;
  this.setBlockName(type);
}
Program: 81231
Project: 81231
Buggy source:
public BlockNikoliteBlock(String name){
  super(Material.rock);
  this.textureName=Refs.MODID + "String_Node_Str" + name;
  this.setCreativeTab(CreativeTabs.tabBlock);
  this.setStepSound(soundTypeStone);
  this.setHardness(1.9F);
  this.setResistance(10.0F);
  this.setBlockName(name);
}

Fixed version (ground truth):
public BlockNikoliteBlock(String name){
  super(Material.rock);
  this.textureName=Refs.MODID + "String_Node_Str" + name;
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
  this.setStepSound(soundTypeStone);
  this.setHardness(1.9F);
  this.setResistance(10.0F);
  this.setBlockName(name);
}
Program: 81232
Project: 81232
Buggy source:
public BlockNikoliteOre(String name){
  super(Material.rock);
  this.textureName=Refs.MODID + "String_Node_Str" + name;
  this.setCreativeTab(BluePower.creativeTab);
  this.setStepSound(soundTypeStone);
  this.setHardness(1.9F);
  this.setResistance(10.0F);
  this.setBlockName(name);
}

Fixed version (ground truth):
public BlockNikoliteOre(String name){
  super(Material.rock);
  this.textureName=Refs.MODID + "String_Node_Str" + name;
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
  this.setStepSound(soundTypeStone);
  this.setHardness(1.9F);
  this.setResistance(10.0F);
  this.setBlockName(name);
}
Program: 81233
Project: 81233
Buggy source:
public BlockStoneOre(String name){
  super(Material.rock);
  this.setBlockName(name);
  this.setHardness(1.9F);
  if (name == Refs.BASALT_NAME) {
    this.setResistance(25.0F);
  }
 else {
    this.setResistance(10.0F);
  }
  this.textureName=Refs.MODID + "String_Node_Str" + name;
  this.setCreativeTab(BluePower.creativeTab);
  this.setStepSound(soundTypeStone);
}

Fixed version (ground truth):
public BlockStoneOre(String name){
  super(Material.rock);
  this.setBlockName(name);
  this.setHardness(1.9F);
  if (name == Refs.BASALT_NAME) {
    this.setResistance(25.0F);
  }
 else {
    this.setResistance(10.0F);
  }
  this.textureName=Refs.MODID + "String_Node_Str" + name;
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
  this.setStepSound(soundTypeStone);
}
Program: 81234
Project: 81234
Buggy source:
public ContainerAlloyFurnace(){
  super(Material.rock);
  this.setHardness(1.5F);
  this.setResistance(20.0F);
  this.setCreativeTab(BluePower.creativeTab);
}

Fixed version (ground truth):
public ContainerAlloyFurnace(){
  super(Material.rock);
  this.setHardness(1.5F);
  this.setResistance(20.0F);
  this.setCreativeTab(CustomTabs.tabBluePowerMachines);
}
Program: 81235
Project: 81235
Buggy source:
public ItemMalachite(){
  super();
  this.setUnlocalizedName(Refs.ITEMMALACHITE_NAME);
  this.setCreativeTab(BluePower.creativeTab);
}

Fixed version (ground truth):
public ItemMalachite(){
  super();
  this.setUnlocalizedName(Refs.ITEMMALACHITE_NAME);
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
}
Program: 81236
Project: 81236
Buggy source:
public ItemNikolite(){
  super();
  this.setUnlocalizedName(Refs.ITEMNIKOLITE_NAME);
  this.setCreativeTab(BluePower.creativeTab);
}

Fixed version (ground truth):
public ItemNikolite(){
  super();
  this.setUnlocalizedName(Refs.ITEMNIKOLITE_NAME);
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
}
Program: 81237
Project: 81237
Buggy source:
public ItemRuby(){
  super();
  this.setUnlocalizedName(Refs.ITEMRUBY_NAME);
  this.setCreativeTab(BluePower.creativeTab);
}

Fixed version (ground truth):
public ItemRuby(){
  super();
  this.setUnlocalizedName(Refs.ITEMRUBY_NAME);
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
}
Program: 81238
Project: 81238
Buggy source:
public ItemSapphire(){
  super();
  this.setUnlocalizedName(Refs.ITEMSAPPHIRE_NAME);
  this.setCreativeTab(BluePower.creativeTab);
}

Fixed version (ground truth):
public ItemSapphire(){
  super();
  this.setUnlocalizedName(Refs.ITEMSAPPHIRE_NAME);
  this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
}
Program: 81239
Project: 81239
Buggy source:
public void setup(){
  if (!isSetup) {
    fileDescriptor=NativeEpoll.addFile(epollFd,NativeEpoll.EPOLL_CTL_ADD,filename,NativeEpoll.EPOLLPRI | NativeEpoll.EPOLLIN | NativeEpoll.EPOLLET);
    isSetup=true;
  }
}

Fixed version (ground truth):
public void setup(){
  if (!isSetup) {
    epollFd=NativeEpoll.epollCreate();
    fileDescriptor=NativeEpoll.addFile(epollFd,NativeEpoll.EPOLL_CTL_ADD,filename,NativeEpoll.EPOLLPRI | NativeEpoll.EPOLLIN | NativeEpoll.EPOLLET);
    isSetup=true;
  }
}
Program: 81240
Project: 81240
Buggy source:
public void teardown(){
  stop();
  if (isSetup) {
    NativeEpoll.removeFile(epollFd,fileDescriptor);
  }
  isSetup=false;
}

Fixed version (ground truth):
public void teardown(){
  stop();
  if (isSetup) {
    NativeEpoll.removeFile(epollFd,fileDescriptor);
  }
  NativeEpoll.shutdown(epollFd);
  isSetup=false;
}
Program: 81241
Project: 81241
Buggy source:
private BeagleBoneBlack(){
  createPins();
  createBuses();
  createProperties();
  createShutdownHook();
}

Fixed version (ground truth):
private BeagleBoneBlack(){
  super();
  createPins();
  createBuses();
  createProperties();
}
Program: 81242
Project: 81242
Buggy source:
private RaspberryPi(){
  if (getRevision() >= 4) {
    createPinsRev2();
  }
 else {
    createPinsRev1();
  }
}

Fixed version (ground truth):
private RaspberryPi(){
  super();
  if (getRevision() >= 4) {
    createPinsRev2();
  }
 else {
    createPinsRev1();
  }
}
Program: 81243
Project: 81243
Buggy source:
public void setDuty(double duty){
  if (duty < 0.0 || duty > 1.0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.duty=duty;
  setPwmImpl(getFrequency(),duty);
}

Fixed version (ground truth):
public void setDuty(double duty){
  if (duty < 0.0 || duty > 1.0) {
    throw new IllegalArgumentException("String_Node_Str" + duty);
  }
  this.duty=duty;
  setPwmImpl(getFrequency(),duty);
}
Program: 81244
Project: 81244
Buggy source:
public void setFrequency(double frequency){
  if (frequency < 1.0f) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.frequency=frequency;
  setPwmImpl(frequency,getDuty());
}

Fixed version (ground truth):
public void setFrequency(double frequency){
  if (frequency < 1.0f) {
    throw new IllegalArgumentException("String_Node_Str" + frequency);
  }
  this.frequency=frequency;
  setPwmImpl(frequency,getDuty());
}
Program: 81245
Project: 81245
Buggy source:
public Blinker(DigitalOutput output){
  executorService=Executors.newScheduledThreadPool(1);
  this.output=output;
}

Fixed version (ground truth):
public Blinker(DigitalOutput output){
  executorService=Executors.newScheduledThreadPool(1,new DaemonThreadFactory());
  this.output=output;
}
Program: 81246
Project: 81246
Buggy source:
public void dutyTransition(Pwm pwm,double toDuty,int milliseconds,Easing easing){
  long startTime=System.currentTimeMillis();
  double startDuty=pwm.getDuty();
  double diff=Math.abs(startDuty - toDuty);
  long currentTime=0;
  while (currentTime < milliseconds) {
    currentTime=System.currentTimeMillis() - startTime;
    double currentDuty=diff * easing.easeInOut(currentTime,milliseconds);
    if (startDuty < toDuty) {
      pwm.setDuty(startDuty + currentDuty);
    }
 else {
      pwm.setDuty(startDuty - currentDuty);
    }
  }
}

Fixed version (ground truth):
public void dutyTransition(Pwm pwm,double toDuty,int milliseconds,Easing easing,EasingOptions option){
  long startTime=System.currentTimeMillis();
  double startDuty=pwm.getDuty();
  double diff=Math.abs(startDuty - toDuty);
  long currentTime=0;
  while (currentTime < milliseconds) {
    currentTime=System.currentTimeMillis() - startTime;
    double currentDuty=diff * option.calculate(easing,currentTime,milliseconds);
    if (startDuty < toDuty) {
      double duty=startDuty + currentDuty;
      if (duty > 1.0) {
        duty=1.0;
      }
      if (duty < 0.0) {
        duty=0.0;
      }
      pwm.setDuty(duty);
    }
 else {
      double duty=startDuty - currentDuty;
      if (duty > 1.0) {
        duty=1.0;
      }
      if (duty < 0.0) {
        duty=0.0;
      }
      pwm.setDuty(duty);
    }
  }
}
Program: 81247
Project: 81247
Buggy source:
public void frequencyTransition(Pwm pwm,double toFrequency,int milliseconds,Easing easing){
  long startTime=System.currentTimeMillis();
  double startFrequency=pwm.getFrequency();
  double diff=Math.abs(startFrequency - toFrequency);
  long currentTime=0;
  while (currentTime < milliseconds) {
    currentTime=System.currentTimeMillis() - startTime;
    double currentDuty=diff * easing.easeInOut(currentTime,milliseconds);
    if (startFrequency < toFrequency) {
      pwm.setDuty(startFrequency + currentDuty);
    }
 else {
      pwm.setDuty(startFrequency - currentDuty);
    }
  }
}

Fixed version (ground truth):
public void frequencyTransition(Pwm pwm,double toFrequency,int milliseconds,Easing easing,EasingOptions option){
  long startTime=System.currentTimeMillis();
  double startFrequency=pwm.getFrequency();
  double diff=Math.abs(startFrequency - toFrequency);
  long currentTime=0;
  while (currentTime < milliseconds) {
    currentTime=System.currentTimeMillis() - startTime;
    double currentDuty=diff * option.calculate(easing,currentTime,milliseconds);
    if (startFrequency < toFrequency) {
      pwm.setDuty(startFrequency + currentDuty);
    }
 else {
      pwm.setDuty(startFrequency - currentDuty);
    }
  }
}
Program: 81248
Project: 81248
Buggy source:
private void createScheduler(){
  if (executorService != null) {
    return;
  }
  executorService=Executors.newScheduledThreadPool(1);
  future=executorService.scheduleAtFixedRate(this,0,periodInNanoseconds,TimeUnit.NANOSECONDS);
}

Fixed version (ground truth):
private void createScheduler(){
  if (executorService != null) {
    return;
  }
  executorService=Executors.newScheduledThreadPool(1,new DaemonThreadFactory());
  future=executorService.scheduleAtFixedRate(this,0,periodInNanoseconds,TimeUnit.NANOSECONDS);
}
Program: 81249
Project: 81249
Buggy source:
public void fadeOut(int milliseconds,Easing easing){
  pwmController.dutyTransition(pwm,0.0,milliseconds,easing);
}

Fixed version (ground truth):
public void fadeOut(int milliseconds,Easing easing){
  pwmController.dutyTransition(pwm,0.0,milliseconds,easing,EasingOptions.EaseOut);
}
Program: 81250
Project: 81250
Buggy source:
public void fadeIn(int milliseconds,Easing easing){
  pwmController.dutyTransition(pwm,1.0,milliseconds,easing);
}

Fixed version (ground truth):
public void fadeIn(int milliseconds,Easing easing){
  pwmController.dutyTransition(pwm,1.0,milliseconds,easing,EasingOptions.EaseIn);
}
Program: 81251
Project: 81251
Buggy source:
public Led(Pwm pwm){
  this.pwm=pwm;
  this.pwmController=new PwmController();
}

Fixed version (ground truth):
public Led(Pwm pwm,Easing defaultEasing){
  this.pwm=pwm;
  this.defaultEasing=defaultEasing;
  this.pwmController=new PwmController();
  pwm.setFrequency(10000.0);
  pwm.setDuty(0.0);
  pwm.enable();
}
Program: 81252
Project: 81252
Buggy source:
public static void main(String[] args) throws IOException {
  Board board=Platform.createBoard();
  DigitalOutput output=board.getPin(BBBNames.P8_12).as(DigitalOutput.class);
  output.write(Signal.High);
  output.toggle();
  BulldogUtil.sleepMs(500);
  output.high();
  BulldogUtil.sleepMs(500);
  output.low();
  BulldogUtil.sleepMs(500);
  output.applySignal(Signal.High);
  BulldogUtil.sleepMs(500);
  output.blinkTimes(500,3);
  BulldogUtil.sleepMs(2000);
  output.startBlinking(100,5000);
  BulldogUtil.sleepMs(5500);
  output.startBlinking(200);
  while (true) {
    BulldogUtil.sleepMs(50);
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  Board board=Platform.createBoard();
  DigitalOutput output=board.getPin(BBBNames.P8_12).as(DigitalOutput.class);
  output.write(Signal.High);
  output.toggle();
  BulldogUtil.sleepMs(500);
  output.high();
  BulldogUtil.sleepMs(500);
  output.low();
  BulldogUtil.sleepMs(500);
  output.applySignal(Signal.High);
  BulldogUtil.sleepMs(500);
  output.blinkTimes(500,3);
  output.awaitBlinkingStopped();
  output.startBlinking(100,5000);
  output.awaitBlinkingStopped();
  output.startBlinking(200);
  while (true) {
    BulldogUtil.sleepMs(50);
  }
}
Program: 81253
Project: 81253
Buggy source:
public void echoAndWait(String path,String value,int waitMs){
  try {
    waitForFileCreation(path,WAIT_TIMEOUT_MS);
    BufferedWriter writer=new BufferedWriter(new FileWriter(path));
    writer.write(value);
    BulldogUtil.sleepMs(waitMs);
    writer.close();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void echoAndWait(String path,String value,int waitMs){
  try {
    System.out.println(path + "String_Node_Str" + value);
    waitForFileCreation(path,WAIT_TIMEOUT_MS);
    BufferedWriter writer=new BufferedWriter(new FileWriter(path));
    writer.write(value);
    BulldogUtil.sleepMs(waitMs);
    writer.close();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 81254
Project: 81254
Buggy source:
public static void initialize(){
  if (isInitialized) {
    return;
  }
  setup();
  isInitialized=true;
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      deinitialize();
    }
  }
);
}

Fixed version (ground truth):
public static void initialize(){
  if (isInitialized) {
    return;
  }
  setup();
  enableGpio();
  isInitialized=true;
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      deinitialize();
    }
  }
);
}
Program: 81255
Project: 81255
Buggy source:
public byte readState(){
  try {
    byte buffer=getLastKnownState();
    switchInputsHigh();
    byte readByte=connection.readByte();
    writeState(buffer);
    return readByte;
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return (byte)0;
}

Fixed version (ground truth):
/** 
 * This method preservers the outputs' state and adjust the state of the inputs. Before it reads, it sets all the input pins that are to be read to high, according to the PCF8574 datasheet.
 * @return the state read from the PCF857
 */
public byte readState(){
  try {
    byte buffer=getState();
    switchInputsHigh();
    byte readByte=connection.readByte();
    buffer=applyReadInputs(readByte,buffer);
    writeState(buffer);
    return readByte;
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return (byte)0;
}
Program: 81256
Project: 81256
Buggy source:
private void switchInputsHigh(){
  byte highInputState=getLastKnownState();
  for (  Pin pin : getPins()) {
    if (pin.isFeatureActive(DigitalInput.class)) {
      highInputState=BitMagic.setBit(highInputState,pin.getAddress(),1);
    }
  }
  writeState(highInputState);
}

Fixed version (ground truth):
private void switchInputsHigh(){
  byte highInputState=getState();
  for (  Pin pin : getPins()) {
    if (pin.isFeatureActive(DigitalInput.class)) {
      highInputState=BitMagic.setBit(highInputState,pin.getAddress(),1);
    }
  }
  writeState(highInputState);
}
Program: 81257
Project: 81257
Buggy source:
@Override public void setup(){
  byte state=expander.getLastKnownState();
  byte newState=(byte)BitMagic.setBit(state,getPin().getAddress(),1);
  expander.writeState(newState);
}

Fixed version (ground truth):
@Override public void setup(){
  byte state=expander.getState();
  byte newState=(byte)BitMagic.setBit(state,getPin().getAddress(),1);
  expander.writeState(newState);
}
Program: 81258
Project: 81258
Buggy source:
@Override public Signal getAppliedSignal(){
  return Signal.fromNumericValue(BitMagic.getBit(expander.getLastKnownState(),getPin().getAddress()));
}

Fixed version (ground truth):
@Override public Signal getAppliedSignal(){
  return Signal.fromNumericValue(BitMagic.getBit(expander.getState(),getPin().getAddress()));
}
Program: 81259
Project: 81259
Buggy source:
@Override protected void applySignalImpl(Signal signal){
  byte state=expander.getLastKnownState();
  byte newState=(byte)BitMagic.setBit(state,getPin().getAddress(),signal.getNumericValue());
  expander.writeState(newState);
}

Fixed version (ground truth):
@Override protected void applySignalImpl(Signal signal){
  byte state=expander.getState();
  byte newState=(byte)BitMagic.setBit(state,getPin().getAddress(),signal.getNumericValue());
  expander.writeState(newState);
}
Program: 81260
Project: 81260
Buggy source:
public static int setBit(int dword,int bitPosition,int value){
  if (value == 1) {
    dword|=(value << bitPosition);
  }
 else {
    dword&=~(1 << bitPosition);
  }
  return dword;
}

Fixed version (ground truth):
public static byte setBit(byte b,int bitPosition,int value){
  if (value == 1) {
    b|=(value << bitPosition);
  }
 else {
    b&=~(1 << bitPosition);
  }
  return b;
}
Program: 81261
Project: 81261
Buggy source:
public byte readState(){
  try {
    byte readByte=connection.readByte();
    return readByte;
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return (byte)0;
}

Fixed version (ground truth):
public byte readState(){
  try {
    byte buffer=getLastKnownState();
    switchInputsHigh();
    byte readByte=connection.readByte();
    writeState(buffer);
    return readByte;
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return (byte)0;
}
Program: 81262
Project: 81262
Buggy source:
@Override public void interruptRequest(InterruptEventArgs args){
  byte lastKnownState=(byte)state;
  state=readState();
  for (int i=0; i <= 7; i++) {
    Pin currentPin=getPin(i);
    if (!currentPin.isFeatureActive(PCF8574DigitalInput.class)) {
      continue;
    }
    PCF8574DigitalInput input=currentPin.as(PCF8574DigitalInput.class);
    int lastKnownPinState=BitMagic.getBit(lastKnownState,currentPin.getAddress());
    int currentState=BitMagic.getBit(state,currentPin.getAddress());
    if (lastKnownPinState == currentState) {
      continue;
    }
    input.handleInterruptEvent(Signal.fromNumericValue(lastKnownState),Signal.fromNumericValue(currentState));
  }
}

Fixed version (ground truth):
@Override public void interruptRequest(InterruptEventArgs args){
  byte lastKnownState=(byte)state;
  byte readState=readState();
  for (int i=0; i <= 7; i++) {
    Pin currentPin=getPin(i);
    if (!currentPin.isFeatureActive(PCF8574DigitalInput.class)) {
      continue;
    }
    PCF8574DigitalInput input=currentPin.as(PCF8574DigitalInput.class);
    int lastKnownPinState=BitMagic.getBit(lastKnownState,currentPin.getAddress());
    int currentState=BitMagic.getBit(readState,currentPin.getAddress());
    if (lastKnownPinState == currentState) {
      continue;
    }
    input.handleInterruptEvent(Signal.fromNumericValue(lastKnownState),Signal.fromNumericValue(currentState));
  }
}
Program: 81263
Project: 81263
Buggy source:
public static void main(String[] args) throws IOException {
  Board board=Platform.createBoard();
  DigitalOutput output=board.getPin(BBBNames.P8_12).as(DigitalOutput.class);
  output.write(Signal.High);
  output.toggle();
  BulldogUtil.sleepMs(500);
  output.high();
  BulldogUtil.sleepMs(500);
  output.low();
  BulldogUtil.sleepMs(500);
  output.applySignal(Signal.High);
  output.blinkTimes(500,3);
  BulldogUtil.sleepMs(2000);
  output.startBlinking(50,3000);
  BulldogUtil.sleepMs(3500);
  output.startBlinking(100);
  while (true) {
    BulldogUtil.sleepMs(50);
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  Board board=Platform.createBoard();
  DigitalOutput output=board.getPin(BBBNames.P8_12).as(DigitalOutput.class);
  output.write(Signal.High);
  output.toggle();
  BulldogUtil.sleepMs(500);
  output.high();
  BulldogUtil.sleepMs(500);
  output.low();
  BulldogUtil.sleepMs(500);
  output.applySignal(Signal.High);
  BulldogUtil.sleepMs(500);
  output.blinkTimes(500,3);
  BulldogUtil.sleepMs(2000);
  output.startBlinking(50,3000);
  BulldogUtil.sleepMs(3500);
  output.startBlinking(100);
  while (true) {
    BulldogUtil.sleepMs(50);
  }
}
Program: 81265
Project: 81265
Buggy source:
private void createBuses(){
  getI2cBuses().add(new BBBI2cBus("String_Node_Str"));
  getI2cBuses().add(new BBBI2cBus("String_Node_Str"));
}

Fixed version (ground truth):
private void createBuses(){
  detectI2cBuses();
  detectSerialBuses();
}
Program: 81266
Project: 81266
Buggy source:
public BeagleBonePin(String name,String internalName,int bank,int pinIndex,int port,int indexOnPort){
  super(name,internalName,32 * bank + pinIndex);
  this.port=port;
  this.indexOnPort=indexOnPort;
}

Fixed version (ground truth):
public BeagleBonePin(String name,String am335xName,int bank,int pinIndex,int port,int indexOnPort){
  super(name,32 * bank + pinIndex);
  this.port=port;
  this.indexOnPort=indexOnPort;
  this.am335xName=am335xName;
}
Program: 81267
Project: 81267
Buggy source:
@Override public void addInterruptListener(InterruptListener listener){
  super.addInterruptListener(listener);
  if (areInterruptsEnabled() && interruptControl.isRunning()) {
    interruptControl.start();
  }
}

Fixed version (ground truth):
@Override public void addInterruptListener(InterruptListener listener){
  super.addInterruptListener(listener);
  if (areInterruptsEnabled() && !interruptControl.isRunning()) {
    interruptControl.start();
  }
}
Program: 81268
Project: 81268
Buggy source:
public void run(){
  while (running) {
    NativePollResult[] results=NativeEpoll.waitForInterrupt(epollFd);
    if (results == null) {
      continue;
    }
    for (    NativePollResult result : results) {
      if (lastEdge != null && lastEdge.equals(result.getEdge())) {
        continue;
      }
      Edge edge=result.getEdge();
      long delta=System.currentTimeMillis() - lastInterruptTime;
      if (delta <= this.debounceMilliseconds) {
        continue;
      }
      lastInterruptTime=System.currentTimeMillis();
      lastEdge=result.getEdge();
      interrupt.fireInterruptEvent(new InterruptEventArgs(edge));
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (running) {
    NativePollResult[] results=NativeEpoll.waitForInterrupt(epollFd);
    if (results == null) {
      continue;
    }
    for (    NativePollResult result : results) {
      Edge edge=result.getEdge();
      if (lastEdge != null && lastEdge.equals(edge)) {
        continue;
      }
      long delta=System.currentTimeMillis() - lastInterruptTime;
      if (delta <= this.debounceMilliseconds) {
        continue;
      }
      lastInterruptTime=System.currentTimeMillis();
      lastEdge=result.getEdge();
      interrupt.fireInterruptEvent(new InterruptEventArgs(edge));
    }
  }
}