nus-yam/ex-repair huggingface dataset:
Program: 1553
Project: 1553
Buggy source:
/** 
 * Slower retrieval of components from this entity. Minimize usage of this, but is fine to use e.g. when creating new entities and setting data in components.
 * @param < T > the expected return component type.
 * @param type the expected return component type.
 * @return component that matches, or null if none is found.
 */
public <T extends Component>T getComponent(Class<T> type){
  return type.cast(getComponent(ComponentTypeManager.getTypeFor(type)));
}

Fixed version (ground truth):
/** 
 * Slower retrieval of components from this entity. Minimize usage of this, but is fine to use e.g. when creating new entities and setting data in components.
 * @param < T > the expected return component type.
 * @param type the expected return component type.
 * @return component that matches, or null if none is found.
 */
public <T extends Component>T getComponent(Class<T> type){
  return type.cast(getComponent(ComponentTypeManager.getTypeFor(type,world)));
}
Program: 1554
Project: 1554
Buggy source:
protected void addComponent(Entity e,Component component){
  ComponentType type=ComponentTypeManager.getTypeFor(component.getClass());
  if (type.getId() >= componentsByType.getCapacity()) {
    componentsByType.set(type.getId(),null);
  }
  Bag<Component> components=componentsByType.get(type.getId());
  if (components == null) {
    components=new Bag<Component>();
    componentsByType.set(type.getId(),components);
  }
  components.set(e.getId(),component);
  e.addTypeBit(type.getBit());
}

Fixed version (ground truth):
protected void addComponent(Entity e,Component component){
  ComponentType type=ComponentTypeManager.getTypeFor(component.getClass(),world);
  if (type.getId() >= componentsByType.getCapacity()) {
    componentsByType.set(type.getId(),null);
  }
  Bag<Component> components=componentsByType.get(type.getId());
  if (components == null) {
    components=new Bag<Component>();
    componentsByType.set(type.getId(),components);
  }
  components.set(e.getId(),component);
  e.addTypeBit(type.getBit());
}
Program: 1555
Project: 1555
Buggy source:
public EntitySystem(Class<? extends Component>... types){
  actives=new Bag<Entity>();
  for (  Class<? extends Component> type : types) {
    ComponentType ct=ComponentTypeManager.getTypeFor(type);
    typeFlags|=ct.getBit();
  }
}

Fixed version (ground truth):
public EntitySystem(Class<? extends Component>... types){
  actives=new Bag<Entity>();
  this.types=types;
}
Program: 1556
Project: 1556
Buggy source:
/** 
 * After adding all systems to the world, you must initialize them all.
 */
public void initializeAll(){
  for (int i=0; i < bagged.size(); i++) {
    bagged.get(i).initialize();
  }
}

Fixed version (ground truth):
/** 
 * After adding all systems to the world, you must initialize them all.
 */
public void initializeAll(){
  for (int i=0; i < bagged.size(); i++) {
    bagged.get(i).applyTypeFlags();
    bagged.get(i).initialize();
  }
}
Program: 1557
Project: 1557
Buggy source:
/** 
 * Set element at specified index in the bag.
 * @param index position of element
 * @param o the element
 */
public void set(int index,E o){
  if (index >= data.length) {
    grow(index * 2);
  }
  data[index]=o;
  size=index + 1;
}

Fixed version (ground truth):
/** 
 * Set element at specified index in the bag.
 * @param index position of element
 * @param o the element
 */
public void set(int index,E o){
  if (index >= data.length) {
    grow(index * 2);
    size=index + 1;
  }
 else   if (index >= size) {
    size=index + 1;
  }
  data[index]=o;
}
Program: 1558
Project: 1558
Buggy source:
protected Entity create(){
  Entity e=removedAndAvailable.removeLast();
  if (e == null) {
    e=new Entity(world,nextAvailableId++);
    activeEntities.add(e);
  }
 else {
    activeEntities.set(e.getId(),e);
    e.reset();
  }
  count++;
  totalCreated++;
  return e;
}

Fixed version (ground truth):
protected Entity create(){
  Entity e=removedAndAvailable.removeLast();
  if (e == null) {
    e=new Entity(world,nextAvailableId++);
  }
 else {
    e.reset();
  }
  activeEntities.set(e.getId(),e);
  count++;
  totalCreated++;
  return e;
}
Program: 1559
Project: 1559
Buggy source:
protected void remove(Entity e){
  activeEntities.set(e.getId(),null);
  removedAndAvailable.add(e);
  e.setTypeBits(0);
  refresh(e);
  count--;
  totalRemoved++;
}

Fixed version (ground truth):
protected void remove(Entity e){
  activeEntities.set(e.getId(),null);
  e.setTypeBits(0);
  refresh(e);
  count--;
  totalRemoved++;
  removedAndAvailable.add(e);
}
Program: 1560
Project: 1560
Buggy source:
private void remove(Entity e){
  if ((systemBit & e.getSystemBits()) == systemBit) {
    actives.remove(e);
    e.removeSystemBit(systemBit);
    removed(e);
  }
}

Fixed version (ground truth):
private void remove(Entity e){
  actives.remove(e);
  e.removeSystemBit(systemBit);
  removed(e);
}
Program: 1561
Project: 1561
Buggy source:
public void deleteEntity(Entity e){
  entityManager.remove(e);
  groupManager.remove(e);
}

Fixed version (ground truth):
public void deleteEntity(Entity e){
  groupManager.remove(e);
  entityManager.remove(e);
}
Program: 1562
Project: 1562
Buggy source:
public void remove(Entity e){
  if (e.getId() < groupByEntity.size()) {
    String group=groupByEntity.get(e.getId());
    if (group != null) {
      groupByEntity.set(e.getId(),null);
      Bag<Entity> entities=entitiesByGroup.get(group);
      if (entities != null) {
        entities.remove(e);
      }
    }
  }
}

Fixed version (ground truth):
public void remove(Entity e){
  if (e.getId() < groupByEntity.getCapacity()) {
    String group=groupByEntity.get(e.getId());
    if (group != null) {
      groupByEntity.set(e.getId(),null);
      Bag<Entity> entities=entitiesByGroup.get(group);
      if (entities != null) {
        entities.remove(e);
      }
    }
  }
}
Program: 1563
Project: 1563
Buggy source:
/** 
 * Converts a list of arguments into points.
 * @param original The original string necessary to convert inside of.
 * @param arguments The list of arguments, multiple arguments are seperated by commas for a single point.
 * @param points The point used to alter the argument.
 * @return <code>String</code> - The parsed string after converting arguments to variables (points)
 */
public static String argument(String original,Object[] arguments,Object[] points){
  for (int i=0; i < arguments.length; i++) {
    if (String.valueOf(arguments[i]).contains("String_Node_Str")) {
      for (      String arg : String.valueOf(arguments[i]).split("String_Node_Str")) {
        original=original.replace(arg,String.valueOf(points[i]));
      }
    }
 else {
      original=original.replace(String.valueOf(arguments[i]),String.valueOf(points[i]));
    }
  }
  return original;
}

Fixed version (ground truth):
/** 
 * Converts a list of arguments into points.
 * @param original The original string necessary to convert inside of.
 * @param arguments The list of arguments, multiple arguments are seperated by commas for a single point.
 * @param points The point used to alter the argument.
 * @return <code>String</code> - The parsed string after converting arguments to variables (points)
 */
public static String argument(String original,Object[] arguments,Object[] points){
  if (arguments.length < 1)   return original;
  for (int i=0; i < arguments.length; i++) {
    if (String.valueOf(arguments[i]).contains("String_Node_Str")) {
      for (      String arg : String.valueOf(arguments[i]).split("String_Node_Str")) {
        original=original.replace(arg,String.valueOf(points[i]));
      }
    }
 else {
      original=original.replace(String.valueOf(arguments[i]),String.valueOf(points[i]));
    }
  }
  return original;
}
Program: 1564
Project: 1564
Buggy source:
public void showBalance(CommandSender to){
  if (to != null) {
    String tag=iConomy.Template.raw(Template.Node.TAG_MONEY);
    Template template=iConomy.Template;
    template.set(Template.Node.PLAYER_BALANCE);
    template.add("String_Node_Str",name);
    template.add("String_Node_Str",toString());
    Messaging.send(to,tag + template.parse());
  }
  Player player=iConomy.Server.getPlayer(name);
  if (iConomy.Server.getPlayer(name) == null)   return;
  String tag=iConomy.Template.color(Template.Node.TAG_MONEY);
  Template template=iConomy.Template;
  template.set(Template.Node.PERSONAL_BALANCE);
  template.add("String_Node_Str",toString());
  Messaging.send(player,tag + template.parse());
}

Fixed version (ground truth):
public void showBalance(CommandSender to){
  if (to != null) {
    String tag=iConomy.Template.raw(Template.Node.TAG_MONEY);
    Template template=iConomy.Template;
    template.set(Template.Node.PLAYER_BALANCE);
    template.add("String_Node_Str",name);
    template.add("String_Node_Str",toString());
    Messaging.send(to,tag + template.parse());
    return;
  }
  Player player=iConomy.Server.getPlayer(name);
  String tag=iConomy.Template.color(Template.Node.TAG_MONEY);
  if (iConomy.Server.getPlayer(name) == null)   return;
  Template template=iConomy.Template;
  template.set(Template.Node.PERSONAL_BALANCE);
  template.add("String_Node_Str",toString());
  Messaging.send(player,tag + template.parse());
}
Program: 1565
Project: 1565
Buggy source:
static List<Account> topAccounts(int amount){
  Accounts Accounts=new Accounts();
  List<Account> accounts=new ArrayList<Account>();
  List<Account> finals=new ArrayList<Account>();
  List<String> total=new ArrayList<String>();
  if (useMiniDB() || useInventoryDB() || useOrbDB()) {
    if (useInventoryDB())     total.addAll(inventory.getAllPlayers());
    if (useOrbDB())     for (    Player p : iConomy.Server.getOnlinePlayers())     total.add(p.getName());
    total.addAll(database.getIndices().keySet());
  }
 else {
    try {
      QueryRunner run=new QueryRunner();
      Connection c=iConomy.Database.getConnection();
      try {
        String t=Constants.Nodes.DatabaseTable.toString();
        total=run.query(c,"String_Node_Str" + t,returnList);
      }
 catch (      SQLException ex) {
        System.out.println("String_Node_Str" + ex);
      }
 finally {
        DbUtils.close(c);
      }
    }
 catch (    SQLException ex) {
      System.out.println("String_Node_Str" + ex);
    }
  }
  for (Iterator<String> it=total.iterator(); it.hasNext(); ) {
    String player=it.next();
    accounts.add(Accounts.get(player));
  }
  Collections.sort(accounts,new MoneyComparator());
  if (amount > accounts.size())   amount=accounts.size();
  for (int i=0; i < amount; i++) {
    if (accounts.get(i).getStatus() == 1) {
      i--;
      continue;
    }
    finals.add(accounts.get(i));
  }
  return finals;
}

Fixed version (ground truth):
static List<Account> topAccounts(int amount){
  Accounts Accounts=new Accounts();
  List<Account> accounts=new ArrayList<Account>();
  List<Account> finals=new ArrayList<Account>();
  List<String> total=new ArrayList<String>();
  if (useMiniDB() || useInventoryDB() || useOrbDB()) {
    if (useInventoryDB())     total.addAll(inventory.getAllPlayers());
    if (useOrbDB())     for (    Player p : iConomy.Server.getOnlinePlayers())     total.add(p.getName());
    total.addAll(database.getIndices().keySet());
  }
 else {
    try {
      QueryRunner run=new QueryRunner();
      Connection c=iConomy.Database.getConnection();
      try {
        String t=Constants.Nodes.DatabaseTable.toString();
        total=run.query(c,"String_Node_Str" + t + "String_Node_Str"+ amount,returnList);
      }
 catch (      SQLException ex) {
        System.out.println("String_Node_Str" + ex);
      }
 finally {
        DbUtils.close(c);
      }
    }
 catch (    SQLException ex) {
      System.out.println("String_Node_Str" + ex);
    }
  }
  for (Iterator<String> it=total.iterator(); it.hasNext(); ) {
    String player=it.next();
    if (useMiniDB() || useInventoryDB() || useOrbDB()) {
      accounts.add(Accounts.get(player));
    }
 else {
      finals.add(new Account(player));
    }
  }
  if (useMiniDB() || useInventoryDB() || useOrbDB()) {
    Collections.sort(accounts,new MoneyComparator());
    if (amount > accounts.size())     amount=accounts.size();
    for (int i=0; i < amount; i++) {
      if (accounts.get(i).getStatus() == 1) {
        i--;
        continue;
      }
      finals.add(accounts.get(i));
    }
  }
  return finals;
}
Program: 1567
Project: 1567
Buggy source:
@Override public boolean perform(CommandSender sender,LinkedHashMap<String,Argument> arguments) throws InvalidUsage {
  String name=arguments.get("String_Node_Str").getStringValue();
  String tag=template.color(Template.Node.TAG_MONEY);
  Double amount;
  if (name.equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  if (arguments.get("String_Node_Str").getStringValue().equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  try {
    amount=arguments.get("String_Node_Str").getDoubleValue();
  }
 catch (  NumberFormatException e) {
    throw new InvalidUsage("String_Node_Str");
  }
  if (Double.isInfinite(amount) || Double.isNaN(amount))   throw new InvalidUsage("String_Node_Str");
  if (!Accounts.exists(name)) {
    template.set(Template.Node.ERROR_ACCOUNT);
    template.add("String_Node_Str",name);
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  Account account=new Account(name);
  account.getHoldings().add(amount);
  template.set(Template.Node.PLAYER_CREDIT);
  template.add("String_Node_Str",name);
  template.add("String_Node_Str",account.getHoldings().toString());
  Messaging.send(sender,tag + template.parse());
  return false;
}

Fixed version (ground truth):
@Override public boolean perform(CommandSender sender,LinkedHashMap<String,Argument> arguments) throws InvalidUsage {
  String name=arguments.get("String_Node_Str").getStringValue();
  String tag=template.color(Template.Node.TAG_MONEY);
  Double amount;
  if (name.equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  if (arguments.get("String_Node_Str").getStringValue().equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  try {
    amount=arguments.get("String_Node_Str").getDoubleValue();
  }
 catch (  NumberFormatException e) {
    throw new InvalidUsage("String_Node_Str");
  }
  if (Double.isInfinite(amount) || Double.isNaN(amount))   throw new InvalidUsage("String_Node_Str");
  if (!Accounts.exists(name)) {
    template.set(Template.Node.ERROR_ACCOUNT);
    template.add("String_Node_Str",name);
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  Account account=new Account(name);
  account.getHoldings().add(amount);
  template.set(Template.Node.PLAYER_CREDIT);
  template.add("String_Node_Str",name);
  template.add("String_Node_Str",iConomy.format(amount));
  Messaging.send(sender,tag + template.parse());
  return false;
}
Program: 1568
Project: 1568
Buggy source:
@Override public boolean perform(CommandSender sender,LinkedHashMap<String,Argument> arguments) throws InvalidUsage {
  String name=arguments.get("String_Node_Str").getStringValue();
  String tag=template.color(Template.Node.TAG_MONEY);
  Double amount;
  if (name.equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  if (arguments.get("String_Node_Str").getStringValue().equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  try {
    amount=arguments.get("String_Node_Str").getDoubleValue();
  }
 catch (  NumberFormatException e) {
    throw new InvalidUsage("String_Node_Str");
  }
  if (Double.isInfinite(amount) || Double.isNaN(amount))   throw new InvalidUsage("String_Node_Str");
  if (!Accounts.exists(name)) {
    template.set(Template.Node.ERROR_ACCOUNT);
    template.add("String_Node_Str",name);
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  Account account=new Account(name);
  account.getHoldings().subtract(amount);
  template.set(Template.Node.PLAYER_DEBIT);
  template.add("String_Node_Str",name);
  template.add("String_Node_Str",account.getHoldings().toString());
  Messaging.send(sender,tag + template.parse());
  return false;
}

Fixed version (ground truth):
@Override public boolean perform(CommandSender sender,LinkedHashMap<String,Argument> arguments) throws InvalidUsage {
  String name=arguments.get("String_Node_Str").getStringValue();
  String tag=template.color(Template.Node.TAG_MONEY);
  Double amount;
  if (name.equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  if (arguments.get("String_Node_Str").getStringValue().equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  try {
    amount=arguments.get("String_Node_Str").getDoubleValue();
  }
 catch (  NumberFormatException e) {
    throw new InvalidUsage("String_Node_Str");
  }
  if (Double.isInfinite(amount) || Double.isNaN(amount))   throw new InvalidUsage("String_Node_Str");
  if (!Accounts.exists(name)) {
    template.set(Template.Node.ERROR_ACCOUNT);
    template.add("String_Node_Str",name);
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  Account account=new Account(name);
  account.getHoldings().subtract(amount);
  template.set(Template.Node.PLAYER_DEBIT);
  template.add("String_Node_Str",name);
  template.add("String_Node_Str",iConomy.format(amount));
  Messaging.send(sender,tag + template.parse());
  return false;
}
Program: 1569
Project: 1569
Buggy source:
public void showBalance(CommandSender to){
  if (to != null) {
    String tag=iConomy.Template.raw(Template.Node.TAG_MONEY);
    Template template=iConomy.Template;
    template.set(Template.Node.PLAYER_BALANCE);
    template.add("String_Node_Str",name);
    template.add("String_Node_Str",getBalance());
    Messaging.send(to,tag + template.parse());
  }
  Player player=iConomy.Server.getPlayer(name);
  if (iConomy.Server.getPlayer(name) == null)   return;
  String tag=iConomy.Template.color(Template.Node.TAG_MONEY);
  Template template=iConomy.Template;
  template.set(Template.Node.PERSONAL_BALANCE);
  template.add("String_Node_Str",getBalance());
  Messaging.send(player,tag + template.parse());
}

Fixed version (ground truth):
public void showBalance(CommandSender to){
  if (to != null) {
    String tag=iConomy.Template.raw(Template.Node.TAG_MONEY);
    Template template=iConomy.Template;
    template.set(Template.Node.PLAYER_BALANCE);
    template.add("String_Node_Str",name);
    template.add("String_Node_Str",toString());
    Messaging.send(to,tag + template.parse());
  }
  Player player=iConomy.Server.getPlayer(name);
  if (iConomy.Server.getPlayer(name) == null)   return;
  String tag=iConomy.Template.color(Template.Node.TAG_MONEY);
  Template template=iConomy.Template;
  template.set(Template.Node.PERSONAL_BALANCE);
  template.add("String_Node_Str",toString());
  Messaging.send(player,tag + template.parse());
}
Program: 1570
Project: 1570
Buggy source:
static void setBalance(String name,double balance){
  if (!hasAccount(name)) {
    createAccount(name,balance,0);
    return;
  }
  if (useMiniDB() || useInventoryDB() || useOrbDB()) {
    if (useInventoryDB())     if (inventory.dataExists(name)) {
      inventory.setBalance(name,balance);
      return;
    }
    if (useOrbDB()) {
      Player gainer=iConomy.Server.getPlayer(name);
      if (gainer != null) {
        for (int i=0; i < balance; i++)         gainer.setExperience(i);
        return;
      }
    }
    if (database.hasIndex(name)) {
      database.setArgument(name,"String_Node_Str",balance);
      database.update();
    }
    return;
  }
  try {
    QueryRunner run=new QueryRunner();
    Connection c=iConomy.Database.getConnection();
    try {
      String t=Constants.Nodes.DatabaseTable.toString();
      int update=run.update(c,"String_Node_Str" + t + "String_Node_Str",balance,name.toLowerCase());
    }
 catch (    SQLException ex) {
      System.out.println("String_Node_Str" + ex);
    }
 finally {
      DbUtils.close(c);
    }
  }
 catch (  SQLException ex) {
    System.out.println("String_Node_Str" + ex);
  }
}

Fixed version (ground truth):
static void setBalance(String name,double balance){
  if (!hasAccount(name)) {
    createAccount(name,balance,0);
    return;
  }
  if (useMiniDB() || useInventoryDB() || useOrbDB()) {
    if (useInventoryDB())     if (inventory.dataExists(name)) {
      inventory.setBalance(name,balance);
      return;
    }
    if (useOrbDB()) {
      Player gainer=iConomy.Server.getPlayer(name);
      if (gainer != null) {
        gainer.setTotalExperience((int)balance);
        return;
      }
    }
    if (database.hasIndex(name)) {
      database.setArgument(name,"String_Node_Str",balance);
      database.update();
    }
    return;
  }
  try {
    QueryRunner run=new QueryRunner();
    Connection c=iConomy.Database.getConnection();
    try {
      String t=Constants.Nodes.DatabaseTable.toString();
      int update=run.update(c,"String_Node_Str" + t + "String_Node_Str",balance,name.toLowerCase());
    }
 catch (    SQLException ex) {
      System.out.println("String_Node_Str" + ex);
    }
 finally {
      DbUtils.close(c);
    }
  }
 catch (  SQLException ex) {
    System.out.println("String_Node_Str" + ex);
  }
}
Program: 1571
Project: 1571
Buggy source:
@Override public boolean perform(CommandSender sender,LinkedHashMap<String,Argument> arguments) throws InvalidUsage {
  if (!hasPermissions(sender,"String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  String name=arguments.get("String_Node_Str").getStringValue();
  String tag=template.color(Template.Node.TAG_MONEY);
  boolean self=false;
  if (!isConsole(sender))   if (((Player)sender).getName().equalsIgnoreCase(name))   self=true;
  if (name.equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  if (!Accounts.exists(name)) {
    template.set(Template.Node.ERROR_ACCOUNT);
    template.add("String_Node_Str",name);
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  Account account=new Account(name);
  if (arguments.get("String_Node_Str").getStringValue().equalsIgnoreCase("String_Node_Str")) {
    int current=account.getStatus();
    if (self)     template.set(Template.Node.PERSONAL_STATUS);
 else {
      template.set(Template.Node.PLAYER_STATUS);
      template.add("String_Node_Str",name);
    }
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  if (!hasPermissions(sender,"String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  int status=arguments.get("String_Node_Str").getIntegerValue();
  account.setStatus(status);
  template.set(Template.Node.ACCOUNTS_STATUS);
  template.add("String_Node_Str",status);
  Messaging.send(sender,tag + template.parse());
  return false;
}

Fixed version (ground truth):
@Override public boolean perform(CommandSender sender,LinkedHashMap<String,Argument> arguments) throws InvalidUsage {
  if (!hasPermissions(sender,"String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  String name=arguments.get("String_Node_Str").getStringValue();
  String tag=template.color(Template.Node.TAG_MONEY);
  boolean self=false;
  if (!isConsole(sender))   if (((Player)sender).getName().equalsIgnoreCase(name))   self=true;
  if (name.equals("String_Node_Str"))   throw new InvalidUsage("String_Node_Str");
  if (!Accounts.exists(name)) {
    template.set(Template.Node.ERROR_ACCOUNT);
    template.add("String_Node_Str",name);
    Messaging.send(sender,tag + template.parse());
    return false;
  }
  Account account=new Account(name);
  if (arguments.get("String_Node_Str").getStringValue().equalsIgnoreCase("String_Node_Str")) {
    int current=account.getStatus();
    if (self)     template.set(Template.Node.PERSONAL_STATUS);
 else {
      template.set(Template.Node.PLAYER_STATUS);
      template.add("String_Node_Str",name);
    }
    template.add("String_Node_Str",current);
    Messaging.send(sender,tag + template.parse());
  }
 else {
    if (!hasPermissions(sender,"String_Node_Str"))     throw new InvalidUsage("String_Node_Str");
    int status=arguments.get("String_Node_Str").getIntegerValue();
    account.setStatus(status);
    template.set(Template.Node.ACCOUNTS_STATUS);
    template.add("String_Node_Str",status);
    Messaging.send(sender,tag + template.parse());
  }
  return false;
}
Program: 1572
Project: 1572
Buggy source:
public InventoryDB(){
  server=Bukkit.getServer();
  dataDir=new File(server.getWorlds().get(0).getName(),"String_Node_Str");
}

Fixed version (ground truth):
public InventoryDB(){
  dataDir=new File(iConomy.Server.getWorlds().get(0).getName(),"String_Node_Str");
}
Program: 1573
Project: 1573
Buggy source:
private void writeInventory(String name,ItemStack[] stacks){
  try {
    NBTInputStream in=new NBTInputStream(new FileInputStream(new File(dataDir,name + "String_Node_Str")));
    CompoundTag tag=(CompoundTag)in.readTag();
    in.close();
    ListTag inventory=(ListTag)tag.getValue().get("String_Node_Str");
    inventory.getValue().clear();
    for (int i=0; i < stacks.length; ++i) {
      if (stacks[i] == null)       continue;
      ByteTag count=new ByteTag("String_Node_Str",(byte)stacks[i].getAmount());
      ByteTag slot=new ByteTag("String_Node_Str",(byte)i);
      ShortTag damage=new ShortTag("String_Node_Str",stacks[i].getDurability());
      ShortTag id=new ShortTag("String_Node_Str",(short)stacks[i].getTypeId());
      HashMap<String,Tag> tagMap=new HashMap<String,Tag>();
      tagMap.put("String_Node_Str",count);
      tagMap.put("String_Node_Str",slot);
      tagMap.put("String_Node_Str",damage);
      tagMap.put("String_Node_Str",id);
      inventory.getValue().add(new CompoundTag("String_Node_Str",tagMap));
    }
    NBTOutputStream out=new NBTOutputStream(new FileOutputStream(new File(dataDir,name + "String_Node_Str")));
    out.writeTag(tag);
  }
 catch (  IOException ex) {
  }
}

Fixed version (ground truth):
private void writeInventory(String name,ItemStack[] stacks){
  try {
    NBTInputStream in=new NBTInputStream(new FileInputStream(new File(dataDir,name + "String_Node_Str")));
    CompoundTag tag=(CompoundTag)in.readTag();
    in.close();
    ArrayList tagList=new ArrayList<Tag>();
    for (int i=0; i < stacks.length; ++i) {
      if (stacks[i] == null)       continue;
      ByteTag count=new ByteTag("String_Node_Str",(byte)stacks[i].getAmount());
      ByteTag slot=new ByteTag("String_Node_Str",(byte)i);
      ShortTag damage=new ShortTag("String_Node_Str",stacks[i].getDurability());
      ShortTag id=new ShortTag("String_Node_Str",(short)stacks[i].getTypeId());
      HashMap<String,Tag> tagMap=new HashMap<String,Tag>();
      tagMap.put("String_Node_Str",count);
      tagMap.put("String_Node_Str",slot);
      tagMap.put("String_Node_Str",damage);
      tagMap.put("String_Node_Str",id);
      tagList.add(new CompoundTag("String_Node_Str",tagMap));
    }
    ListTag inventory=new ListTag("String_Node_Str",CompoundTag.class,tagList);
    HashMap<String,Tag> tagCompound=new HashMap<String,Tag>(tag.getValue());
    tagCompound.put("String_Node_Str",inventory);
    tag=new CompoundTag("String_Node_Str",tagCompound);
    NBTOutputStream out=new NBTOutputStream(new FileOutputStream(new File(dataDir,name + "String_Node_Str")));
    out.writeTag(tag);
    out.close();
  }
 catch (  IOException ex) {
    iConomy.Server.getLogger().warning("String_Node_Str" + name + "String_Node_Str"+ ex.getMessage());
  }
}
Program: 1574
Project: 1574
Buggy source:
private void setBalance(ItemStack[] contents,double balance){
  int major=Constants.Nodes.DatabaseMajorItem.getInteger();
  int minor=Constants.Nodes.DatabaseMinorItem.getInteger();
  for (int i=0; i < contents.length; ++i) {
    ItemStack item=contents[i];
    if (item != null) {
      if (item.getTypeId() == major || item.getTypeId() == minor) {
        contents[i]=null;
      }
    }
  }
  for (int i=0; i < contents.length; ++i) {
    if (contents[i] == null) {
      if (balance >= 1) {
        int add=(int)balance;
        if (add > Material.getMaterial(major).getMaxStackSize()) {
          add=Material.getMaterial(major).getMaxStackSize();
        }
        contents[i]=new ItemStack(major,add);
        balance-=add;
      }
 else       if (balance > 0) {
        int add=(int)((balance - (int)balance) * 100);
        if (add > Material.getMaterial(minor).getMaxStackSize()) {
          add=Material.getMaterial(minor).getMaxStackSize();
        }
        contents[i]=new ItemStack(minor,add);
        balance=0;
        break;
      }
    }
  }
}

Fixed version (ground truth):
private void setBalance(ItemStack[] contents,double balance){
  int major=Constants.Nodes.DatabaseMajorItem.getInteger();
  int minor=Constants.Nodes.DatabaseMinorItem.getInteger();
  for (int i=0; i < contents.length; ++i) {
    ItemStack item=contents[i];
    if (item != null) {
      if (item.getTypeId() == major || item.getTypeId() == minor) {
        contents[i]=null;
      }
    }
  }
  for (int i=0; i < contents.length; ++i) {
    if (contents[i] == null) {
      if (balance >= 1) {
        int add=(int)balance;
        if (add > Material.getMaterial(major).getMaxStackSize()) {
          add=Material.getMaterial(major).getMaxStackSize();
        }
        contents[i]=new ItemStack(major,add);
        balance-=add;
      }
 else       if (balance > 0) {
        int add=(int)((balance - (int)balance) * 100);
        if (add > Material.getMaterial(minor).getMaxStackSize()) {
          add=Material.getMaterial(minor).getMaxStackSize();
        }
        contents[i]=new ItemStack(minor,add);
        balance=0;
        break;
      }
    }
  }
  if (balance > 0) {
    throw new RuntimeException("String_Node_Str");
  }
}
Program: 1575
Project: 1575
Buggy source:
private ItemStack[] readInventory(String name){
  try {
    NBTInputStream in=new NBTInputStream(new FileInputStream(new File(dataDir,name + "String_Node_Str")));
    CompoundTag tag=(CompoundTag)in.readTag();
    in.close();
    ListTag inventory=(ListTag)tag.getValue().get("String_Node_Str");
    ItemStack[] stacks=new ItemStack[40];
    for (int i=0; i < inventory.getValue().size(); ++i) {
      CompoundTag item=(CompoundTag)inventory.getValue().get(i);
      byte count=((ByteTag)item.getValue().get("String_Node_Str")).getValue();
      byte slot=((ByteTag)item.getValue().get("String_Node_Str")).getValue();
      short damage=((ShortTag)item.getValue().get("String_Node_Str")).getValue();
      short id=((ShortTag)item.getValue().get("String_Node_Str")).getValue();
      stacks[slot]=new ItemStack(id,damage,count);
    }
    return stacks;
  }
 catch (  IOException ex) {
    return null;
  }
}

Fixed version (ground truth):
private ItemStack[] readInventory(String name){
  try {
    NBTInputStream in=new NBTInputStream(new FileInputStream(new File(dataDir,name + "String_Node_Str")));
    CompoundTag tag=(CompoundTag)in.readTag();
    in.close();
    ListTag inventory=(ListTag)tag.getValue().get("String_Node_Str");
    ItemStack[] stacks=new ItemStack[40];
    for (int i=0; i < inventory.getValue().size(); ++i) {
      CompoundTag item=(CompoundTag)inventory.getValue().get(i);
      byte count=((ByteTag)item.getValue().get("String_Node_Str")).getValue();
      byte slot=((ByteTag)item.getValue().get("String_Node_Str")).getValue();
      short damage=((ShortTag)item.getValue().get("String_Node_Str")).getValue();
      short id=((ShortTag)item.getValue().get("String_Node_Str")).getValue();
      stacks[slot]=new ItemStack(id,count,damage);
    }
    return stacks;
  }
 catch (  IOException ex) {
    iConomy.Server.getLogger().warning("String_Node_Str" + name + "String_Node_Str"+ ex.getMessage());
    return null;
  }
}
Program: 1576
Project: 1576
Buggy source:
public void createBankAccount(CommandSender sender,String name,String player){
  Bank bank=iConomy.getBank(name);
  if (!iConomy.hasAccount(player)) {
    Messaging.send(sender,Template.color("String_Node_Str"));
    return;
  }
  Account account=iConomy.getAccount(player);
  if (bank == null) {
    Messaging.send(sender,Template.parse("String_Node_Str",new String[]{"String_Node_Str"},new String[]{name}));
    return;
  }
  int count=iConomy.Banks.count(player);
  if (count > 1 && !Constants.BankingMultiple || !iConomy.hasPermissions(sender,"String_Node_Str")) {
    Messaging.send(sender,Template.color("String_Node_Str"));
    return;
  }
  if (bank != null) {
    double fee=bank.getFee();
    if (fee < account.getHoldings().balance()) {
      Messaging.send(sender,Template.color("String_Node_Str"));
      return;
    }
    if (bank.createAccount(player)) {
      account.getHoldings().subtract(fee);
      Messaging.send(sender,Template.color("String_Node_Str") + Template.parse("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},new String[]{name,player}));
      if (count == 0) {
        iConomy.getAccount(player).setMainBank(bank.getId());
      }
      return;
    }
 else {
      Messaging.send(sender,Template.color("String_Node_Str"));
    }
  }
 else {
    Messaging.send(sender,Template.color("String_Node_Str"));
  }
}

Fixed version (ground truth):
public void createBankAccount(CommandSender sender,String name,String player){
  Bank bank=iConomy.getBank(name);
  if (!iConomy.hasAccount(player)) {
    Messaging.send(sender,Template.color("String_Node_Str"));
    return;
  }
  Account account=iConomy.getAccount(player);
  if (bank == null) {
    Messaging.send(sender,Template.parse("String_Node_Str",new String[]{"String_Node_Str"},new String[]{name}));
    return;
  }
  int count=iConomy.Banks.count(player);
  if (count > 1 && !Constants.BankingMultiple || !iConomy.hasPermissions(sender,"String_Node_Str")) {
    Messaging.send(sender,Template.color("String_Node_Str"));
    return;
  }
  if (bank != null) {
    double fee=bank.getFee();
    if (fee > account.getHoldings().balance()) {
      Messaging.send(sender,Template.color("String_Node_Str"));
      return;
    }
    if (bank.createAccount(player)) {
      account.getHoldings().subtract(fee);
      Messaging.send(sender,Template.color("String_Node_Str") + Template.parse("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},new String[]{name,player}));
      if (count == 0) {
        iConomy.getAccount(player).setMainBank(bank.getId());
      }
      return;
    }
 else {
      Messaging.send(sender,Template.color("String_Node_Str"));
    }
  }
 else {
    Messaging.send(sender,Template.color("String_Node_Str"));
  }
}
Program: 1577
Project: 1577
Buggy source:
public Database(){
  if (Misc.is(Constants.Database_Type,new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"})) {
    driver="String_Node_Str";
    dsn="String_Node_Str" + Constants.Plugin_Directory + File.separator+ Constants.SQL_Database+ "String_Node_Str";
    username="String_Node_Str";
    password="String_Node_Str";
  }
 else   if (Constants.Database_Type.equalsIgnoreCase("String_Node_Str")) {
    driver="String_Node_Str";
    dsn="String_Node_Str" + Constants.SQL_Hostname + "String_Node_Str"+ Constants.SQL_Port+ "String_Node_Str"+ Constants.SQL_Database;
    username=Constants.SQL_Username;
    password=Constants.SQL_Password;
  }
  try {
    Class.forName(driver).newInstance();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
public Database(){
  if (Misc.is(Constants.Database_Type,new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"})) {
    driver="String_Node_Str";
    dsn="String_Node_Str" + Constants.Plugin_Directory + File.separator+ Constants.SQL_Database+ "String_Node_Str";
    username="String_Node_Str";
    password="String_Node_Str";
  }
 else   if (Constants.Database_Type.equalsIgnoreCase("String_Node_Str")) {
    driver="String_Node_Str";
    dsn="String_Node_Str" + Constants.SQL_Hostname + "String_Node_Str"+ Constants.SQL_Port+ "String_Node_Str"+ Constants.SQL_Database;
    username=Constants.SQL_Username;
    password=Constants.SQL_Password;
  }
  try {
    Class.forName(driver).newInstance();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e);
  }
  if (Misc.is(Constants.Database_Type,new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"})) {
    if (h2pool == null) {
      h2pool=JdbcConnectionPool.create(dsn,username,password);
    }
  }
}
Program: 1578
Project: 1578
Buggy source:
public Connection checkOut(){
  try {
    if (username.equalsIgnoreCase("String_Node_Str") && password.equalsIgnoreCase("String_Node_Str"))     return (DriverManager.getConnection(dsn));
 else {
      return (DriverManager.getConnection(dsn,username,password));
    }
  }
 catch (  SQLException e) {
    System.out.println("String_Node_Str" + e);
    return (null);
  }
}

Fixed version (ground truth):
public Connection checkOut(){
  try {
    if (username.equalsIgnoreCase("String_Node_Str") && password.equalsIgnoreCase("String_Node_Str"))     return (DriverManager.getConnection(dsn));
 else {
      if (Misc.is(Constants.Database_Type,new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"})) {
        return h2pool.getConnection();
      }
 else {
        return (DriverManager.getConnection(dsn,username,password));
      }
    }
  }
 catch (  SQLException e) {
    System.out.println("String_Node_Str" + e);
    return (null);
  }
}
Program: 1579
Project: 1579
Buggy source:
public void subtract(double amount){
  if (Constants.Database_Cache) {
    this.balance=this.balance - amount;
    this.setAltered(true);
    return;
  }
  this.setBalance(this.getBalance() / amount);
}

Fixed version (ground truth):
public void subtract(double amount){
  if (Constants.Database_Cache) {
    this.balance=this.balance - amount;
    this.setAltered(true);
    return;
  }
  this.setBalance(this.getBalance() - amount);
}
Program: 1582
Project: 1582
Buggy source:
/** 
 * Reset a players account, accessable via Console & In-Game
 * @param account The account we are resetting.
 * @param controller If set to null, won't display messages.
 * @param console Is it sent via console?
 */
public void showReset(String account,Player controller,boolean console){
  Player player=iConomy.getBukkitServer().getPlayer(account);
  iConomy.getTransactions().insert(account,"String_Node_Str",0.0,0.0,0.0,0.0,iConomy.getBank().getAccount(account).getBalance());
  iConomy.getBank().resetAccount(account);
  if (player != null) {
    Messaging.send(player,Template.color("String_Node_Str"));
  }
  if (controller != null) {
    Messaging.send(Template.parse("String_Node_Str",new String[]{"String_Node_Str"},new String[]{account}));
  }
  if (console) {
    System.out.println("String_Node_Str" + account + "String_Node_Str");
  }
 else {
    System.out.println(Messaging.bracketize("String_Node_Str") + "String_Node_Str" + account+ "String_Node_Str"+ controller.getName()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Reset a players account, accessable via Console & In-Game
 * @param account The account we are resetting.
 * @param controller If set to null, won't display messages.
 * @param console Is it sent via console?
 */
public void showReset(String account,Player controller,boolean console){
  Player player=iConomy.getBukkitServer().getPlayer(account);
  if (player != null) {
    account=player.getName();
  }
  iConomy.getTransactions().insert(account,"String_Node_Str",0.0,0.0,0.0,0.0,iConomy.getBank().getAccount(account).getBalance());
  iConomy.getBank().resetAccount(account);
  if (player != null) {
    Messaging.send(player,Template.color("String_Node_Str"));
  }
  if (controller != null) {
    Messaging.send(Template.parse("String_Node_Str",new String[]{"String_Node_Str"},new String[]{account}));
  }
  if (console) {
    System.out.println("String_Node_Str" + account + "String_Node_Str");
  }
 else {
    System.out.println(Messaging.bracketize("String_Node_Str") + "String_Node_Str" + account+ "String_Node_Str"+ controller.getName()+ "String_Node_Str");
  }
}
Program: 1583
Project: 1583
Buggy source:
/** 
 * @param account
 * @param controller If set to null, won't display messages.
 * @param amount
 * @param console Is it sent via console?
 */
public void showSet(String name,Player controller,double amount,boolean console){
  Player online=iConomy.getBukkitServer().getPlayer(name);
  Account account=iConomy.getBank().getAccount(name);
  account.setBalance(amount);
  account.save();
  iConomy.getTransactions().insert("String_Node_Str",name,0.0,account.getBalance(),amount,0.0,0.0);
  if (online != null) {
    Messaging.send(online,Template.color("String_Node_Str") + Template.parse("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},new String[]{(console) ? "String_Node_Str" : controller.getName(),iConomy.getBank().format(amount)}));
    showBalance(name,online,true);
  }
  if (controller != null) {
    Messaging.send(Template.color("String_Node_Str") + Template.parse("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},new String[]{name,iConomy.getBank().format(amount)}));
  }
  if (console) {
    System.out.println("String_Node_Str" + account + "String_Node_Str"+ amount+ "String_Node_Str");
  }
 else {
    System.out.println(Messaging.bracketize("String_Node_Str") + "String_Node_Str" + account+ "String_Node_Str"+ amount+ "String_Node_Str"+ controller.getName()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * @param account
 * @param controller If set to null, won't display messages.
 * @param amount
 * @param console Is it sent via console?
 */
public void showSet(String name,Player controller,double amount,boolean console){
  Player online=iConomy.getBukkitServer().getPlayer(name);
  if (online != null) {
    name=online.getName();
  }
  Account account=iConomy.getBank().getAccount(name);
  if (account != null) {
    account.setBalance(amount);
    account.save();
    iConomy.getTransactions().insert("String_Node_Str",name,0.0,account.getBalance(),amount,0.0,0.0);
    if (online != null) {
      Messaging.send(online,Template.color("String_Node_Str") + Template.parse("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},new String[]{(console) ? "String_Node_Str" : controller.getName(),iConomy.getBank().format(amount)}));
      showBalance(name,online,true);
    }
    if (controller != null) {
      Messaging.send(Template.color("String_Node_Str") + Template.parse("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},new String[]{name,iConomy.getBank().format(amount)}));
    }
    if (console) {
      System.out.println("String_Node_Str" + account + "String_Node_Str"+ amount+ "String_Node_Str");
    }
 else {
      System.out.println(Messaging.bracketize("String_Node_Str") + "String_Node_Str" + account+ "String_Node_Str"+ amount+ "String_Node_Str"+ controller.getName()+ "String_Node_Str");
    }
  }
}
Program: 1586
Project: 1586
Buggy source:
/** 
 * Call this method in your Activity's onPause() method body.
 */
public void onPause(Activity activity){
  if (mNfcAdapter == null) {
    return;
  }
  mActivity=activity;
  mState=STATE_PAUSING;
  mNfcAdapter.disableForegroundDispatch(mActivity);
  mNfcAdapter.disableForegroundNdefPush(mActivity);
  mState=STATE_PAUSED;
}

Fixed version (ground truth):
/** 
 * Call this method in your Activity's onPause() method body.
 */
public void onPause(Activity activity){
  if (mNfcAdapter == null) {
    return;
  }
  mActivity=activity;
synchronized (this) {
    mState=STATE_PAUSING;
    mNfcAdapter.disableForegroundDispatch(mActivity);
    mNfcAdapter.disableForegroundNdefPush(mActivity);
    mState=STATE_PAUSED;
  }
}
Program: 1587
Project: 1587
Buggy source:
/** 
 * Call this method in your Activity's onResume() method body.
 */
public void onResume(Activity activity){
  if (mNfcAdapter == null) {
    return;
  }
  mActivity=activity;
  mState=STATE_RESUMING;
  if (mInterfaceMode != MODE_PASSTHROUGH) {
    installNfcHandler();
    if (mInterfaceMode == MODE_EXCHANGE) {
      enableNdefPush();
    }
  }
  mState=STATE_RESUMED;
}

Fixed version (ground truth):
/** 
 * Call this method in your Activity's onResume() method body.
 */
public void onResume(Activity activity){
  if (mNfcAdapter == null) {
    return;
  }
  mActivity=activity;
synchronized (this) {
    mState=STATE_RESUMING;
    if (mInterfaceMode != MODE_PASSTHROUGH) {
      installNfcHandler();
      if (mInterfaceMode == MODE_EXCHANGE) {
        enableNdefPush();
      }
    }
    mState=STATE_RESUMED;
  }
}
Program: 1588
Project: 1588
Buggy source:
/** 
 * Sets an ndef message to be read via android.npp protocol. This method may be called off the main thread.
 */
private void enableNdefPush(){
  if (mNfcAdapter == null) {
    return;
  }
  final NdefMessage ndef=mForegroundMessage;
  if (ndef == null) {
    return;
  }
  mActivity.runOnUiThread(new Runnable(){
    @Override public void run(){
synchronized (Nfc.this) {
        if (mState < STATE_RESUMING) {
          return;
        }
        mNfcAdapter.enableForegroundNdefPush(mActivity,ndef);
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Sets an ndef message to be read via android.npp protocol. This method may be called off the main thread.
 */
private void enableNdefPush(){
  if (mNfcAdapter == null) {
    return;
  }
  final NdefMessage ndef=mForegroundMessage;
  if (ndef == null) {
    mActivity.runOnUiThread(new Runnable(){
      @Override public void run(){
synchronized (Nfc.this) {
          if (mState < STATE_RESUMING) {
            return;
          }
          mNfcAdapter.disableForegroundNdefPush(mActivity);
        }
      }
    }
);
    return;
  }
  mActivity.runOnUiThread(new Runnable(){
    @Override public void run(){
synchronized (Nfc.this) {
        if (mState < STATE_RESUMING) {
          return;
        }
        mNfcAdapter.enableForegroundNdefPush(mActivity,ndef);
      }
    }
  }
);
}
Program: 1589
Project: 1589
Buggy source:
/** 
 * Issues a connection handover of the given type.
 * @param handoverRequest The connection handover request record.
 * @param outboundNdef The ndef message to send from this device. May be null.
 * @throws IOException
 */
public void doConnectionHandover(NdefRecord handoverRequest,NdefProxy ndefProxy) throws IOException ;

Fixed version (ground truth):
/** 
 * Issues a connection handover of the given type.
 * @param handoverRequest The connection handover request record.
 * @param ndefProxy The ndef proxy for sending and receiving ndef messages.
 * @throws IOException
 */
public void doConnectionHandover(NdefRecord handoverRequest,NdefProxy ndefProxy) throws IOException ;
Program: 1590
Project: 1590
Buggy source:
public Nfc(Activity activity){
  mActivity=activity;
  try {
    mNfcAdapter=NfcAdapter.getDefaultAdapter(mActivity);
  }
 catch (  Exception e) {
    Log.i(TAG,"String_Node_Str");
    return;
  }
  addNdefHandler(ConnectionHandoverManager.HANDOVER_PRIORITY,mConnectionHandoverManager);
}

Fixed version (ground truth):
public Nfc(Activity activity){
  mActivity=activity;
  try {
    mNfcAdapter=NfcAdapter.getDefaultAdapter(mActivity);
  }
 catch (  NoSuchMethodError e) {
    Log.i(TAG,"String_Node_Str");
    return;
  }
  addNdefHandler(ConnectionHandoverManager.HANDOVER_PRIORITY,mConnectionHandoverManager);
}
Program: 1591
Project: 1591
Buggy source:
private DeploymentActionsCompleteBuilder undeployAndRemoveUndeployed(final DeploymentPlanBuilder builder,final List<String> deploymentNames){
  DeploymentActionsCompleteBuilder completeBuilder=null;
  for (  String deploymentName : deploymentNames) {
    completeBuilder=builder.undeploy(deploymentName).andRemoveUndeployed();
    if (matchPatternStrategy == MatchPatternStrategy.FIRST) {
      break;
    }
  }
  return completeBuilder;
}

Fixed version (ground truth):
private DeploymentActionsCompleteBuilder undeployAndRemoveUndeployed(final DeploymentPlanBuilder builder,final List<String> deploymentNames){
  DeploymentActionsCompleteBuilder completeBuilder=null;
  for (  String deploymentName : deploymentNames) {
    DeploymentPlanBuilder actualBuilder=(completeBuilder == null ? builder : completeBuilder);
    completeBuilder=actualBuilder.undeploy(deploymentName).andRemoveUndeployed();
    if (matchPatternStrategy == MatchPatternStrategy.FIRST) {
      break;
    }
  }
  return completeBuilder;
}