nus-yam/ex-repair huggingface dataset:
Program: 161390
Project: 161390
Buggy source:
@Override protected void onBlockRemoved(IMultiblockPart part){
  CoordTriplet coord=part.getWorldLocation();
  if (part instanceof TileEntityReactorAccessPort) {
    if (attachedAccessPorts.contains(coord)) {
      attachedAccessPorts.remove(coord);
    }
  }
 else   if (part instanceof TileEntityReactorControlRod) {
    attachedControlRods.remove(coord);
    if (attachedControlRods.contains(coord)) {
      attachedControlRods.remove(coord);
    }
  }
 else   if (part instanceof TileEntityReactorPart) {
    int metadata=((TileEntityReactorPart)part).getBlockMetadata();
    if (BlockReactorPart.isController(metadata) && attachedControllers.contains(coord)) {
      attachedControllers.remove(coord);
    }
  }
}

Fixed version (ground truth):
@Override protected void onBlockRemoved(IMultiblockPart part){
  CoordTriplet coord=part.getWorldLocation();
  if (part instanceof TileEntityReactorAccessPort) {
    if (attachedAccessPorts.contains(coord)) {
      attachedAccessPorts.remove(coord);
    }
  }
 else   if (part instanceof TileEntityReactorControlRod) {
    attachedControlRods.remove(coord);
    if (attachedControlRods.contains(coord)) {
      attachedControlRods.remove(coord);
    }
  }
 else   if (part instanceof TileEntityReactorPowerTap) {
    attachedPowerTaps.remove(coord);
  }
 else   if (part instanceof TileEntityReactorPart) {
    int metadata=((TileEntityReactorPart)part).getBlockMetadata();
    if (BlockReactorPart.isController(metadata) && attachedControllers.contains(coord)) {
      attachedControllers.remove(coord);
    }
  }
}
Program: 161391
Project: 161391
Buggy source:
@Override protected void onBlockAdded(IMultiblockPart part){
  CoordTriplet coord=part.getWorldLocation();
  if (part instanceof TileEntityReactorAccessPort) {
    if (!attachedAccessPorts.contains(coord)) {
      attachedAccessPorts.add(coord);
    }
  }
 else   if (part instanceof TileEntityReactorControlRod) {
    if (!attachedControlRods.contains(coord)) {
      attachedControlRods.add(coord);
    }
  }
 else   if (part instanceof TileEntityReactorPart) {
    int metadata=((TileEntityReactorPart)part).getBlockMetadata();
    if (BlockReactorPart.isController(metadata) && !attachedControllers.contains(coord)) {
      attachedControllers.add(coord);
    }
  }
}

Fixed version (ground truth):
@Override protected void onBlockAdded(IMultiblockPart part){
  CoordTriplet coord=part.getWorldLocation();
  if (part instanceof TileEntityReactorAccessPort) {
    if (!attachedAccessPorts.contains(coord)) {
      attachedAccessPorts.add(coord);
    }
  }
 else   if (part instanceof TileEntityReactorControlRod) {
    if (!attachedControlRods.contains(coord)) {
      attachedControlRods.add(coord);
    }
  }
 else   if (part instanceof TileEntityReactorPowerTap) {
    attachedPowerTaps.add(coord);
  }
 else   if (part instanceof TileEntityReactorPart) {
    int metadata=((TileEntityReactorPart)part).getBlockMetadata();
    if (BlockReactorPart.isController(metadata) && !attachedControllers.contains(coord)) {
      attachedControllers.add(coord);
    }
  }
}
Program: 161392
Project: 161392
Buggy source:
public MultiblockReactor(World world){
  super(world);
  active=false;
  latentHeat=0.0;
  storedEnergy=0;
  energyGeneratedLastTick=0.0;
  wasteEjection=WasteEjectionSetting.kAutomatic;
  activePowerTaps=new LinkedList<CoordTriplet>();
  attachedControlRods=new LinkedList<CoordTriplet>();
  attachedAccessPorts=new LinkedList<CoordTriplet>();
  attachedControllers=new LinkedList<CoordTriplet>();
  updatePlayers=new HashSet<EntityPlayer>();
  ticksSinceLastUpdate=0;
}

Fixed version (ground truth):
public MultiblockReactor(World world){
  super(world);
  active=false;
  latentHeat=0.0;
  storedEnergy=0;
  energyGeneratedLastTick=0.0;
  wasteEjection=WasteEjectionSetting.kAutomatic;
  attachedPowerTaps=new HashSet<CoordTriplet>();
  attachedControlRods=new LinkedList<CoordTriplet>();
  attachedAccessPorts=new LinkedList<CoordTriplet>();
  attachedControllers=new LinkedList<CoordTriplet>();
  updatePlayers=new HashSet<EntityPlayer>();
  ticksSinceLastUpdate=0;
}
Program: 161393
Project: 161393
Buggy source:
protected void checkForConnections(World world,int x,int y,int z){
  CoordTriplet[] blocksToCheck=new CoordTriplet[]{new CoordTriplet(x + 1,y,z),new CoordTriplet(x - 1,y,z),new CoordTriplet(x,y + 1,z),new CoordTriplet(x,y - 1,z),new CoordTriplet(x,y,z + 1),new CoordTriplet(x,y,z - 1)};
  boolean wasConnected=powerConnections.size() > 0;
  for (  CoordTriplet coord : blocksToCheck) {
    TileEntity te=world.getBlockTileEntity(coord.x,coord.y,coord.z);
    boolean shouldAdd=false;
    if (te == null || te instanceof TileEntityReactorPowerTap) {
      shouldAdd=false;
    }
 else     if (te instanceof IPowerReceptor) {
      shouldAdd=true;
    }
 else     if (te instanceof IConnector) {
      IConnector connector=(IConnector)te;
      ForgeDirection directionFromThereToHere=coord.getOppositeDirectionFromSourceCoords(this.xCoord,this.yCoord,this.zCoord);
      if (connector.canConnect(directionFromThereToHere)) {
        shouldAdd=true;
      }
    }
    if (shouldAdd && !powerConnections.contains(coord)) {
      powerConnections.add(coord);
    }
 else     if (!shouldAdd && powerConnections.contains(coord)) {
      powerConnections.remove(coord);
    }
  }
  if (wasConnected && powerConnections.size() == 0) {
    world.setBlockMetadataWithNotify(x,y,z,BlockReactorPart.POWERTAP_METADATA_BASE,2);
  }
 else   if (!wasConnected && powerConnections.size() > 0) {
    world.setBlockMetadataWithNotify(x,y,z,BlockReactorPart.POWERTAP_METADATA_BASE + 1,2);
  }
  if (this.isConnected()) {
    getReactorController().onPowerTapConnectionChanged(x,y,z,powerConnections.size());
  }
}

Fixed version (ground truth):
protected void checkForConnections(World world,int x,int y,int z){
  boolean wasConnected=isConnected;
  if (out == ForgeDirection.UNKNOWN) {
    wasConnected=false;
    isConnected=false;
  }
 else {
    TileEntity te=world.getBlockTileEntity(x + out.offsetX,y + out.offsetY,z + out.offsetZ);
    if (te == null || te instanceof TileEntityReactorPowerTap) {
      isConnected=false;
    }
 else     if (te instanceof IPowerReceptor) {
      isConnected=true;
    }
 else     if (te instanceof IConnector) {
      IConnector connector=(IConnector)te;
      if (connector.canConnect(out.getOpposite())) {
        isConnected=true;
      }
 else {
        isConnected=false;
      }
    }
  }
  if (wasConnected != isConnected) {
    if (isConnected) {
      world.setBlockMetadataWithNotify(x,y,z,BlockReactorPart.POWERTAP_METADATA_BASE + 1,2);
    }
 else {
      world.setBlockMetadataWithNotify(x,y,z,BlockReactorPart.POWERTAP_METADATA_BASE,2);
    }
  }
}
Program: 161394
Project: 161394
Buggy source:
public void onMachineBroken(){
  checkForConnections(this.worldObj,this.xCoord,this.yCoord,this.zCoord);
}

Fixed version (ground truth):
public void onMachineBroken(){
  checkForConnections(this.worldObj,xCoord,yCoord,zCoord);
}
Program: 161395
Project: 161395
Buggy source:
public TileEntityReactorPowerTap(){
  super();
  powerConnections=new HashSet<CoordTriplet>();
  activeConductors=new HashSet<IConductor>();
  powerProvider=new PowerProviderBeef();
}

Fixed version (ground truth):
public TileEntityReactorPowerTap(){
  super();
  isConnected=false;
  powerProvider=new PowerProviderBeef();
  out=ForgeDirection.UNKNOWN;
}
Program: 161396
Project: 161396
Buggy source:
@Override public void onAttached(MultiblockControllerBase newController){
  super.onAttached(newController);
  if (isConnected()) {
    checkForConnections(this.worldObj,xCoord,yCoord,zCoord);
  }
}

Fixed version (ground truth):
@Override public void onAttached(MultiblockControllerBase newController){
  super.onAttached(newController);
  checkForConnections(this.worldObj,xCoord,yCoord,zCoord);
}
Program: 161398
Project: 161398
Buggy source:
@Override public boolean canConnect(ForgeDirection direction){
  if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) {
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
@Override public boolean canConnect(ForgeDirection direction){
  return direction == out;
}
Program: 161399
Project: 161399
Buggy source:
public void onMachineAssembled(CoordTriplet machineMinCoords,CoordTriplet machineMaxCoords){
  checkForConnections(this.worldObj,this.xCoord,this.yCoord,this.zCoord);
}

Fixed version (ground truth):
public void onMachineAssembled(CoordTriplet machineMinCoords,CoordTriplet machineMaxCoords){
  MultiblockControllerBase controller=this.getMultiblockController();
  CoordTriplet minCoord=controller.getMinimumCoord();
  CoordTriplet maxCoord=controller.getMaximumCoord();
  if (this.xCoord == minCoord.x) {
    out=ForgeDirection.EAST;
  }
 else   if (this.xCoord == maxCoord.x) {
    out=ForgeDirection.WEST;
  }
 else   if (this.zCoord == minCoord.z) {
    out=ForgeDirection.NORTH;
  }
 else   if (this.zCoord == maxCoord.z) {
    out=ForgeDirection.SOUTH;
  }
 else   if (this.yCoord == minCoord.y) {
    out=ForgeDirection.DOWN;
  }
 else   if (this.yCoord == maxCoord.y) {
    out=ForgeDirection.UP;
  }
 else {
    System.err.println("String_Node_Str" + this.getWorldLocation().toString() + "String_Node_Str");
    out=ForgeDirection.UNKNOWN;
  }
  checkForConnections(this.worldObj,xCoord,yCoord,zCoord);
}
Program: 161400
Project: 161400
Buggy source:
/** 
 * Discover which direction is normal to the multiblock face.
 */
protected void checkOutwardDirection(){
  MultiblockControllerBase controller=this.getMultiblockController();
  CoordTriplet minCoord=controller.getMinimumCoord();
  CoordTriplet maxCoord=controller.getMaximumCoord();
  if (this.xCoord == minCoord.x) {
    out=ForgeDirection.WEST;
  }
 else   if (this.xCoord == maxCoord.x) {
    out=ForgeDirection.EAST;
  }
 else   if (this.zCoord == minCoord.z) {
    out=ForgeDirection.SOUTH;
  }
 else   if (this.zCoord == maxCoord.z) {
    out=ForgeDirection.NORTH;
  }
 else   if (this.yCoord == minCoord.y) {
    out=ForgeDirection.DOWN;
  }
 else   if (this.yCoord == maxCoord.y) {
    out=ForgeDirection.UP;
  }
 else {
    System.err.println("String_Node_Str" + this.getWorldLocation().toString() + "String_Node_Str");
    out=ForgeDirection.UNKNOWN;
  }
}

Fixed version (ground truth):
/** 
 * Discover which direction is normal to the multiblock face.
 */
protected void checkOutwardDirection(){
  MultiblockControllerBase controller=this.getMultiblockController();
  CoordTriplet minCoord=controller.getMinimumCoord();
  CoordTriplet maxCoord=controller.getMaximumCoord();
  if (this.xCoord == minCoord.x) {
    out=ForgeDirection.WEST;
  }
 else   if (this.xCoord == maxCoord.x) {
    out=ForgeDirection.EAST;
  }
 else   if (this.zCoord == minCoord.z) {
    out=ForgeDirection.NORTH;
  }
 else   if (this.zCoord == maxCoord.z) {
    out=ForgeDirection.SOUTH;
  }
 else   if (this.yCoord == minCoord.y) {
    out=ForgeDirection.DOWN;
  }
 else   if (this.yCoord == maxCoord.y) {
    out=ForgeDirection.UP;
  }
 else {
    System.err.println("String_Node_Str" + this.getWorldLocation().toString() + "String_Node_Str");
    out=ForgeDirection.UNKNOWN;
  }
}
Program: 161403
Project: 161403
Buggy source:
/** 
 * @param itemToDistribute An ItemStack to distribute to pipes
 * @return Null if the stack was distributed, the same ItemStack otherwise.
 */
protected ItemStack distributeItemToPipes(ItemStack itemToDistribute){
  if (itemToDistribute == null) {
    return null;
  }
  ForgeDirection[] dirsToCheck={ForgeDirection.NORTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.WEST};
  for (  ForgeDirection dir : dirsToCheck) {
    TileEntity te=this.worldObj.getBlockTileEntity(xCoord + dir.offsetX,yCoord + dir.offsetY,zCoord + dir.offsetZ);
    if (te != null && te instanceof IPipeEntry) {
      IPipeEntry pipe=(IPipeEntry)te;
      if (pipe.acceptItems()) {
        pipe.entityEntering(itemToDistribute.copy(),dir.getOpposite());
        return null;
      }
    }
  }
  return itemToDistribute;
}

Fixed version (ground truth):
/** 
 * @param itemToDistribute An ItemStack to distribute to pipes
 * @return Null if the stack was distributed, the same ItemStack otherwise.
 */
protected ItemStack distributeItemToPipes(ItemStack itemToDistribute){
  if (itemToDistribute == null) {
    return null;
  }
  ForgeDirection[] dirsToCheck={ForgeDirection.NORTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.WEST};
  for (  ForgeDirection dir : dirsToCheck) {
    TileEntity te=this.worldObj.getBlockTileEntity(xCoord + dir.offsetX,yCoord + dir.offsetY,zCoord + dir.offsetZ);
    if (te != null && te instanceof IPipeEntry) {
      IPipeEntry pipe=(IPipeEntry)te;
      if (pipe.acceptItems()) {
        pipe.entityEntering(itemToDistribute.copy(),dir);
        return null;
      }
    }
  }
  return itemToDistribute;
}
Program: 161404
Project: 161404
Buggy source:
/** 
 * @param fromSlot The inventory slot into which this object would normally go.
 * @param itemToDistribute An ItemStack to distribute to pipes
 * @return Null if the stack was distributed, the same ItemStack otherwise.
 */
protected ItemStack distributeItemToPipes(int fromSlot,ItemStack itemToDistribute){
  if (itemToDistribute == null) {
    return null;
  }
  ForgeDirection[] dirsToCheck={ForgeDirection.NORTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.WEST};
  for (  ForgeDirection dir : dirsToCheck) {
    int rotatedSide=this.getRotatedSide(dir.ordinal());
    if (invExposures[rotatedSide] != fromSlot) {
      continue;
    }
    TileEntity te=this.worldObj.getBlockTileEntity(xCoord + dir.offsetX,yCoord + dir.offsetY,zCoord + dir.offsetZ);
    if (te != null && te instanceof IPipeEntry) {
      IPipeEntry pipe=(IPipeEntry)te;
      if (pipe.acceptItems()) {
        pipe.entityEntering(itemToDistribute.copy(),dir.getOpposite());
        return null;
      }
    }
  }
  return itemToDistribute;
}

Fixed version (ground truth):
/** 
 * @param fromSlot The inventory slot into which this object would normally go.
 * @param itemToDistribute An ItemStack to distribute to pipes
 * @return Null if the stack was distributed, the same ItemStack otherwise.
 */
protected ItemStack distributeItemToPipes(int fromSlot,ItemStack itemToDistribute){
  if (itemToDistribute == null) {
    return null;
  }
  ForgeDirection[] dirsToCheck={ForgeDirection.NORTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.WEST};
  for (  ForgeDirection dir : dirsToCheck) {
    int rotatedSide=this.getRotatedSide(dir.ordinal());
    if (invExposures[rotatedSide] != fromSlot) {
      continue;
    }
    TileEntity te=this.worldObj.getBlockTileEntity(xCoord + dir.offsetX,yCoord + dir.offsetY,zCoord + dir.offsetZ);
    if (te != null && te instanceof IPipeEntry) {
      IPipeEntry pipe=(IPipeEntry)te;
      if (pipe.acceptItems()) {
        pipe.entityEntering(itemToDistribute.copy(),dir);
        return null;
      }
    }
  }
  return itemToDistribute;
}
Program: 161405
Project: 161405
Buggy source:
/** 
 * Set the exposed inventory slot on a given side, using the reference side index. Only use this if you know what you're doing.
 * @param side Reference side. 2 = North, 3 = South, 4 = East, 5 = West
 * @param slot The inventory slot to expose, or -1 (INVENTORY_UNEXPOSED) if none.
 */
public void setExposedInventorySlotReference(int referenceSide,int slot){
  invExposures[referenceSide]=slot;
  if (!this.worldObj.isRemote) {
    Packet updatePacket=PacketWrapper.createPacket(BigReactors.CHANNEL,Packets.SmallMachineInventoryExposureUpdate,new Object[]{xCoord,yCoord,zCoord,referenceSide,slot});
    PacketDispatcher.sendPacketToAllAround(xCoord,yCoord,zCoord,50,worldObj.provider.dimensionId,updatePacket);
  }
}

Fixed version (ground truth):
/** 
 * Set the exposed inventory slot on a given side, using the reference side index. Only use this if you know what you're doing.
 * @param side Reference side. 2 = North, 3 = South, 4 = East, 5 = West
 * @param slot The inventory slot to expose, or -1 (INVENTORY_UNEXPOSED) if none.
 */
public void setExposedInventorySlotReference(int referenceSide,int slot){
  if (referenceSide < 0 || referenceSide >= invExposures.length) {
    return;
  }
  if (invExposures[referenceSide] == slot) {
    return;
  }
  invExposures[referenceSide]=slot;
  if (!this.worldObj.isRemote) {
    Packet updatePacket=PacketWrapper.createPacket(BigReactors.CHANNEL,Packets.SmallMachineInventoryExposureUpdate,new Object[]{xCoord,yCoord,zCoord,referenceSide,slot});
    PacketDispatcher.sendPacketToAllAround(xCoord,yCoord,zCoord,50,worldObj.provider.dimensionId,updatePacket);
    this.worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,this.worldObj.getBlockId(this.xCoord,this.yCoord,this.zCoord));
  }
}
Program: 161406
Project: 161406
Buggy source:
/** 
 * Set the externally-accessible liquid tank for a given reference direction.
 * @param side Reference direction (north/front, south/back, west/left, east/right)
 * @param tankIdx The index of the tank which can be accessed from that direction.
 */
public void setExposedTank(ForgeDirection side,int tankIdx){
  if (side == ForgeDirection.UNKNOWN) {
    return;
  }
  if (tankExposure[side.ordinal()] == tankIdx) {
    return;
  }
  tankExposure[side.ordinal()]=tankIdx;
  if (!this.worldObj.isRemote) {
    Packet updatePacket=PacketWrapper.createPacket(BigReactors.CHANNEL,Packets.SmallMachineLiquidExposureUpdate,new Object[]{xCoord,yCoord,zCoord,side.ordinal(),tankIdx});
    PacketDispatcher.sendPacketToAllAround(xCoord,yCoord,zCoord,50,worldObj.provider.dimensionId,updatePacket);
  }
}

Fixed version (ground truth):
/** 
 * Set the externally-accessible liquid tank for a given reference direction.
 * @param side Reference direction (north/front, south/back, west/left, east/right)
 * @param tankIdx The index of the tank which can be accessed from that direction.
 */
public void setExposedTank(ForgeDirection side,int tankIdx){
  if (side == ForgeDirection.UNKNOWN) {
    return;
  }
  if (tankExposure[side.ordinal()] == tankIdx) {
    return;
  }
  tankExposure[side.ordinal()]=tankIdx;
  if (!this.worldObj.isRemote) {
    Packet updatePacket=PacketWrapper.createPacket(BigReactors.CHANNEL,Packets.SmallMachineLiquidExposureUpdate,new Object[]{xCoord,yCoord,zCoord,side.ordinal(),tankIdx});
    PacketDispatcher.sendPacketToAllAround(xCoord,yCoord,zCoord,50,worldObj.provider.dimensionId,updatePacket);
    this.worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,this.worldObj.getBlockId(this.xCoord,this.yCoord,this.zCoord));
  }
}
Program: 161407
Project: 161407
Buggy source:
@Override public Icon getBlockTexture(IBlockAccess blockAccess,int x,int y,int z,int side){
  TileEntity te=blockAccess.getBlockTileEntity(x,y,z);
  if (te instanceof TileEntityBeefBase) {
    if (side == ((TileEntityBeefBase)te).getFacingDirection().ordinal()) {
      int metadata=blockAccess.getBlockMetadata(x,y,z);
      if (te instanceof TileEntityPoweredInventory) {
        if (((TileEntityPoweredInventory)te).isActive()) {
          return _activeIcons[metadata];
        }
      }
      return _icons[metadata];
    }
  }
  if (te instanceof TileEntityInventory) {
    int[] slots=((TileEntityInventory)te).getAccessibleSlotsFromSide(side);
    if (slots != null && slots[0] != TileEntityInventory.INVENTORY_UNEXPOSED) {
      return _inventorySideIcons[slots[0]];
    }
  }
  if (te instanceof TileEntityPoweredInventoryLiquid) {
    if (((TileEntityPoweredInventoryLiquid)te).getTank(ForgeDirection.getOrientation(side).getOpposite(),null) != null) {
      return _liquidSideIcons[0];
    }
  }
  return this.blockIcon;
}

Fixed version (ground truth):
@Override public Icon getBlockTexture(IBlockAccess blockAccess,int x,int y,int z,int side){
  TileEntity te=blockAccess.getBlockTileEntity(x,y,z);
  if (te instanceof TileEntityBeefBase) {
    if (side == ((TileEntityBeefBase)te).getFacingDirection().ordinal()) {
      int metadata=blockAccess.getBlockMetadata(x,y,z);
      if (te instanceof TileEntityPoweredInventory) {
        if (((TileEntityPoweredInventory)te).isActive()) {
          return _activeIcons[metadata];
        }
      }
      return _icons[metadata];
    }
  }
  if (te instanceof TileEntityInventory) {
    int[] slots=((TileEntityInventory)te).getAccessibleSlotsFromSide(side);
    if (slots != null && slots.length > 0 && slots[0] != TileEntityInventory.INVENTORY_UNEXPOSED) {
      return _inventorySideIcons[slots[0]];
    }
  }
  if (te instanceof TileEntityPoweredInventoryLiquid) {
    if (((TileEntityPoweredInventoryLiquid)te).getTank(ForgeDirection.getOrientation(side),null) != null) {
      return _liquidSideIcons[0];
    }
  }
  return this.blockIcon;
}
Program: 161408
Project: 161408
Buggy source:
@Override public int[] getAccessibleSlotsFromSide(int side){
  int rotatedSide=this.getRotatedSide(side);
  if (invExposures[rotatedSide] == INVENTORY_UNEXPOSED) {
    return null;
  }
  int[] slots=new int[1];
  slots[0]=invExposures[rotatedSide];
  return slots;
}

Fixed version (ground truth):
@Override public int[] getAccessibleSlotsFromSide(int side){
  int rotatedSide=this.getRotatedSide(side);
  if (invExposures[rotatedSide] == INVENTORY_UNEXPOSED) {
    return new int[0];
  }
  int[] slots=new int[1];
  slots[0]=invExposures[rotatedSide];
  return slots;
}
Program: 161409
Project: 161409
Buggy source:
/** 
 * Return the tank that this tank container desired to be used for the specified liquid type from the specified direction
 * @param direction the direction
 * @param type the liquid type, null is always an acceptable value
 * @return a tank or null for no such tank
 */
public ILiquidTank getTank(ForgeDirection direction,LiquidStack type){
  if (direction == ForgeDirection.UNKNOWN) {
    return null;
  }
 else {
    direction=direction.getOpposite();
    int tankIdx=tankExposure[this.getRotatedSide(direction.ordinal())];
    if (tankIdx == LIQUIDTANK_NONE) {
      return null;
    }
    ILiquidTank t=tanks[tankIdx];
    if (type == null || isLiquidValidForTank(tankIdx,type)) {
      return t;
    }
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the tank that this tank container desired to be used for the specified liquid type from the specified direction
 * @param direction the direction
 * @param type the liquid type, null is always an acceptable value
 * @return a tank or null for no such tank
 */
public ILiquidTank getTank(ForgeDirection direction,LiquidStack type){
  if (direction == ForgeDirection.UNKNOWN) {
    return null;
  }
 else {
    int tankIdx=tankExposure[this.getRotatedSide(direction.ordinal())];
    if (tankIdx == LIQUIDTANK_NONE) {
      return null;
    }
    ILiquidTank t=tanks[tankIdx];
    if (type == null || isLiquidValidForTank(tankIdx,type)) {
      return t;
    }
    return null;
  }
}
Program: 161410
Project: 161410
Buggy source:
/** 
 * @param direction tank side: UNKNOWN for default tank set
 * @return Array of {@link LiquidTank}s contained in this ITankContainer for this direction
 */
public ILiquidTank[] getTanks(ForgeDirection direction){
  if (direction == ForgeDirection.UNKNOWN) {
    return tanks;
  }
 else {
    direction=direction.getOpposite();
    int exposure=tankExposure[this.getRotatedSide(direction.ordinal())];
    if (exposure == LIQUIDTANK_NONE) {
      return null;
    }
    ILiquidTank[] exposedTanks=new ILiquidTank[1];
    exposedTanks[0]=tanks[exposure];
    return exposedTanks;
  }
}

Fixed version (ground truth):
/** 
 * @param direction tank side: UNKNOWN for default tank set
 * @return Array of {@link LiquidTank}s contained in this ITankContainer for this direction
 */
public ILiquidTank[] getTanks(ForgeDirection direction){
  if (direction == ForgeDirection.UNKNOWN) {
    return tanks;
  }
 else {
    int exposure=tankExposure[this.getRotatedSide(direction.ordinal())];
    if (exposure == LIQUIDTANK_NONE) {
      return new ILiquidTank[0];
    }
    ILiquidTank[] exposedTanks=new ILiquidTank[1];
    exposedTanks[0]=tanks[exposure];
    return exposedTanks;
  }
}
Program: 161411
Project: 161411
Buggy source:
public ItemBase(String name,int id){
  super(id);
  this.setUnlocalizedName(name);
  this.setCreativeTab(BigReactors.TAB);
}

Fixed version (ground truth):
public ItemBase(String name,int id){
  super(id);
  this.setUnlocalizedName(name);
  this.setCreativeTab(BigReactors.TAB);
  icons=new Icon[getNumberOfSubItems()];
}
Program: 161412
Project: 161412
Buggy source:
@Override @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int damage){
  if (this.icons.size() > damage && !this.isDamageable()) {
    return icons.get(damage);
  }
  return super.getIconFromDamage(damage);
}

Fixed version (ground truth):
@Override @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int damage){
  if (icons.length > damage && !this.isDamageable()) {
    return icons[damage];
  }
  return super.getIconFromDamage(damage);
}
Program: 161413
Project: 161413
Buggy source:
@Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister){
  List<ItemStack> list=new ArrayList<ItemStack>();
  this.getSubItems(this.itemID,this.getCreativeTab(),list);
  if (list.size() > 1) {
    for (    ItemStack itemStack : list) {
      this.icons.add(iconRegister.registerIcon(this.getUnlocalizedName(itemStack).replace("String_Node_Str",BigReactors.TEXTURE_NAME_PREFIX)));
    }
  }
 else {
    this.itemIcon=iconRegister.registerIcon(this.getUnlocalizedName().replace("String_Node_Str",BigReactors.TEXTURE_NAME_PREFIX));
  }
}

Fixed version (ground truth):
@Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister){
  String[] subItemNames=getSubItemNames();
  if (subItemNames != null) {
    for (int i=0; i < subItemNames.length; i++) {
      icons[i]=iconRegister.registerIcon(BigReactors.TEXTURE_NAME_PREFIX + subItemNames[i]);
    }
  }
 else {
    this.itemIcon=iconRegister.registerIcon(this.getUnlocalizedName().replace("String_Node_Str",BigReactors.TEXTURE_NAME_PREFIX));
  }
}
Program: 161414
Project: 161414
Buggy source:
public static boolean isFuel(int itemDamage){
  return itemDamage == 0;
}

Fixed version (ground truth):
public static boolean isFuel(int itemDamage){
  return itemDamage == 0 || itemDamage == 3;
}
Program: 161415
Project: 161415
Buggy source:
@Override public boolean canExtractItem(int slot,ItemStack itemstack,int side){
  if (side == 0 || side == 1) {
    return false;
  }
  return isStackValidForSlot(slot,itemstack);
}

Fixed version (ground truth):
@Override public boolean canExtractItem(int slot,ItemStack itemstack,int side){
  return isStackValidForSlot(slot,itemstack);
}
Program: 161416
Project: 161416
Buggy source:
/** 
 * @param fromSlot The inventory slot into which this object would normally go.
 * @param itemToDistribute An ItemStack to distribute to pipes
 * @return Null if the stack was distributed, the same ItemStack otherwise.
 */
protected ItemStack distributeItemToPipes(int fromSlot,ItemStack itemToDistribute){
  if (itemToDistribute == null) {
    return null;
  }
  ForgeDirection[] dirsToCheck={ForgeDirection.NORTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.WEST};
  for (  ForgeDirection dir : dirsToCheck) {
    int rotatedSide=this.getRotatedSide(dir.ordinal());
    if (invExposures[rotatedSide] != fromSlot) {
      continue;
    }
    TileEntity te=this.worldObj.getBlockTileEntity(xCoord + dir.offsetX,yCoord + dir.offsetY,zCoord + dir.offsetZ);
    if (te != null && te instanceof IPipeEntry) {
      IPipeEntry pipe=(IPipeEntry)te;
      if (pipe.acceptItems()) {
        pipe.entityEntering(itemToDistribute.copy(),dir);
        return null;
      }
    }
  }
  return itemToDistribute;
}

Fixed version (ground truth):
/** 
 * @param fromSlot The inventory slot into which this object would normally go.
 * @param itemToDistribute An ItemStack to distribute to pipes
 * @return Null if the stack was distributed, the same ItemStack otherwise.
 */
protected ItemStack distributeItemToPipes(int fromSlot,ItemStack itemToDistribute){
  if (itemToDistribute == null) {
    return null;
  }
  ForgeDirection[] dirsToCheck={ForgeDirection.NORTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.WEST,ForgeDirection.UP,ForgeDirection.DOWN};
  for (  ForgeDirection dir : dirsToCheck) {
    int rotatedSide=this.getRotatedSide(dir.ordinal());
    if (invExposures[rotatedSide] != fromSlot) {
      continue;
    }
    TileEntity te=this.worldObj.getBlockTileEntity(xCoord + dir.offsetX,yCoord + dir.offsetY,zCoord + dir.offsetZ);
    if (te != null && te instanceof IPipeEntry) {
      IPipeEntry pipe=(IPipeEntry)te;
      if (pipe.acceptItems()) {
        pipe.entityEntering(itemToDistribute.copy(),dir);
        return null;
      }
    }
  }
  return itemToDistribute;
}
Program: 161417
Project: 161417
Buggy source:
@Override public boolean canInsertItem(int slot,ItemStack itemstack,int side){
  if (side == 0 || side == 1) {
    return false;
  }
  return isStackValidForSlot(slot,itemstack);
}

Fixed version (ground truth):
@Override public boolean canInsertItem(int slot,ItemStack itemstack,int side){
  return isStackValidForSlot(slot,itemstack);
}
Program: 161418
Project: 161418
Buggy source:
@Override public void onItemSelected(AdapterView<?> parent,View view,int position,long id){
  list.smoothScrollToPositionFromTop(position,0);
}

Fixed version (ground truth):
@Override public void onItemSelected(AdapterView<?> parent,View view,int position,long id){
  list.smoothScrollToPositionFromTop(list.getSelectedItemPosition(),0);
}
Program: 161419
Project: 161419
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mAppHelper=new AppHelper(this);
  mAppHelper.loadApplications(true);
  mAppHelper.bindApplications();
  mAppHelper.registerIntentReceivers();
  final ListView list=(ListView)findViewById(android.R.id.list);
  list.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      list.smoothScrollToPositionFromTop(position,0);
    }
    @Override public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
  intentFilter.addDataScheme("String_Node_Str");
  registerReceiver(mPackageBroadcastReciever,intentFilter);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mAppHelper=new AppHelper(this);
  mAppHelper.loadApplications(true);
  mAppHelper.bindApplications();
  mAppHelper.registerIntentReceivers();
  mGestureDetector=createGestureDetector(this);
  final ListView list=(ListView)findViewById(android.R.id.list);
  list.setSelection(0);
  list.requestFocus();
  list.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      list.smoothScrollToPositionFromTop(list.getSelectedItemPosition(),0);
    }
    @Override public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
  intentFilter.addDataScheme("String_Node_Str");
  registerReceiver(mPackageBroadcastReciever,intentFilter);
}
Program: 161420
Project: 161420
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case BluetoothChatService.MSG_CONNECTED:
    connected=true;
  mStatusView.setText(formatStatusMessage(R.string.btstatus_connected_to_fmt,msg.obj));
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_CONNECTING:
mStatusView.setText(formatStatusMessage(R.string.btstatus_connecting_to_fmt,msg.obj));
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_NOT_CONNECTED:
connected=false;
mStatusView.setText(R.string.btstatus_not_connected);
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_BYTES_WRITTEN:
String written=new String((byte[])msg.obj);
mConversationArrayAdapter.add("String_Node_Str" + written);
Log.i(TAG,"String_Node_Str" + written + "String_Node_Str");
break;
case BluetoothChatService.MSG_LINE_READ:
if (paused) break;
String readMessage=(String)msg.obj;
if (D) Log.d(TAG,readMessage);
mConversationArrayAdapter.add(readMessage);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case BluetoothChatService.MSG_CONNECTED:
    connected=true;
  mStatusView.setText(formatStatusMessage(R.string.btstatus_connected_to_fmt,msg.obj));
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_CONNECTING:
connected=false;
mStatusView.setText(formatStatusMessage(R.string.btstatus_connecting_to_fmt,msg.obj));
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_NOT_CONNECTED:
connected=false;
mStatusView.setText(R.string.btstatus_not_connected);
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_CONNECTION_FAILED:
connected=false;
mStatusView.setText(R.string.btstatus_not_connected);
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_CONNECTION_LOST:
connected=false;
mStatusView.setText(R.string.btstatus_not_connected);
onBluetoothStateChanged();
break;
case BluetoothChatService.MSG_BYTES_WRITTEN:
String written=new String((byte[])msg.obj);
mConversationArrayAdapter.add("String_Node_Str" + written);
Log.i(TAG,"String_Node_Str" + written + "String_Node_Str");
break;
case BluetoothChatService.MSG_LINE_READ:
if (paused) break;
String readMessage=(String)msg.obj;
if (D) Log.d(TAG,readMessage);
mConversationArrayAdapter.add(readMessage);
break;
}
}
Program: 161421
Project: 161421
Buggy source:
public void run(){
  Log.i(TAG,"String_Node_Str");
  BufferedReader reader=new BufferedReader(new InputStreamReader(mmInStream));
  while (!stop) {
    try {
      String line=reader.readLine();
      if (line != null) {
        mHandler.obtainMessage(BluetoothChat.MESSAGE_READ,line.length(),-1,line.toCharArray()).sendToTarget();
      }
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str",e);
      connectionLost();
      break;
    }
  }
}

Fixed version (ground truth):
public void run(){
  Log.i(TAG,"String_Node_Str");
  BufferedReader reader=new BufferedReader(new InputStreamReader(mmInStream));
  while (!stop) {
    try {
      String line=reader.readLine();
      if (line != null) {
        mHandler.obtainMessage(BluetoothChat.MESSAGE_READ,line.length(),-1,line.getBytes()).sendToTarget();
      }
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str",e);
      connectionLost();
      break;
    }
  }
}
Program: 161422
Project: 161422
Buggy source:
private void onBluetoothStateChanged(){
  if (mChatService != null) {
    if (connectMenuItem != null) {
switch (mChatService.getState()) {
case BluetoothChatService.STATE_CONNECTED:
        connectMenuItem.setVisible(false);
      disconnectMenuItem.setVisible(true);
    resumeMenuItem.setVisible(false);
  pauseMenuItem.setVisible(true);
break;
case BluetoothChatService.STATE_NONE:
case BluetoothChatService.STATE_CONNECTING:
default :
connectMenuItem.setVisible(true);
disconnectMenuItem.setVisible(false);
resumeMenuItem.setVisible(false);
pauseMenuItem.setVisible(false);
break;
}
}
}
}

Fixed version (ground truth):
private void onBluetoothStateChanged(){
  if (!menuReady)   return;
  if (mChatService != null) {
    if (connectMenuItem != null) {
switch (mChatService.getState()) {
case BluetoothChatService.STATE_CONNECTED:
        connectMenuItem.setVisible(false);
      disconnectMenuItem.setVisible(true);
    resumeMenuItem.setVisible(false);
  pauseMenuItem.setVisible(true);
break;
case BluetoothChatService.STATE_NONE:
case BluetoothChatService.STATE_CONNECTING:
default :
connectMenuItem.setVisible(true);
disconnectMenuItem.setVisible(false);
resumeMenuItem.setVisible(false);
pauseMenuItem.setVisible(false);
break;
}
}
}
}
Program: 161423
Project: 161423
Buggy source:
private void onPauseChanged(){
  if (mChatService != null && mChatService.getState() == BluetoothChatService.STATE_CONNECTED) {
    if (pauseMenuItem != null) {
      if (paused) {
        pauseMenuItem.setVisible(false);
        resumeMenuItem.setVisible(true);
      }
 else {
        pauseMenuItem.setVisible(true);
        resumeMenuItem.setVisible(false);
      }
    }
  }
 else {
    pauseMenuItem.setVisible(false);
    resumeMenuItem.setVisible(false);
  }
}

Fixed version (ground truth):
private void onPauseChanged(){
  if (mChatService != null && mChatService.getState() == BluetoothChatService.STATE_CONNECTED) {
    if (paused) {
      pauseMenuItem.setVisible(false);
      resumeMenuItem.setVisible(true);
    }
 else {
      pauseMenuItem.setVisible(true);
      resumeMenuItem.setVisible(false);
    }
  }
 else {
    pauseMenuItem.setVisible(false);
    resumeMenuItem.setVisible(false);
  }
}
Program: 161424
Project: 161424
Buggy source:
@Override public boolean onCreateOptionsMenu(Menu menu){
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.option_menu,menu);
  connectMenuItem=menu.findItem(R.id.scan);
  disconnectMenuItem=menu.findItem(R.id.menu_disconnect);
  onBluetoothStateChanged();
  pauseMenuItem=menu.findItem(R.id.menu_pause_on);
  resumeMenuItem=menu.findItem(R.id.menu_pause_off);
  onPauseChanged();
  return true;
}

Fixed version (ground truth):
@Override public boolean onCreateOptionsMenu(Menu menu){
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.option_menu,menu);
  connectMenuItem=menu.findItem(R.id.scan);
  disconnectMenuItem=menu.findItem(R.id.menu_disconnect);
  onBluetoothStateChanged();
  pauseMenuItem=menu.findItem(R.id.menu_pause_on);
  resumeMenuItem=menu.findItem(R.id.menu_pause_off);
  onPauseChanged();
  menuReady=true;
  return true;
}
Program: 161426
Project: 161426
Buggy source:
/** 
 * Start device discover with the BluetoothAdapter
 */
private void doDiscovery(){
  if (D)   Log.d(TAG,"String_Node_Str");
  setProgressBarIndeterminateVisibility(true);
  setTitle(R.string.scanning);
  findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
  if (mBtAdapter.isDiscovering()) {
    mBtAdapter.cancelDiscovery();
  }
  mBtAdapter.startDiscovery();
}

Fixed version (ground truth):
/** 
 * Start device discover with the BluetoothAdapter
 */
private void doDiscovery(){
  if (D)   Log.d(TAG,"String_Node_Str");
  mNewDevicesArrayAdapter.clear();
  mNewDevicesSet.clear();
  setProgressBarIndeterminateVisibility(true);
  setTitle(R.string.scanning);
  findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
  if (mBtAdapter.isDiscovering()) {
    mBtAdapter.cancelDiscovery();
  }
  mBtAdapter.startDiscovery();
}
Program: 161427
Project: 161427
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (BluetoothDevice.ACTION_FOUND.equals(action)) {
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
      mNewDevicesArrayAdapter.add(device.getName() + "String_Node_Str" + device.getAddress());
    }
  }
 else   if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
    setProgressBarIndeterminateVisibility(false);
    setTitle(R.string.select_device);
    if (mNewDevicesArrayAdapter.getCount() == 0) {
      String noDevices=getResources().getText(R.string.none_found).toString();
      mNewDevicesArrayAdapter.add(noDevices);
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (BluetoothDevice.ACTION_FOUND.equals(action)) {
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
      String address=device.getAddress();
      if (!mNewDevicesSet.contains(address)) {
        mNewDevicesSet.add(address);
        mNewDevicesArrayAdapter.add(device.getName() + "String_Node_Str" + device.getAddress());
      }
    }
  }
 else   if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
    setProgressBarIndeterminateVisibility(false);
    setTitle(R.string.select_device);
    if (mNewDevicesSet.isEmpty()) {
      String noDevices=getResources().getText(R.string.none_found).toString();
      mNewDevicesArrayAdapter.add(noDevices);
    }
    scanButton.setVisibility(View.VISIBLE);
  }
}
Program: 161429
Project: 161429
Buggy source:
@Override public boolean isApplicable(@NotNull PsiElement[] elements){
  return true;
}

Fixed version (ground truth):
@Override public boolean isApplicable(@NotNull PsiElement[] elements){
  return elements.length > 0 && elements[0].getContainingFile() instanceof MathematicaPsiFile;
}
Program: 161430
Project: 161430
Buggy source:
@NotNull @Override public PsiElement[] getElementsToSurround(PsiFile file,int startOffset,int endOffset){
  return findElementsInRange(file,startOffset,endOffset);
}

Fixed version (ground truth):
@NotNull @Override public PsiElement[] getElementsToSurround(PsiFile file,int startOffset,int endOffset){
  if (file instanceof MathematicaPsiFile) {
    return findElementsInRange(file,startOffset,endOffset);
  }
  return PsiElement.EMPTY_ARRAY;
}
Program: 161432
Project: 161432
Buggy source:
@Override public boolean isReferenceTo(PsiElement element){
  return getManager().areElementsEquivalent(resolve(),element);
}

Fixed version (ground truth):
@Override public boolean isReferenceTo(PsiElement element){
  return (element instanceof Symbol || element instanceof LightSymbol) && getManager().areElementsEquivalent(resolve(),element);
}
Program: 161434
Project: 161434
Buggy source:
@Override public String getReportActionText(){
  return "String_Node_Str";
}

Fixed version (ground truth):
@NotNull @Override public String getReportActionText(){
  return "String_Node_Str";
}
Program: 161436
Project: 161436
Buggy source:
@Override public String getName(){
  return "String_Node_Str";
}

Fixed version (ground truth):
@NotNull @Override public String getName(){
  return "String_Node_Str";
}
Program: 161437
Project: 161437
Buggy source:
@Override public MathematicaModuleBuilder createModuleBuilder(){
  return new MathematicaModuleBuilder.Empty();
}

Fixed version (ground truth):
@NotNull @Override public MathematicaModuleBuilder createModuleBuilder(){
  return new MathematicaModuleBuilder.Empty();
}
Program: 161438
Project: 161438
Buggy source:
@Override public String getDescription(){
  return "String_Node_Str";
}

Fixed version (ground truth):
@NotNull @Override public String getDescription(){
  return "String_Node_Str";
}
Program: 161439
Project: 161439
Buggy source:
@Nullable @Override public String suggestHomePath(){
  String path="String_Node_Str";
  if (new File(path).exists()) {
    return path;
  }
  return null;
}

Fixed version (ground truth):
@Nullable @Override public String suggestHomePath(){
  final String property=System.getProperty("String_Node_Str");
  String path="String_Node_Str";
  if (property.matches("String_Node_Str")) {
    path="String_Node_Str";
  }
  if (new File(path).exists()) {
    return path;
  }
  return null;
}
Program: 161440
Project: 161440
Buggy source:
@Nullable @Override public String getVersionString(Sdk sdk){
  return getMathematicaVersionString(sdk.getHomePath());
}

Fixed version (ground truth):
@Nullable @Override public String getVersionString(@NotNull Sdk sdk){
  return getMathematicaVersionString(sdk.getHomePath());
}
Program: 161441
Project: 161441
Buggy source:
/** 
 * Extracts the precedence of an infix operator connected to the first token in the token stream of builder.
 * @param builder Builder from which the first token is extracted to find the required precedence
 * @return The precedence of the specified token or 0 whether the precedence is not available.
 */
public static int getPrecedence(PsiBuilder builder){
  if (ourInstance == null) {
    ourInstance=new ParseletProvider();
  }
  IElementType token=builder.getTokenType();
  if (token == null) {
    return 0;
  }
  InfixParselet parselet=INFIX_PARSELETS.get(token);
  if (parselet != null) {
    return parselet.getMyPrecedence();
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * Extracts the precedence of an infix operator connected to the first token in the token stream of builder.
 * @param builder Builder from which the first token is extracted to find the required precedence
 * @return The precedence of the specified token or 0 whether the precedence is not available.
 */
public static int getPrecedence(PsiBuilder builder){
  IElementType token=builder.getTokenType();
  if (token == null) {
    return 0;
  }
  InfixParselet parselet=INFIX_PARSELETS.get(token);
  if (parselet != null) {
    return parselet.getMyPrecedence();
  }
  return 0;
}
Program: 161442
Project: 161442
Buggy source:
/** 
 * Provides the infix-parselet which is connected to the specified token.
 * @param token The token for which the parselet is wanted
 * @return The {@link InfixParselet} if available for this token and {@code null} otherwise.
 */
public static InfixParselet getInfixParselet(IElementType token){
  if (ourInstance == null) {
    ourInstance=new ParseletProvider();
  }
  return INFIX_PARSELETS.get(token);
}

Fixed version (ground truth):
/** 
 * Provides the infix-parselet which is connected to the specified token.
 * @param token The token for which the parselet is wanted
 * @return The {@link InfixParselet} if available for this token and {@code null} otherwise.
 */
public static InfixParselet getInfixParselet(IElementType token){
  return INFIX_PARSELETS.get(token);
}
Program: 161443
Project: 161443
Buggy source:
/** 
 * Provides the prefix-parselet which is connected to the specified token.
 * @param token The token for which the parselet is wanted
 * @return The {@link PrefixParselet} if available for this token and {@code null} otherwise.
 */
public static PrefixParselet getPrefixParselet(IElementType token){
  if (ourInstance == null) {
    ourInstance=new ParseletProvider();
  }
  return PREFIX_PARSELETS.get(token);
}

Fixed version (ground truth):
/** 
 * Provides the prefix-parselet which is connected to the specified token.
 * @param token The token for which the parselet is wanted
 * @return The {@link PrefixParselet} if available for this token and {@code null} otherwise.
 */
public static PrefixParselet getPrefixParselet(IElementType token){
  return PREFIX_PARSELETS.get(token);
}
Program: 161444
Project: 161444
Buggy source:
private ParseletProvider(){
  registerAll();
}

Fixed version (ground truth):
private ParseletProvider(){
}
Program: 161445
Project: 161445
Buggy source:
/** 
 * Implementation note: This roundabout way of implementation is required to ensure that a   {@link CloudFactory} bean if created in some other configuration is available, we should usethat.
 */
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  if (cloudFactory == null) {
    try {
      cloudFactory=beanFactory.getBean(CloudFactory.class);
    }
 catch (    NoSuchBeanDefinitionException ex) {
      cloudFactory=new CloudFactory();
      ((SingletonBeanRegistry)beanFactory).registerSingleton(CLOUD_FACTORY_BEAN_NAME,cloudFactory);
    }
  }
  this.cloud=cloudFactory.getCloud();
  this.connectionFactory=new ServiceConnectionFactory();
}

Fixed version (ground truth):
/** 
 * Implementation note: This roundabout way of implementation is required to ensure that a   {@link CloudFactory} bean if created in some other configuration is available, we should usethat.
 */
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  if (cloudFactory == null) {
    try {
      cloudFactory=beanFactory.getBean(CloudFactory.class);
    }
 catch (    NoSuchBeanDefinitionException ex) {
      cloudFactory=new CloudFactory();
      ((SingletonBeanRegistry)beanFactory).registerSingleton(CLOUD_FACTORY_BEAN_NAME,cloudFactory);
    }
  }
  this.cloud=cloudFactory.getCloud();
  this.connectionFactory=new CloudServiceConnectionFactory(cloud);
}