nus-yam/ex-repair huggingface dataset:
Program: 95764
Project: 95764
Buggy source:
@Override public void updateEntity(){
  boolean change=false;
  if (!this.worldObj.isRemote && this.isAnalyzing()) {
    this.progress=progress < this.maxProgress() ? progress + 1 : this.maxProgress();
    if (progress == this.maxProgress()) {
      this.analyze();
    }
    change=true;
  }
  if (change) {
    this.markDirty();
    this.worldObj.addBlockEvent(this.xCoord,this.yCoord,this.zCoord,this.worldObj.getBlock(this.xCoord,this.yCoord,this.zCoord),0,0);
    this.worldObj.notifyBlockChange(this.xCoord,this.yCoord,this.zCoord,this.getBlockType());
  }
}

Fixed version (ground truth):
@Override public void updateEntity(){
  boolean change=false;
  if (!this.worldObj.isRemote && this.isAnalyzing()) {
    this.progress=progress < this.maxProgress() ? progress + 1 : this.maxProgress();
    if (progress == this.maxProgress()) {
      this.analyze();
    }
    change=true;
  }
  if (change) {
    this.markDirtyAndMarkForUpdate();
    this.worldObj.addBlockEvent(this.xCoord,this.yCoord,this.zCoord,this.worldObj.getBlock(this.xCoord,this.yCoord,this.zCoord),0,0);
    this.worldObj.notifyBlockChange(this.xCoord,this.yCoord,this.zCoord,this.getBlockType());
  }
}
Program: 95765
Project: 95765
Buggy source:
private boolean sprinkle(){
  boolean newState=this.canSprinkle();
  if (newState != this.isSprinkled) {
    this.isSprinkled=newState;
    this.markDirty();
  }
  return this.isSprinkled;
}

Fixed version (ground truth):
private boolean sprinkle(){
  boolean newState=this.canSprinkle();
  if (newState != this.isSprinkled) {
    this.isSprinkled=newState;
    this.markDirtyAndMarkForUpdate();
  }
  return this.isSprinkled;
}
Program: 95766
Project: 95766
Buggy source:
public void syncFluidLevels(){
  int lvl=this.fluidLevel;
  int xPos=this.getXPosition();
  int yPos=this.getYPosition();
  int zPos=this.getZPosition();
  int xSize=this.getXSize();
  int ySize=this.getYSize();
  int zSize=this.getZSize();
  boolean change=timer > 20;
  if (change)   timer=0;
  for (int x=this.xCoord - xPos; x < this.xCoord - xPos + xSize; x++) {
    for (int y=this.yCoord - yPos; y < this.yCoord - yPos + ySize; y++) {
      for (int z=this.zCoord - zPos; z < this.zCoord - zPos + zSize; z++) {
        if (this.worldObj.getTileEntity(x,y,z) != null && this.worldObj.getTileEntity(x,y,z) instanceof TileEntityTank) {
          TileEntityTank tank=(TileEntityTank)this.worldObj.getTileEntity(x,y,z);
          tank.fluidLevel=lvl;
        }
      }
    }
  }
}

Fixed version (ground truth):
public void syncFluidLevels(boolean forceUpdate){
  int lvl=this.fluidLevel;
  int xPos=this.getXPosition();
  int yPos=this.getYPosition();
  int zPos=this.getZPosition();
  int xSize=this.getXSize();
  int ySize=this.getYSize();
  int zSize=this.getZSize();
  boolean change=timer > 20 || forceUpdate;
  if (change)   timer=0;
  for (int x=this.xCoord - xPos; x < this.xCoord - xPos + xSize; x++) {
    for (int y=this.yCoord - yPos; y < this.yCoord - yPos + ySize; y++) {
      for (int z=this.zCoord - zPos; z < this.zCoord - zPos + zSize; z++) {
        if (this.worldObj.getTileEntity(x,y,z) != null && this.worldObj.getTileEntity(x,y,z) instanceof TileEntityTank) {
          TileEntityTank tank=(TileEntityTank)this.worldObj.getTileEntity(x,y,z);
          tank.fluidLevel=lvl;
          if (change && tank.getYPosition() == 0) {
            tank.markDirtyAndMarkForUpdate();
          }
        }
      }
    }
  }
}
Program: 95767
Project: 95767
Buggy source:
@Override public int fill(ForgeDirection from,FluidStack resource,boolean doFill){
  if (resource == null || !this.canFill(from,resource.getFluid())) {
    return 0;
  }
  int filled=Math.min(resource.amount,this.getTotalCapacity() - this.getFluidLevel());
  if (doFill) {
    this.setFluidLevel(this.getFluidLevel() + filled);
  }
  return filled;
}

Fixed version (ground truth):
@Override public int fill(ForgeDirection from,FluidStack resource,boolean doFill){
  if (resource == null || !this.canFill(from,resource.getFluid())) {
    return 0;
  }
  int filled=Math.min(resource.amount,this.getTotalCapacity() - this.getFluidLevel());
  if (doFill) {
    this.setFluidLevel(this.getFluidLevel() + filled);
    syncFluidLevels(true);
  }
  return filled;
}
Program: 95768
Project: 95768
Buggy source:
@Override public void updateEntity(){
  if (!this.worldObj.isRemote) {
    boolean change=this.updateMultiBlock();
    if (this.worldObj.canBlockSeeTheSky(this.xCoord,this.yCoord,this.zCoord) && this.worldObj.isRaining()) {
      if (this.getYPosition() + 1 == this.getYSize()) {
        BiomeGenBase biome=this.worldObj.getBiomeGenForCoords(this.xCoord,this.zCoord);
        if (biome != BiomeGenBase.desert && biome != BiomeGenBase.desertHills) {
          this.setFluidLevel(this.fluidLevel + 1);
          change=true;
        }
      }
    }
    if (ConfigurationHandler.fillFromFlowingWater && (this.worldObj.getBlock(this.xCoord,this.yCoord + 1,this.zCoord) == Blocks.water || this.worldObj.getBlock(this.xCoord,this.yCoord + 1,this.zCoord) == Blocks.flowing_water)) {
      this.setFluidLevel(this.fluidLevel + 5);
      change=true;
    }
    if (change && timer > 10) {
      timer=0;
      float smallestPart=32.0f / getTotalCapacity();
      int discreteFluidLevel=Math.round(smallestPart * fluidLevel);
      if (lastDiscreteFluidLevel != discreteFluidLevel) {
        lastDiscreteFluidLevel=discreteFluidLevel;
        this.markDirty();
      }
    }
    timer++;
  }
}

Fixed version (ground truth):
@Override public void updateEntity(){
  if (!this.worldObj.isRemote) {
    boolean change=this.updateMultiBlock();
    if (this.worldObj.canBlockSeeTheSky(this.xCoord,this.yCoord,this.zCoord) && this.worldObj.isRaining()) {
      if (this.getYPosition() + 1 == this.getYSize()) {
        BiomeGenBase biome=this.worldObj.getBiomeGenForCoords(this.xCoord,this.zCoord);
        if (biome != BiomeGenBase.desert && biome != BiomeGenBase.desertHills) {
          this.setFluidLevel(this.fluidLevel + 1);
          change=true;
        }
      }
    }
    if (ConfigurationHandler.fillFromFlowingWater && (this.worldObj.getBlock(this.xCoord,this.yCoord + 1,this.zCoord) == Blocks.water || this.worldObj.getBlock(this.xCoord,this.yCoord + 1,this.zCoord) == Blocks.flowing_water)) {
      this.setFluidLevel(this.fluidLevel + 5);
      change=true;
    }
    if (change && timer > 10) {
      timer=0;
      int discreteFluidLevel=getDiscreteFluidLevel();
      if (lastDiscreteFluidLevel != discreteFluidLevel) {
        lastDiscreteFluidLevel=discreteFluidLevel;
        markDirtyAndMarkForUpdate();
      }
    }
    timer++;
  }
}
Program: 95769
Project: 95769
Buggy source:
public void breakMultiBlock(){
  int lvl=this.fluidLevel;
  int xPos=this.getXPosition();
  int yPos=this.getYPosition();
  int zPos=this.getZPosition();
  int xSize=this.getXSize();
  int ySize=this.getYSize();
  int zSize=this.getZSize();
  int[] levels=new int[ySize];
  int area=xSize * zSize;
  for (int i=0; i < levels.length; i++) {
    levels[i]=(lvl / area >= this.getSingleCapacity()) ? this.getSingleCapacity() : lvl / area;
    lvl=(lvl - levels[i] * area) < 0 ? 0 : (lvl - levels[i] * area);
  }
  for (int x=0; x < xSize; x++) {
    for (int y=0; y < ySize; y++) {
      for (int z=0; z < zSize; z++) {
        TileEntityTank tank=(TileEntityTank)this.worldObj.getTileEntity(this.xCoord - xPos + x,this.yCoord - yPos + y,this.zCoord - zPos + z);
        tank.connectedTanks=1;
        tank.fluidLevel=levels[y];
      }
    }
  }
}

Fixed version (ground truth):
public void breakMultiBlock(){
  int lvl=this.fluidLevel;
  int xPos=this.getXPosition();
  int yPos=this.getYPosition();
  int zPos=this.getZPosition();
  int xSize=this.getXSize();
  int ySize=this.getYSize();
  int zSize=this.getZSize();
  int[] levels=new int[ySize];
  int area=xSize * zSize;
  for (int i=0; i < levels.length; i++) {
    levels[i]=(lvl / area >= this.getSingleCapacity()) ? this.getSingleCapacity() : lvl / area;
    lvl=(lvl - levels[i] * area) < 0 ? 0 : (lvl - levels[i] * area);
  }
  for (int x=0; x < xSize; x++) {
    for (int y=0; y < ySize; y++) {
      for (int z=0; z < zSize; z++) {
        TileEntityTank tank=(TileEntityTank)this.worldObj.getTileEntity(this.xCoord - xPos + x,this.yCoord - yPos + y,this.zCoord - zPos + z);
        tank.connectedTanks=1;
        tank.fluidLevel=levels[y];
        tank.markDirtyAndMarkForUpdate();
      }
    }
  }
}
Program: 95771
Project: 95771
Buggy source:
public void setFluidLevel(int lvl){
  if (lvl != this.fluidLevel) {
    this.fluidLevel=lvl > this.getTotalCapacity() ? this.getTotalCapacity() : lvl;
    this.syncFluidLevels();
  }
}

Fixed version (ground truth):
public void setFluidLevel(int lvl){
  if (lvl != this.fluidLevel) {
    this.fluidLevel=lvl > this.getTotalCapacity() ? this.getTotalCapacity() : lvl;
    this.syncFluidLevels(false);
  }
}
Program: 95772
Project: 95772
Buggy source:
public void updatePowerStatus(){
  boolean wasPowered=powered;
  powered=worldObj.isBlockIndirectlyGettingPowered(xCoord,yCoord,zCoord);
  if (powered != wasPowered) {
    markDirty();
  }
}

Fixed version (ground truth):
public void updatePowerStatus(){
  boolean wasPowered=powered;
  powered=worldObj.isBlockIndirectlyGettingPowered(xCoord,yCoord,zCoord);
  if (powered != wasPowered) {
    markDirtyAndMarkForUpdate();
  }
}
Program: 95773
Project: 95773
Buggy source:
public void plantSeed(World world,int x,int y,int z,EntityPlayer player){
  if (!world.isRemote) {
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (crop.crossCrop || crop.hasPlant() || !(player.getCurrentEquippedItem().getItem() instanceof ItemSeeds)) {
      return;
    }
 else {
      ItemStack stack=player.getCurrentEquippedItem();
      if (!SeedHelper.isValidSeed((ItemSeeds)stack.getItem(),stack.getItemDamage()) || !SeedHelper.isCorrectSoil(world.getBlock(x,y - 1,z),world.getBlockMetadata(x,y - 1,z),(ItemSeeds)stack.getItem(),stack.getItemDamage())) {
        return;
      }
      if (player.getCurrentEquippedItem().stackTagCompound != null && player.getCurrentEquippedItem().stackTagCompound.hasKey(Names.NBT.growth)) {
        crop.setPlant(stack.stackTagCompound.getInteger(Names.NBT.growth),stack.stackTagCompound.getInteger(Names.NBT.gain),stack.stackTagCompound.getInteger(Names.NBT.strength),stack.stackTagCompound.getBoolean(Names.NBT.analyzed),(ItemSeeds)stack.getItem(),stack.getItemDamage());
      }
 else {
        crop.setPlant(Constants.defaultGrowth,Constants.defaultGain,Constants.defaultStrength,false,(ItemSeeds)stack.getItem(),stack.getItemDamage());
      }
      player.getCurrentEquippedItem().stackSize=player.capabilities.isCreativeMode ? player.getCurrentEquippedItem().stackSize : player.getCurrentEquippedItem().stackSize - 1;
    }
    crop.markDirty();
  }
}

Fixed version (ground truth):
public void plantSeed(World world,int x,int y,int z,EntityPlayer player){
  if (!world.isRemote) {
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (crop.crossCrop || crop.hasPlant() || !(player.getCurrentEquippedItem().getItem() instanceof ItemSeeds)) {
      return;
    }
 else {
      ItemStack stack=player.getCurrentEquippedItem();
      if (!SeedHelper.isValidSeed((ItemSeeds)stack.getItem(),stack.getItemDamage()) || !SeedHelper.isCorrectSoil(world.getBlock(x,y - 1,z),world.getBlockMetadata(x,y - 1,z),(ItemSeeds)stack.getItem(),stack.getItemDamage())) {
        return;
      }
      if (player.getCurrentEquippedItem().stackTagCompound != null && player.getCurrentEquippedItem().stackTagCompound.hasKey(Names.NBT.growth)) {
        crop.setPlant(stack.stackTagCompound.getInteger(Names.NBT.growth),stack.stackTagCompound.getInteger(Names.NBT.gain),stack.stackTagCompound.getInteger(Names.NBT.strength),stack.stackTagCompound.getBoolean(Names.NBT.analyzed),(ItemSeeds)stack.getItem(),stack.getItemDamage());
      }
 else {
        crop.setPlant(Constants.defaultGrowth,Constants.defaultGain,Constants.defaultStrength,false,(ItemSeeds)stack.getItem(),stack.getItemDamage());
      }
      player.getCurrentEquippedItem().stackSize=player.capabilities.isCreativeMode ? player.getCurrentEquippedItem().stackSize : player.getCurrentEquippedItem().stackSize - 1;
    }
    crop.markDirtyAndMarkForUpdate();
  }
}
Program: 95774
Project: 95774
Buggy source:
public boolean harvest(World world,int x,int y,int z){
  if (!world.isRemote) {
    boolean update=false;
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (crop.weed) {
      crop.clearWeed();
    }
 else     if (crop.crossCrop) {
      crop.crossCrop=false;
      this.dropBlockAsItem(world,x,y,z,new ItemStack(Items.crops,1));
      update=true;
    }
 else     if (crop.isMature()) {
      crop.getWorldObj().setBlockMetadataWithNotify(crop.xCoord,crop.yCoord,crop.zCoord,2,2);
      update=true;
      ArrayList<ItemStack> drops=SeedHelper.getPlantFruits((ItemSeeds)crop.seed,world,x,y,z,crop.gain,crop.seedMeta);
      for (      ItemStack drop : drops) {
        this.dropBlockAsItem(world,x,y,z,drop);
      }
    }
    if (update) {
      crop.markDirty();
    }
    return update;
  }
  return false;
}

Fixed version (ground truth):
public boolean harvest(World world,int x,int y,int z){
  if (!world.isRemote) {
    boolean update=false;
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (crop.weed) {
      crop.clearWeed();
    }
 else     if (crop.crossCrop) {
      crop.crossCrop=false;
      this.dropBlockAsItem(world,x,y,z,new ItemStack(Items.crops,1));
      update=true;
    }
 else     if (crop.isMature()) {
      crop.getWorldObj().setBlockMetadataWithNotify(crop.xCoord,crop.yCoord,crop.zCoord,2,2);
      update=true;
      ArrayList<ItemStack> drops=SeedHelper.getPlantFruits((ItemSeeds)crop.seed,world,x,y,z,crop.gain,crop.seedMeta);
      for (      ItemStack drop : drops) {
        this.dropBlockAsItem(world,x,y,z,drop);
      }
    }
    if (update) {
      crop.markDirtyAndMarkForUpdate();
    }
    return update;
  }
  return false;
}
Program: 95775
Project: 95775
Buggy source:
public void setCrossCrop(World world,int x,int y,int z,EntityPlayer player){
  if (!world.isRemote) {
    boolean update=false;
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (!crop.crossCrop && !crop.hasPlant()) {
      crop.crossCrop=true;
      player.getCurrentEquippedItem().stackSize=player.capabilities.isCreativeMode ? player.getCurrentEquippedItem().stackSize : player.getCurrentEquippedItem().stackSize - 1;
      update=true;
    }
 else {
      this.harvest(world,x,y,z);
    }
    if (update) {
      crop.markDirty();
    }
  }
}

Fixed version (ground truth):
public void setCrossCrop(World world,int x,int y,int z,EntityPlayer player){
  if (!world.isRemote) {
    boolean update=false;
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (!crop.crossCrop && !crop.hasPlant()) {
      crop.crossCrop=true;
      player.getCurrentEquippedItem().stackSize=player.capabilities.isCreativeMode ? player.getCurrentEquippedItem().stackSize : player.getCurrentEquippedItem().stackSize - 1;
      update=true;
    }
 else {
      this.harvest(world,x,y,z);
    }
    if (update) {
      crop.markDirtyAndMarkForUpdate();
    }
  }
}
Program: 95777
Project: 95777
Buggy source:
@Override public ItemStack transferStackInSlot(EntityPlayer player,int clickedSlot){
  ItemStack itemstack=null;
  Slot slot=(Slot)this.inventorySlots.get(clickedSlot);
  if (slot != null && slot.getHasStack()) {
    ItemStack itemstack1=slot.getStack();
    itemstack=itemstack1.copy();
    if (clickedSlot == seedSlotId || clickedSlot == journalSlotId) {
      if (!this.mergeItemStack(itemstack1,0,inventorySlots.size(),false)) {
        return null;
      }
    }
 else {
      if (itemstack1.getItem() != null) {
        if (itemstack1.getItem() instanceof ItemSeeds) {
          if (!SeedHelper.isValidSeed((ItemSeeds)itemstack1.getItem(),itemstack1.getItemDamage())) {
            return null;
          }
          if (!this.mergeItemStack(itemstack1,seedSlotId,seedSlotId + 1,false)) {
            return null;
          }
        }
 else         if (itemstack1.getItem() instanceof ItemJournal) {
          if (!this.mergeItemStack(itemstack1,journalSlotId,journalSlotId + 1,false)) {
            return null;
          }
        }
      }
    }
    if (itemstack1.stackSize == 0) {
      slot.putStack(null);
    }
 else {
      slot.onSlotChanged();
    }
    if (itemstack1.stackSize == itemstack.stackSize) {
      return null;
    }
    slot.onPickupFromSlot(player,itemstack1);
  }
  return itemstack;
}

Fixed version (ground truth):
@Override public ItemStack transferStackInSlot(EntityPlayer player,int clickedSlot){
  ItemStack itemstack=null;
  Slot slot=(Slot)this.inventorySlots.get(clickedSlot);
  if (slot != null && slot.getHasStack()) {
    ItemStack itemstack1=slot.getStack();
    itemstack=itemstack1.copy();
    if (clickedSlot == seedSlotId || clickedSlot == journalSlotId) {
      if (!this.mergeItemStack(itemstack1,0,inventorySlots.size() - 2,false)) {
        return null;
      }
    }
 else {
      if (itemstack1.getItem() != null) {
        if (itemstack1.getItem() instanceof ItemSeeds) {
          if (!SeedHelper.isValidSeed((ItemSeeds)itemstack1.getItem(),itemstack1.getItemDamage())) {
            return null;
          }
          if (!this.mergeItemStack(itemstack1,seedSlotId,seedSlotId + 1,false)) {
            return null;
          }
        }
 else         if (itemstack1.getItem() instanceof ItemJournal) {
          if (!this.mergeItemStack(itemstack1,journalSlotId,journalSlotId + 1,false)) {
            return null;
          }
        }
      }
    }
    if (itemstack1.stackSize == 0) {
      slot.putStack(null);
    }
 else {
      slot.onSlotChanged();
    }
    if (itemstack1.stackSize == itemstack.stackSize) {
      return null;
    }
    slot.onPickupFromSlot(player,itemstack1);
  }
  return itemstack;
}
Program: 95778
Project: 95778
Buggy source:
@Override public void harvestBlock(World world,EntityPlayer player,int x,int y,int z,int meta){
  if ((!world.isRemote) && (!player.isSneaking())) {
    if (!player.capabilities.isCreativeMode) {
      this.dropBlockAsItem(world,x,y,z,world.getBlockMetadata(x,y,z),0);
    }
    world.setBlockToAir(x,y,z);
    world.removeTileEntity(x,y,z);
  }
}

Fixed version (ground truth):
@Override public void harvestBlock(World world,EntityPlayer player,int x,int y,int z,int meta){
  if ((!world.isRemote) && (!player.isSneaking())) {
    if (!player.capabilities.isCreativeMode) {
      this.dropBlockAsItem(world,x,y,z,world.getBlockMetadata(x,y,z),0);
    }
    world.setBlockToAir(x,y,z);
  }
}
Program: 95779
Project: 95779
Buggy source:
@Override public void updateEntity(){
  if (!worldObj.isRemote) {
    for (int yOffset=1; yOffset < 5; yOffset++) {
      for (int xOffset=-3; xOffset <= 3; xOffset++) {
        for (int zOffset=-3; zOffset <= 3; zOffset++) {
          if (this.sprinkle() && this.irrigate(this.xCoord + xOffset,this.yCoord - yOffset,this.zCoord + zOffset)) {
            TileEntityChannel channel=(TileEntityChannel)this.worldObj.getTileEntity(this.xCoord,this.yCoord + 1,this.zCoord);
            channel.setFluidLevel(channel.getFluidLevel() - 1);
          }
        }
      }
    }
  }
 else {
    if (this.isSprinkled) {
      this.renderLiquidSpray();
    }
  }
}

Fixed version (ground truth):
@Override public void updateEntity(){
  if (!worldObj.isRemote) {
    if (this.canSprinkle())     counter=(counter + 1) % 60;
    for (int yOffset=1; yOffset < 5; yOffset++) {
      for (int xOffset=-3; xOffset <= 3; xOffset++) {
        for (int zOffset=-3; zOffset <= 3; zOffset++) {
          if (this.sprinkle() && this.irrigate(this.xCoord + xOffset,this.yCoord - yOffset,this.zCoord + zOffset)) {
            TileEntityChannel channel=(TileEntityChannel)this.worldObj.getTileEntity(this.xCoord,this.yCoord + 1,this.zCoord);
            channel.setFluidLevel(channel.getFluidLevel() - 1);
          }
        }
      }
    }
  }
 else {
    if (this.isSprinkled) {
      this.renderLiquidSpray();
    }
  }
}
Program: 95780
Project: 95780
Buggy source:
private boolean sprinkle(){
  boolean newState=this.canSprinkle();
  if (newState)   counter=(counter + 1) % 60;
  if (newState != this.isSprinkled) {
    this.isSprinkled=newState;
    this.markDirty();
  }
  return this.isSprinkled;
}

Fixed version (ground truth):
private boolean sprinkle(){
  boolean newState=this.canSprinkle();
  if (newState != this.isSprinkled) {
    this.isSprinkled=newState;
    this.markDirty();
  }
  return this.isSprinkled;
}
Program: 95781
Project: 95781
Buggy source:
@Override public List<String> getWailaBody(ItemStack itemStack,List<String> list,IWailaDataAccessor dataAccessor,IWailaConfigHandler configHandler){
  Block block=dataAccessor.getBlock();
  TileEntity te=dataAccessor.getTileEntity();
  if (block != null && block instanceof BlockCrop && te != null && te instanceof TileEntityCrop) {
    TileEntityCrop crop=(TileEntityCrop)te;
    int growth=crop.growth;
    int gain=crop.gain;
    int strength=crop.strength;
    String seedName=((ItemSeeds)crop.seed).getItemStackDisplayName(new ItemStack((ItemSeeds)crop.seed,1,crop.seedMeta));
    list.add(StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str" + seedName);
    list.add("String_Node_Str" + StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str"+ growth);
    list.add("String_Node_Str" + StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str"+ gain);
    list.add("String_Node_Str" + StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str"+ strength);
  }
  return list;
}

Fixed version (ground truth):
@Override public List<String> getWailaBody(ItemStack itemStack,List<String> list,IWailaDataAccessor dataAccessor,IWailaConfigHandler configHandler){
  Block block=dataAccessor.getBlock();
  TileEntity te=dataAccessor.getTileEntity();
  if (block != null && block instanceof BlockCrop && te != null && te instanceof TileEntityCrop) {
    TileEntityCrop crop=(TileEntityCrop)te;
    if (crop.hasPlant()) {
      int growth=crop.growth;
      int gain=crop.gain;
      int strength=crop.strength;
      String seedName=((ItemSeeds)crop.seed).getItemStackDisplayName(new ItemStack((ItemSeeds)crop.seed,1,crop.seedMeta));
      list.add(StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str" + seedName);
      list.add("String_Node_Str" + StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str"+ growth);
      list.add("String_Node_Str" + StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str"+ gain);
      list.add("String_Node_Str" + StatCollector.translateToLocal("String_Node_Str") + "String_Node_Str"+ strength);
    }
  }
  return list;
}
Program: 95782
Project: 95782
Buggy source:
@Override public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int side,float fX,float fY,float fZ){
  if (!world.isRemote) {
    if (player.getCurrentEquippedItem() == null) {
      this.harvest(world,x,y,z);
    }
 else     if (player.getCurrentEquippedItem().getItem() == Items.crops) {
      this.setCrossCrop(world,x,y,z,player);
    }
 else     if (player.getCurrentEquippedItem().getItem() instanceof ItemSeeds) {
      this.plantSeed(world,x,y,z,player);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int side,float fX,float fY,float fZ){
  if (!world.isRemote) {
    if (player.getCurrentEquippedItem() == null) {
      this.harvest(world,x,y,z);
    }
 else     if (player.getCurrentEquippedItem().getItem() == Items.crops) {
      this.setCrossCrop(world,x,y,z,player);
    }
 else {
      this.harvest(world,x,y,z);
      if (player.getCurrentEquippedItem().getItem() instanceof ItemSeeds) {
        this.plantSeed(world,x,y,z,player);
      }
    }
  }
  return true;
}
Program: 95783
Project: 95783
Buggy source:
public void setCrossCrop(World world,int x,int y,int z,EntityPlayer player){
  if (!world.isRemote) {
    boolean update=false;
    LogHelper.debug("String_Node_Str");
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (!crop.crossCrop && !crop.hasPlant()) {
      crop.crossCrop=true;
      player.getCurrentEquippedItem().stackSize=player.capabilities.isCreativeMode ? player.getCurrentEquippedItem().stackSize : player.getCurrentEquippedItem().stackSize - 1;
      update=true;
      LogHelper.debug("String_Node_Str");
    }
    if (update) {
      this.syncAndUpdate(world,x,y,z);
    }
  }
}

Fixed version (ground truth):
public void setCrossCrop(World world,int x,int y,int z,EntityPlayer player){
  if (!world.isRemote) {
    boolean update=false;
    LogHelper.debug("String_Node_Str");
    TileEntityCrop crop=(TileEntityCrop)world.getTileEntity(x,y,z);
    if (!crop.crossCrop && !crop.hasPlant()) {
      crop.crossCrop=true;
      player.getCurrentEquippedItem().stackSize=player.capabilities.isCreativeMode ? player.getCurrentEquippedItem().stackSize : player.getCurrentEquippedItem().stackSize - 1;
      update=true;
      LogHelper.debug("String_Node_Str");
    }
 else {
      this.harvest(world,x,y,z);
    }
    if (update) {
      this.syncAndUpdate(world,x,y,z);
    }
  }
}
Program: 95785
Project: 95785
Buggy source:
@Override protected void onResume(){
  super.onResume();
  Log.d("String_Node_Str","String_Node_Str");
  if (simpleBluetooth == null) {
    simpleBluetooth=new SimpleBluetooth(this,this);
  }
  simpleBluetooth.initializeSimpleBluetooth();
  simpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.BUFFERED);
  simpleBluetooth.setSimpleBluetoothListener(new SimpleBluetoothListener(){
    @Override public void onBluetoothDataReceived(    byte[] bytes,    String data){
      Toast.makeText(MainActivity.this,"String_Node_Str" + data,Toast.LENGTH_SHORT).show();
      connectionState.setText("String_Node_Str" + data);
      isConnected=false;
      Log.w("String_Node_Str","String_Node_Str");
    }
    @Override public void onDeviceConnected(    BluetoothDevice device){
      Toast.makeText(MainActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
      connectionState.setText("String_Node_Str");
      isConnected=true;
      Log.w("String_Node_Str","String_Node_Str");
    }
    @Override public void onDeviceDisconnected(    BluetoothDevice device){
      Toast.makeText(MainActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
      connectionState.setText("String_Node_Str");
      Log.w("String_Node_Str","String_Node_Str");
    }
    @Override public void onDiscoveryStarted(){
    }
    @Override public void onDiscoveryFinished(){
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (simpleBluetooth == null) {
    simpleBluetooth=new SimpleBluetooth(this,this);
  }
  simpleBluetooth.initializeSimpleBluetooth();
  simpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.BUFFERED);
  simpleBluetooth.setSimpleBluetoothListener(new SimpleBluetoothListener(){
    @Override public void onBluetoothDataReceived(    byte[] bytes,    String data){
      Toast.makeText(MainActivity.this,"String_Node_Str" + data,Toast.LENGTH_SHORT).show();
      connectionState.setText("String_Node_Str" + data);
      isConnected=false;
      Log.w("String_Node_Str","String_Node_Str");
    }
    @Override public void onDeviceConnected(    BluetoothDevice device){
      Toast.makeText(MainActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
      connectionState.setText("String_Node_Str");
      isConnected=true;
      Log.w("String_Node_Str","String_Node_Str");
    }
    @Override public void onDeviceDisconnected(    BluetoothDevice device){
      Toast.makeText(MainActivity.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
      connectionState.setText("String_Node_Str");
      Log.w("String_Node_Str","String_Node_Str");
    }
    @Override public void onDiscoveryStarted(){
    }
    @Override public void onDiscoveryFinished(){
    }
  }
);
}
Program: 95786
Project: 95786
Buggy source:
public ConnectedThread(BluetoothSocket socket){
  mmSocket=socket;
  bluetoothSocket=socket;
  InputStream tmpIn=null;
  OutputStream tmpOut=null;
  try {
    tmpIn=socket.getInputStream();
    tmpOut=socket.getOutputStream();
  }
 catch (  IOException e) {
    Log.d("String_Node_Str",e.getMessage());
  }
  mInputStream=tmpIn;
  mOutputStream=tmpOut;
}

Fixed version (ground truth):
public ConnectedThread(BluetoothSocket socket){
  mmSocket=socket;
  bluetoothSocket=socket;
  InputStream tmpIn=null;
  OutputStream tmpOut=null;
  try {
    tmpIn=socket.getInputStream();
    tmpOut=socket.getOutputStream();
  }
 catch (  IOException e) {
  }
  mInputStream=tmpIn;
  mOutputStream=tmpOut;
}
Program: 95787
Project: 95787
Buggy source:
@Override public void handleMessage(Message message){
switch (message.what) {
case MESSAGE_READ:
    byte[] readBuf=(byte[])message.obj;
  String readMessage=new String(readBuf);
if (readBuf.length > 0) {
  if (mListener != null)   mListener.onBluetoothDataReceived(readBuf,readMessage);
}
break;
case MESSAGE_WAIT_FOR_CONNECTION:
if (dialog != null) {
dialog.setTitle("String_Node_Str");
dialog.setMessage("String_Node_Str");
dialog.show();
}
break;
case MESSAGE_CONNECTION_MADE:
if (dialog != null) {
if (dialog.isShowing()) {
dialog.dismiss();
if (shouldShowSnackbars && mActivity != null) {
Snackbar.make(mActivity.findViewById(android.R.id.content),"String_Node_Str",Snackbar.LENGTH_SHORT).show();
}
}
}
break;
case MESSAGE_A2DP_PROXY_RECEIVED:
BluetoothA2dp device=(BluetoothA2dp)message.obj;
if (device != null && mListener != null) {
mListener.onBluetoothA2DPRequested(device);
}
break;
default :
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
switch (message.what) {
case MESSAGE_READ:
    byte[] readBuf=(byte[])message.obj;
  int datalength=message.arg1;
String readMessage=new String(readBuf,0,datalength);
if (readBuf.length > 0) {
if (mListener != null) mListener.onBluetoothDataReceived(readBuf,readMessage);
}
break;
case MESSAGE_WAIT_FOR_CONNECTION:
if (dialog != null) {
dialog.setTitle("String_Node_Str");
dialog.setMessage("String_Node_Str");
dialog.show();
}
break;
case MESSAGE_CONNECTION_MADE:
if (dialog != null) {
if (dialog.isShowing()) {
dialog.dismiss();
if (shouldShowSnackbars && mActivity != null) {
Snackbar.make(mActivity.findViewById(android.R.id.content),"String_Node_Str",Snackbar.LENGTH_SHORT).show();
}
}
}
break;
case MESSAGE_A2DP_PROXY_RECEIVED:
BluetoothA2dp device=(BluetoothA2dp)message.obj;
if (device != null && mListener != null) {
mListener.onBluetoothA2DPRequested(device);
}
break;
default :
break;
}
}
Program: 95788
Project: 95788
Buggy source:
private boolean isSubDirectory(FilePath parent,FilePath child){
  FilePath parentFolder=child;
  while (parentFolder != null) {
    if (parent.equals(parentFolder)) {
      return true;
    }
    parentFolder=child.getParent();
  }
  return false;
}

Fixed version (ground truth):
private boolean isSubDirectory(FilePath parent,FilePath child){
  FilePath parentFolder=child;
  while (parentFolder != null) {
    if (parent.equals(parentFolder)) {
      return true;
    }
    parentFolder=parentFolder.getParent();
  }
  return false;
}
Program: 95790
Project: 95790
Buggy source:
private String createDeployment(AWSClients aws,RevisionLocation revisionLocation) throws Exception {
  this.logger.println("String_Node_Str" + revisionLocation);
  CreateDeploymentResult createDeploymentResult=aws.codedeploy.createDeployment(new CreateDeploymentRequest().withDeploymentConfigName(this.deploymentConfig).withDeploymentGroupName(this.deploymentGroupName).withApplicationName(this.applicationName).withRevision(revisionLocation).withDescription("String_Node_Str"));
  return createDeploymentResult.getDeploymentId();
}

Fixed version (ground truth):
private String createDeployment(AWSClients aws,RevisionLocation revisionLocation,String deploymentGroupName) throws Exception {
  this.logger.println("String_Node_Str" + revisionLocation);
  CreateDeploymentResult createDeploymentResult=aws.codedeploy.createDeployment(new CreateDeploymentRequest().withDeploymentConfigName(this.deploymentConfig).withDeploymentGroupName(deploymentGroupName).withApplicationName(this.applicationName).withRevision(revisionLocation).withDescription("String_Node_Str"));
  return createDeploymentResult.getDeploymentId();
}
Program: 95791
Project: 95791
Buggy source:
private void verifyCodeDeployApplication(AWSClients aws) throws IllegalArgumentException {
  ListApplicationsResult applications=aws.codedeploy.listApplications();
  if (!applications.getApplications().contains(this.applicationName)) {
    throw new IllegalArgumentException("String_Node_Str" + this.applicationName + "String_Node_Str");
  }
  ListDeploymentGroupsResult deploymentGroups=aws.codedeploy.listDeploymentGroups(new ListDeploymentGroupsRequest().withApplicationName(this.applicationName));
  if (!deploymentGroups.getDeploymentGroups().contains(this.deploymentGroupName)) {
    throw new IllegalArgumentException("String_Node_Str" + this.deploymentGroupName + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void verifyCodeDeployApplication(AWSClients aws,String deploymentGroupName) throws IllegalArgumentException {
  ListApplicationsResult applications=aws.codedeploy.listApplications();
  if (!applications.getApplications().contains(this.applicationName)) {
    throw new IllegalArgumentException("String_Node_Str" + this.applicationName + "String_Node_Str");
  }
  ListDeploymentGroupsResult deploymentGroups=aws.codedeploy.listDeploymentGroups(new ListDeploymentGroupsRequest().withApplicationName(this.applicationName));
  if (!deploymentGroups.getDeploymentGroups().contains(deploymentGroupName)) {
    throw new IllegalArgumentException("String_Node_Str" + deploymentGroupName + "String_Node_Str");
  }
}
Program: 95793
Project: 95793
Buggy source:
/** 
 * Leader A and follower B commit 5 entries, then snapshot A. Then C comes up and should get the 5 committed entries as well, as a snapshot
 */
public void testInstallSnapshotInC() throws Exception {
  init(true);
  close(true,true,c);
  for (int i=1; i <= 5; i++)   as.put(i,i);
  assertSame(as,bs);
  as.snapshot();
  c=create("String_Node_Str",true);
  cs=new ReplicatedStateMachine<>(c);
  c.connect(CLUSTER);
  Util.waitUntilAllChannelsHaveSameSize(10000,500,a,b,c);
  assertSame(as,bs,cs);
}

Fixed version (ground truth):
/** 
 * Leader A and follower B commit 5 entries, then snapshot A. Then C comes up and should get the 5 committed entries as well, as a snapshot
 */
public void testInstallSnapshotInC() throws Exception {
  init(true);
  close(true,true,c);
  for (int i=1; i <= 5; i++)   as.put(i,i);
  assertSame(as,bs);
  as.snapshot();
  c=create("String_Node_Str",true);
  cs=new ReplicatedStateMachine<>(c);
  c.connect(CLUSTER);
  Util.waitUntilAllChannelsHaveSameView(10000,500,a,b,c);
  assertSame(as,bs,cs);
}
Program: 95794
Project: 95794
Buggy source:
/** 
 * Leader A and followers B and C commit entries 1-2. Then C leaves and A and B commit entries 3-5. When C rejoins, it should get log entries 3-5 as well.
 */
public void testCatchingUp() throws Exception {
  init(true);
  for (int i=1; i <= 2; i++)   as.put(i,i);
  assertSame(as,bs,cs);
  close(true,true,c);
  for (int i=3; i <= 5; i++)   as.put(i,i);
  assertSame(as,bs);
  c=create("String_Node_Str",true);
  cs=new ReplicatedStateMachine<>(c);
  c.connect(CLUSTER);
  Util.waitUntilAllChannelsHaveSameSize(10000,500,a,b,c);
  assertSame(as,bs,cs);
}

Fixed version (ground truth):
/** 
 * Leader A and followers B and C commit entries 1-2. Then C leaves and A and B commit entries 3-5. When C rejoins, it should get log entries 3-5 as well.
 */
public void testCatchingUp() throws Exception {
  init(true);
  for (int i=1; i <= 2; i++)   as.put(i,i);
  assertSame(as,bs,cs);
  close(true,true,c);
  for (int i=3; i <= 5; i++)   as.put(i,i);
  assertSame(as,bs);
  c=create("String_Node_Str",true);
  cs=new ReplicatedStateMachine<>(c);
  c.connect(CLUSTER);
  Util.waitUntilAllChannelsHaveSameView(10000,500,a,b,c);
  assertSame(as,bs,cs);
}
Program: 95795
Project: 95795
Buggy source:
@BeforeMethod protected void init() throws Exception {
  a=create("String_Node_Str");
  a.connect(CLUSTER);
  b=create("String_Node_Str");
  b.connect(CLUSTER);
  c=create("String_Node_Str");
  c.connect(CLUSTER);
  Util.waitUntilAllChannelsHaveSameSize(10000,500,a,b,c);
}

Fixed version (ground truth):
@BeforeMethod protected void init() throws Exception {
  a=create("String_Node_Str");
  a.connect(CLUSTER);
  b=create("String_Node_Str");
  b.connect(CLUSTER);
  c=create("String_Node_Str");
  c.connect(CLUSTER);
  Util.waitUntilAllChannelsHaveSameView(10000,500,a,b,c);
}
Program: 95796
Project: 95796
Buggy source:
@Override public void truncate(int upto_index){
  if ((upto_index < firstApplied) || (upto_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=firstApplied; index < upto_index; index++) {
      batch.delete(db.get(fromIntToByteArray(index)));
    }
    LogEntry last=getLogEntry(upto_index);
    if (last == null) {
      updateCurrentTerm(0,batch);
    }
 else {
      updateCurrentTerm(last.term,batch);
    }
    firstApplied=upto_index;
    batch.put(FIRSTAPPLIED,fromIntToByteArray(upto_index));
  }
  finally {
    Util.close(batch);
  }
}

Fixed version (ground truth):
@Override public void truncate(int upto_index){
  if ((upto_index < firstApplied) || (upto_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=firstApplied; index < upto_index; index++) {
      batch.delete(db.get(fromIntToByteArray(index)));
    }
    LogEntry last=getLogEntry(upto_index);
    firstApplied=upto_index;
    batch.put(FIRSTAPPLIED,fromIntToByteArray(upto_index));
    db.write(batch);
  }
  finally {
    Util.close(batch);
  }
}
Program: 95797
Project: 95797
Buggy source:
@Override public void deleteAllEntriesStartingFrom(int start_index){
  if ((start_index < firstApplied) || (start_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=start_index; index <= lastApplied; index++) {
      batch.delete(db.get(fromIntToByteArray(index)));
    }
    LogEntry last=getLogEntry(start_index - 1);
    if (last == null) {
      updateCurrentTerm(0,batch);
    }
 else {
      updateCurrentTerm(last.term,batch);
    }
    updateLastApplied(start_index - 1,batch);
  }
  finally {
    Util.close(batch);
  }
}

Fixed version (ground truth):
@Override public void deleteAllEntriesStartingFrom(int start_index){
  if ((start_index < firstApplied) || (start_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=start_index; index <= lastApplied; index++) {
      batch.delete(db.get(fromIntToByteArray(index)));
    }
    LogEntry last=getLogEntry(start_index - 1);
    if (last == null) {
      updateCurrentTerm(0,batch);
    }
 else {
      updateCurrentTerm(last.term,batch);
    }
    updateLastApplied(start_index - 1,batch);
    db.write(batch);
  }
  finally {
    Util.close(batch);
  }
}
Program: 95798
Project: 95798
Buggy source:
public static void main(String[] args) throws Exception {
  LevelDBLog log=new LevelDBLog();
  Address addr=Util.createRandomAddress("String_Node_Str");
  log.init("String_Node_Str",null);
  log.append(1,true,new LogEntry(1,"String_Node_Str".getBytes()));
  log.append(2,true,new LogEntry(2,"String_Node_Str".getBytes()));
  log.append(3,true,new LogEntry(3,"String_Node_Str".getBytes()));
  log.append(3,true,new LogEntry(3,"String_Node_Str".getBytes()));
  log.forEach(null,0,3);
  log.printMetadata();
  log.close();
  log.delete();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  LevelDBLog log=new LevelDBLog();
  Address addr=Util.createRandomAddress("String_Node_Str");
  log.init("String_Node_Str",null);
  log.printMetadata();
  log.close();
}
Program: 95799
Project: 95799
Buggy source:
public void testDeleteEntriesFromFirst(Log log) throws Exception {
  this.log=log;
  log.init(filename,null);
  byte[] buf=new byte[10];
  log.append(1,false,new LogEntry(1,buf));
  log.append(2,false,new LogEntry(1,buf));
  log.append(3,false,new LogEntry(1,buf));
  log.append(4,false,new LogEntry(2,buf));
  log.append(5,false,new LogEntry(2,buf));
  log.append(6,false,new LogEntry(2,buf));
  log.append(7,false,new LogEntry(3,buf));
  log.append(8,false,new LogEntry(3,buf));
  log.append(9,false,new LogEntry(3,buf));
  log.append(10,false,new LogEntry(3,buf));
  log.append(11,false,new LogEntry(3,buf));
  log.commitIndex(11);
  log.deleteAllEntriesStartingFrom(1);
  assertEquals(log.lastApplied(),0);
  assertEquals(log.currentTerm(),0);
}

Fixed version (ground truth):
public void testDeleteEntriesFromFirst(Log log) throws Exception {
  this.log=log;
  log.init(filename,null);
  byte[] buf=new byte[10];
  log.append(1,false,new LogEntry(1,buf));
  log.append(2,false,new LogEntry(1,buf));
  log.append(3,false,new LogEntry(1,buf));
  log.append(4,false,new LogEntry(2,buf));
  log.append(5,false,new LogEntry(2,buf));
  log.append(6,false,new LogEntry(2,buf));
  log.append(7,false,new LogEntry(3,buf));
  log.append(8,false,new LogEntry(3,buf));
  log.append(9,false,new LogEntry(3,buf));
  log.append(10,false,new LogEntry(3,buf));
  log.append(11,false,new LogEntry(3,buf));
  log.commitIndex(11);
  log.deleteAllEntriesStartingFrom(1);
  assertEquals(log.firstApplied(),1);
  assertEquals(log.lastApplied(),0);
  assertEquals(log.currentTerm(),0);
}
Program: 95800
Project: 95800
Buggy source:
public void testDeleteEntriesInTheMiddle(Log log) throws Exception {
  this.log=log;
  log.init(filename,null);
  byte[] buf=new byte[10];
  log.append(1,false,new LogEntry(1,buf));
  log.append(2,false,new LogEntry(1,buf));
  log.append(3,false,new LogEntry(1,buf));
  log.append(4,false,new LogEntry(2,buf));
  log.append(5,false,new LogEntry(2,buf));
  log.append(6,false,new LogEntry(2,buf));
  log.append(7,false,new LogEntry(3,buf));
  log.append(8,false,new LogEntry(3,buf));
  log.append(9,false,new LogEntry(3,buf));
  log.append(10,false,new LogEntry(3,buf));
  log.append(11,false,new LogEntry(3,buf));
  log.commitIndex(11);
  log.deleteAllEntriesStartingFrom(6);
  assertEquals(log.lastApplied(),5);
  assertEquals(log.currentTerm(),2);
}

Fixed version (ground truth):
public void testDeleteEntriesInTheMiddle(Log log) throws Exception {
  this.log=log;
  log.init(filename,null);
  byte[] buf=new byte[10];
  log.append(1,false,new LogEntry(1,buf));
  log.append(2,false,new LogEntry(1,buf));
  log.append(3,false,new LogEntry(1,buf));
  log.append(4,false,new LogEntry(2,buf));
  log.append(5,false,new LogEntry(2,buf));
  log.append(6,false,new LogEntry(2,buf));
  log.append(7,false,new LogEntry(3,buf));
  log.append(8,false,new LogEntry(3,buf));
  log.append(9,false,new LogEntry(3,buf));
  log.append(10,false,new LogEntry(3,buf));
  log.append(11,false,new LogEntry(3,buf));
  log.commitIndex(11);
  log.deleteAllEntriesStartingFrom(6);
  assertEquals(log.firstApplied(),1);
  assertEquals(log.lastApplied(),5);
  assertEquals(log.currentTerm(),2);
}
Program: 95801
Project: 95801
Buggy source:
public void testTruncateInTheMiddle(Log log) throws Exception {
  this.log=log;
  log.init(filename,null);
  byte[] buf=new byte[10];
  log.append(1,false,new LogEntry(1,buf));
  log.append(2,false,new LogEntry(1,buf));
  log.append(3,false,new LogEntry(1,buf));
  log.append(4,false,new LogEntry(2,buf));
  log.append(5,false,new LogEntry(2,buf));
  log.append(6,false,new LogEntry(2,buf));
  log.append(7,false,new LogEntry(3,buf));
  log.append(8,false,new LogEntry(3,buf));
  log.append(9,false,new LogEntry(3,buf));
  log.append(10,false,new LogEntry(3,buf));
  log.append(11,false,new LogEntry(3,buf));
  log.commitIndex(11);
  log.truncate(7);
  assertEquals(log.lastApplied(),11);
  assertEquals(log.currentTerm(),3);
  assertEquals(log.firstApplied(),7);
}

Fixed version (ground truth):
public void testTruncateInTheMiddle(Log log) throws Exception {
  this.log=log;
  log.init(filename,null);
  byte[] buf=new byte[10];
  log.append(1,false,new LogEntry(1,buf));
  log.append(2,false,new LogEntry(1,buf));
  log.append(3,false,new LogEntry(1,buf));
  log.append(4,false,new LogEntry(2,buf));
  log.append(5,false,new LogEntry(2,buf));
  log.append(6,false,new LogEntry(2,buf));
  log.append(7,false,new LogEntry(3,buf));
  log.append(8,false,new LogEntry(3,buf));
  log.append(9,false,new LogEntry(3,buf));
  log.append(10,false,new LogEntry(3,buf));
  log.append(11,false,new LogEntry(3,buf));
  log.commitIndex(11);
  log.truncate(6);
  assertEquals(log.lastApplied(),11);
  assertEquals(log.currentTerm(),3);
  assertEquals(log.firstApplied(),6);
}
Program: 95802
Project: 95802
Buggy source:
@Override public void truncate(int upto_index){
  if ((upto_index < firstApplied) || (upto_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=firstApplied; index < upto_index; index++) {
      batch.delete(db.get(fromIntToByteArray(index)));
    }
    LogEntry last=getLogEntry(upto_index);
    firstApplied=upto_index;
    batch.put(FIRSTAPPLIED,fromIntToByteArray(upto_index));
    db.write(batch);
  }
  finally {
    Util.close(batch);
  }
}

Fixed version (ground truth):
@Override public void truncate(int upto_index){
  if ((upto_index < firstApplied) || (upto_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=firstApplied; index < upto_index; index++) {
      batch.delete(fromIntToByteArray(index));
    }
    firstApplied=upto_index;
    batch.put(FIRSTAPPLIED,fromIntToByteArray(upto_index));
    db.write(batch);
  }
  finally {
    Util.close(batch);
  }
}
Program: 95803
Project: 95803
Buggy source:
@Override public void deleteAllEntriesStartingFrom(int start_index){
  if ((start_index < firstApplied) || (start_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=start_index; index <= lastApplied; index++) {
      batch.delete(db.get(fromIntToByteArray(index)));
    }
    LogEntry last=getLogEntry(start_index - 1);
    if (last == null) {
      updateCurrentTerm(0,batch);
    }
 else {
      updateCurrentTerm(last.term,batch);
    }
    updateLastApplied(start_index - 1,batch);
    db.write(batch);
  }
  finally {
    Util.close(batch);
  }
}

Fixed version (ground truth):
@Override public void deleteAllEntriesStartingFrom(int start_index){
  if ((start_index < firstApplied) || (start_index > lastApplied)) {
    return;
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (int index=start_index; index <= lastApplied; index++) {
      batch.delete(fromIntToByteArray(index));
    }
    LogEntry last=getLogEntry(start_index - 1);
    if (last == null) {
      updateCurrentTerm(0,batch);
    }
 else {
      updateCurrentTerm(last.term,batch);
    }
    updateLastApplied(start_index - 1,batch);
    db.write(batch);
  }
  finally {
    Util.close(batch);
  }
}