nus-yam/ex-repair huggingface dataset:
Program: 157791
Project: 157791
Buggy source:
@Override public int announceXCost(int min,int max,String message,Game game,Ability ability,VariableCost variableCost){
  int xValue=0;
  updateGameStatePriority("String_Node_Str",game);
  do {
    if (!isExecutingMacro()) {
      game.fireGetAmountEvent(playerId,message,min,max);
    }
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    xValue=response.getInteger();
  }
  return xValue;
}

Fixed version (ground truth):
@Override public int announceXCost(int min,int max,String message,Game game,Ability ability,VariableCost variableCost){
  int xValue=0;
  updateGameStatePriority("String_Node_Str",game);
  do {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireGetAmountEvent(playerId,message,min,max);
    }
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    xValue=response.getInteger();
  }
  return xValue;
}
Program: 157792
Project: 157792
Buggy source:
@Override public void setResponseBoolean(Boolean responseBoolean){
synchronized (response) {
    response.setBoolean(responseBoolean);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void setResponseBoolean(Boolean responseBoolean){
  waitResponseOpen();
synchronized (response) {
    response.setBoolean(responseBoolean);
    response.notifyAll();
    logger.info("String_Node_Str" + getId());
  }
}
Program: 157793
Project: 157793
Buggy source:
/** 
 * Gets the amount of mana the player want to spent for a x spell
 * @param min
 * @param max
 * @param message
 * @param game
 * @param ability
 * @return
 */
@Override public int announceXMana(int min,int max,String message,Game game,Ability ability){
  int xValue=0;
  updateGameStatePriority("String_Node_Str",game);
  do {
    if (!isExecutingMacro()) {
      game.fireGetAmountEvent(playerId,message,min,max);
    }
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    xValue=response.getInteger();
  }
  return xValue;
}

Fixed version (ground truth):
/** 
 * Gets the amount of mana the player want to spent for a x spell
 * @param min
 * @param max
 * @param message
 * @param game
 * @param ability
 * @return
 */
@Override public int announceXMana(int min,int max,String message,Game game,Ability ability){
  int xValue=0;
  updateGameStatePriority("String_Node_Str",game);
  do {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireGetAmountEvent(playerId,message,min,max);
    }
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    xValue=response.getInteger();
  }
  return xValue;
}
Program: 157795
Project: 157795
Buggy source:
@Override public boolean chooseTargetAmount(Outcome outcome,TargetAmount target,Ability source,Game game){
  updateGameStatePriority("String_Node_Str",game);
  while (!abort) {
    if (!isExecutingMacro()) {
      game.fireSelectTargetEvent(playerId,new MessageToClient(target.getMessage() + "String_Node_Str" + target.getAmountRemaining(),getRelatedObjectName(source,game)),target.possibleTargets(source == null ? null : source.getSourceId(),playerId,game),target.isRequired(source),getOptions(target,null));
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      if (target.canTarget(response.getUUID(),source,game)) {
        UUID targetId=response.getUUID();
        int amountSelected=getAmount(1,target.getAmountRemaining(),"String_Node_Str",game);
        target.addTarget(targetId,amountSelected,source,game);
        return true;
      }
    }
 else     if (!target.isRequired(source)) {
      return false;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean chooseTargetAmount(Outcome outcome,TargetAmount target,Ability source,Game game){
  updateGameStatePriority("String_Node_Str",game);
  while (!abort) {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireSelectTargetEvent(playerId,new MessageToClient(target.getMessage() + "String_Node_Str" + target.getAmountRemaining(),getRelatedObjectName(source,game)),target.possibleTargets(source == null ? null : source.getSourceId(),playerId,game),target.isRequired(source),getOptions(target,null));
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      if (target.canTarget(response.getUUID(),source,game)) {
        UUID targetId=response.getUUID();
        int amountSelected=getAmount(1,target.getAmountRemaining(),"String_Node_Str",game);
        target.addTarget(targetId,amountSelected,source,game);
        return true;
      }
    }
 else     if (!target.isRequired(source)) {
      return false;
    }
  }
  return false;
}
Program: 157796
Project: 157796
Buggy source:
/** 
 * Gets the number of times the user wants to repeat their macro
 * @param game
 * @return
 */
public int announceRepetitions(Game game){
  int xValue=0;
  updateGameStatePriority("String_Node_Str",game);
  do {
    game.fireGetAmountEvent(playerId,"String_Node_Str",0,999);
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    xValue=response.getInteger();
  }
  return xValue;
}

Fixed version (ground truth):
/** 
 * Gets the number of times the user wants to repeat their macro
 * @param game
 * @return
 */
public int announceRepetitions(Game game){
  int xValue=0;
  updateGameStatePriority("String_Node_Str",game);
  do {
    prepareForResponse(game);
    game.fireGetAmountEvent(playerId,"String_Node_Str",0,999);
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    xValue=response.getInteger();
  }
  return xValue;
}
Program: 157797
Project: 157797
Buggy source:
@Override public int getAmount(int min,int max,String message,Game game){
  updateGameStatePriority("String_Node_Str",game);
  do {
    if (!isExecutingMacro()) {
      game.fireGetAmountEvent(playerId,message,min,max);
    }
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    return response.getInteger();
  }
 else {
    return 0;
  }
}

Fixed version (ground truth):
@Override public int getAmount(int min,int max,String message,Game game){
  updateGameStatePriority("String_Node_Str",game);
  do {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireGetAmountEvent(playerId,message,min,max);
    }
    waitForResponse(game);
  }
 while (response.getInteger() == null && !abort);
  if (response != null && response.getInteger() != null) {
    return response.getInteger();
  }
 else {
    return 0;
  }
}
Program: 157798
Project: 157798
Buggy source:
protected void selectCombatGroup(UUID defenderId,UUID blockerId,Game game){
  updateGameStatePriority("String_Node_Str",game);
  TargetAttackingCreature target=new TargetAttackingCreature();
  if (!isExecutingMacro()) {
    game.fireSelectTargetEvent(playerId,new MessageToClient("String_Node_Str",getRelatedObjectName(blockerId,game)),target.possibleTargets(null,playerId,game),false,getOptions(target,null));
  }
  waitForResponse(game);
  if (response.getBoolean() != null) {
  }
 else   if (response.getUUID() != null) {
    CombatGroup group=game.getCombat().findGroup(response.getUUID());
    if (group != null) {
      if (!group.getBlockers().contains(blockerId)) {
        declareBlocker(defenderId,blockerId,response.getUUID(),game);
      }
 else {
        game.getCombat().removeBlockerGromGroup(blockerId,group,game);
      }
    }
  }
}

Fixed version (ground truth):
protected void selectCombatGroup(UUID defenderId,UUID blockerId,Game game){
  updateGameStatePriority("String_Node_Str",game);
  TargetAttackingCreature target=new TargetAttackingCreature();
  prepareForResponse(game);
  if (!isExecutingMacro()) {
    game.fireSelectTargetEvent(playerId,new MessageToClient("String_Node_Str",getRelatedObjectName(blockerId,game)),target.possibleTargets(null,playerId,game),false,getOptions(target,null));
  }
  waitForResponse(game);
  if (response.getBoolean() != null) {
  }
 else   if (response.getUUID() != null) {
    CombatGroup group=game.getCombat().findGroup(response.getUUID());
    if (group != null) {
      if (!group.getBlockers().contains(blockerId)) {
        declareBlocker(defenderId,blockerId,response.getUUID(),game);
      }
 else {
        game.getCombat().removeBlockerGromGroup(blockerId,group,game);
      }
    }
  }
}
Program: 157799
Project: 157799
Buggy source:
@Override public boolean chooseMulligan(Game game){
  updateGameStatePriority("String_Node_Str",game);
  int nextHandSize=game.mulliganDownTo(playerId);
  do {
    String message="String_Node_Str" + (getHand().size() > nextHandSize ? "String_Node_Str" : "String_Node_Str") + nextHandSize+ (nextHandSize == 1 ? "String_Node_Str" : "String_Node_Str");
    Map<String,Serializable> options=new HashMap<>();
    options.put("String_Node_Str","String_Node_Str");
    options.put("String_Node_Str","String_Node_Str");
    if (!isExecutingMacro()) {
      game.fireAskPlayerEvent(playerId,new MessageToClient(message),null,options);
    }
    waitForResponse(game);
  }
 while (response.getBoolean() == null && !abort);
  if (!abort) {
    return response.getBoolean();
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean chooseMulligan(Game game){
  updateGameStatePriority("String_Node_Str",game);
  int nextHandSize=game.mulliganDownTo(playerId);
  do {
    String message="String_Node_Str" + (getHand().size() > nextHandSize ? "String_Node_Str" : "String_Node_Str") + nextHandSize+ (nextHandSize == 1 ? "String_Node_Str" : "String_Node_Str");
    Map<String,Serializable> options=new HashMap<>();
    options.put("String_Node_Str","String_Node_Str");
    options.put("String_Node_Str","String_Node_Str");
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireAskPlayerEvent(playerId,new MessageToClient(message),null,options);
    }
    waitForResponse(game);
  }
 while (response.getBoolean() == null && !abort);
  if (!abort) {
    return response.getBoolean();
  }
  return false;
}
Program: 157801
Project: 157801
Buggy source:
protected boolean pullResponseFromQueue(Game game){
  if (actionQueue.isEmpty() && actionIterations > 0 && !actionQueueSaved.isEmpty()) {
    actionQueue=new LinkedList(actionQueueSaved);
    actionIterations--;
  }
  PlayerResponse action=actionQueue.poll();
  if (action != null) {
    if (action.getString() != null && action.getString().equals("String_Node_Str")) {
      action=actionQueue.poll();
      if (action == null) {
        return false;
      }
      sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED,game,null);
    }
synchronized (response) {
      response.copy(action);
      response.notifyAll();
      macroTriggeredSelectionFlag=false;
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
protected boolean pullResponseFromQueue(Game game){
  if (actionQueue.isEmpty() && actionIterations > 0 && !actionQueueSaved.isEmpty()) {
    actionQueue=new LinkedList(actionQueueSaved);
    actionIterations--;
  }
  PlayerResponse action=actionQueue.poll();
  if (action != null) {
    if (action.getString() != null && action.getString().equals("String_Node_Str")) {
      action=actionQueue.poll();
      if (action == null) {
        return false;
      }
      sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED,game,null);
    }
    waitResponseOpen();
synchronized (response) {
      response.copy(action);
      response.notifyAll();
      macroTriggeredSelectionFlag=false;
      return true;
    }
  }
  return false;
}
Program: 157802
Project: 157802
Buggy source:
@Override public void abort(){
  abort=true;
synchronized (response) {
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void abort(){
  abort=true;
  waitResponseOpen();
synchronized (response) {
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157805
Project: 157805
Buggy source:
@Override public boolean chooseUse(Outcome outcome,String message,String secondMessage,String trueText,String falseText,Ability source,Game game){
  MessageToClient messageToClient=new MessageToClient(message,secondMessage);
  Map<String,Serializable> options=new HashMap<>(2);
  if (trueText != null) {
    options.put("String_Node_Str",trueText);
  }
  if (falseText != null) {
    options.put("String_Node_Str",falseText);
  }
  if (source != null) {
    Boolean answer=requestAutoAnswerId.get(source.getOriginalId() + "String_Node_Str" + message);
    if (answer != null) {
      return answer;
    }
 else {
      answer=requestAutoAnswerText.get(message);
      if (answer != null) {
        return answer;
      }
    }
  }
  updateGameStatePriority("String_Node_Str",game);
  do {
    if (messageToClient.getSecondMessage() == null) {
      messageToClient.setSecondMessage(getRelatedObjectName(source,game));
    }
    if (!isExecutingMacro()) {
      game.fireAskPlayerEvent(playerId,messageToClient,source,options);
    }
    waitForResponse(game);
  }
 while (response.getBoolean() == null && !abort);
  if (!abort) {
    return response.getBoolean();
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean chooseUse(Outcome outcome,String message,String secondMessage,String trueText,String falseText,Ability source,Game game){
  MessageToClient messageToClient=new MessageToClient(message,secondMessage);
  Map<String,Serializable> options=new HashMap<>(2);
  if (trueText != null) {
    options.put("String_Node_Str",trueText);
  }
  if (falseText != null) {
    options.put("String_Node_Str",falseText);
  }
  if (source != null) {
    Boolean answer=requestAutoAnswerId.get(source.getOriginalId() + "String_Node_Str" + message);
    if (answer != null) {
      return answer;
    }
 else {
      answer=requestAutoAnswerText.get(message);
      if (answer != null) {
        return answer;
      }
    }
  }
  updateGameStatePriority("String_Node_Str",game);
  do {
    if (messageToClient.getSecondMessage() == null) {
      messageToClient.setSecondMessage(getRelatedObjectName(source,game));
    }
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireAskPlayerEvent(playerId,messageToClient,source,options);
    }
    waitForResponse(game);
  }
 while (response.getBoolean() == null && !abort);
  if (!abort) {
    return response.getBoolean();
  }
  return false;
}
Program: 157806
Project: 157806
Buggy source:
protected void waitForResponse(Game game){
  if (isExecutingMacro()) {
    pullResponseFromQueue(game);
    return;
  }
  response.clear();
  logger.debug("String_Node_Str" + getId());
  game.resumeTimer(getTurnControlledBy());
  boolean loop=true;
  while (loop) {
    loop=false;
synchronized (response) {
      try {
        response.wait();
      }
 catch (      InterruptedException ex) {
        logger.error("String_Node_Str" + getName() + "String_Node_Str"+ game.getId(),ex);
      }
 finally {
        game.pauseTimer(getTurnControlledBy());
      }
    }
    if (response.getResponseConcedeCheck()) {
      ((GameImpl)game).checkConcede();
      if (game.hasEnded()) {
        return;
      }
      response.clear();
      if (isInGame()) {
        loop=true;
      }
    }
  }
  if (recordingMacro && !macroTriggeredSelectionFlag) {
    actionQueueSaved.add(new PlayerResponse(response));
  }
}

Fixed version (ground truth):
protected void waitForResponse(Game game){
  if (isExecutingMacro()) {
    pullResponseFromQueue(game);
    return;
  }
  response.clear();
  game.resumeTimer(getTurnControlledBy());
  responseOpenedForAnswer=true;
  boolean loop=true;
  while (loop) {
    loop=false;
synchronized (response) {
      try {
        response.wait();
      }
 catch (      InterruptedException ex) {
        logger.error("String_Node_Str" + getName() + "String_Node_Str"+ game.getId(),ex);
      }
 finally {
        responseOpenedForAnswer=false;
        game.pauseTimer(getTurnControlledBy());
      }
    }
    if (response.getResponseConcedeCheck()) {
      ((GameImpl)game).checkConcede();
      if (game.hasEnded()) {
        return;
      }
      response.clear();
      if (isInGame()) {
        loop=true;
      }
    }
  }
  if (recordingMacro && !macroTriggeredSelectionFlag) {
    actionQueueSaved.add(new PlayerResponse(response));
  }
}
Program: 157807
Project: 157807
Buggy source:
protected boolean playManaHandling(Ability abilityToCast,ManaCost unpaid,String promptText,Game game){
  updateGameStatePriority("String_Node_Str",game);
  Map<String,Serializable> options=new HashMap<>();
  if (!isExecutingMacro()) {
    game.firePlayManaEvent(playerId,"String_Node_Str" + promptText,options);
  }
  waitForResponse(game);
  if (!this.canRespond()) {
    return false;
  }
  if (response.getBoolean() != null) {
    return false;
  }
 else   if (response.getUUID() != null) {
    playManaAbilities(abilityToCast,unpaid,game);
  }
 else   if (response.getString() != null && response.getString().equals("String_Node_Str")) {
    if (unpaid instanceof ManaCostsImpl) {
      specialManaAction(unpaid,game);
    }
  }
 else   if (response.getManaType() != null) {
    if (response.getResponseManaTypePlayerId().equals(this.getId())) {
      this.getManaPool().unlockManaType(response.getManaType());
    }
  }
  return true;
}

Fixed version (ground truth):
protected boolean playManaHandling(Ability abilityToCast,ManaCost unpaid,String promptText,Game game){
  updateGameStatePriority("String_Node_Str",game);
  Map<String,Serializable> options=new HashMap<>();
  prepareForResponse(game);
  if (!isExecutingMacro()) {
    game.firePlayManaEvent(playerId,"String_Node_Str" + promptText,options);
  }
  waitForResponse(game);
  if (!this.canRespond()) {
    return false;
  }
  if (response.getBoolean() != null) {
    return false;
  }
 else   if (response.getUUID() != null) {
    playManaAbilities(abilityToCast,unpaid,game);
  }
 else   if (response.getString() != null && response.getString().equals("String_Node_Str")) {
    if (unpaid instanceof ManaCostsImpl) {
      specialManaAction(unpaid,game);
    }
  }
 else   if (response.getManaType() != null) {
    if (response.getResponseManaTypePlayerId().equals(this.getId())) {
      this.getManaPool().unlockManaType(response.getManaType());
    }
  }
  return true;
}
Program: 157808
Project: 157808
Buggy source:
@Override public void setResponseInteger(Integer responseInteger){
synchronized (response) {
    response.setInteger(responseInteger);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void setResponseInteger(Integer responseInteger){
  waitResponseOpen();
synchronized (response) {
    response.setInteger(responseInteger);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157809
Project: 157809
Buggy source:
@Override public void setResponseManaType(UUID manaTypePlayerId,ManaType manaType){
synchronized (response) {
    response.setManaType(manaType);
    response.setResponseManaTypePlayerId(manaTypePlayerId);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void setResponseManaType(UUID manaTypePlayerId,ManaType manaType){
  waitResponseOpen();
synchronized (response) {
    response.setManaType(manaType);
    response.setResponseManaTypePlayerId(manaTypePlayerId);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157811
Project: 157811
Buggy source:
@Override public void skip(){
synchronized (response) {
    response.setInteger(0);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void skip(){
  waitResponseOpen();
synchronized (response) {
    response.setInteger(0);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157812
Project: 157812
Buggy source:
protected void activateAbility(LinkedHashMap<UUID,? extends ActivatedAbility> abilities,MageObject object,Game game){
  updateGameStatePriority("String_Node_Str",game);
  if (abilities.size() == 1 && suppressAbilityPicker(abilities.values().iterator().next(),game)) {
    ActivatedAbility ability=abilities.values().iterator().next();
    if (!ability.getTargets().isEmpty() || !(ability.getCosts().size() == 1 && ability.getCosts().get(0) instanceof SacrificeSourceCost) || !(ability.getCosts().size() == 2 && ability.getCosts().get(0) instanceof TapSourceCost && ability.getCosts().get(0) instanceof SacrificeSourceCost)) {
      activateAbility(ability,game);
      return;
    }
  }
  if (userData.isUseFirstManaAbility() && object instanceof Permanent && object.isLand()) {
    ActivatedAbility ability=abilities.values().iterator().next();
    if (ability instanceof ActivatedManaAbilityImpl) {
      activateAbility(ability,game);
      return;
    }
  }
  if (!isExecutingMacro()) {
    game.fireGetChoiceEvent(playerId,name,object,new ArrayList<>(abilities.values()));
  }
  waitForResponse(game);
  if (response.getUUID() != null && isInGame()) {
    if (abilities.containsKey(response.getUUID())) {
      activateAbility(abilities.get(response.getUUID()),game);
    }
  }
}

Fixed version (ground truth):
protected void activateAbility(LinkedHashMap<UUID,? extends ActivatedAbility> abilities,MageObject object,Game game){
  updateGameStatePriority("String_Node_Str",game);
  if (abilities.size() == 1 && suppressAbilityPicker(abilities.values().iterator().next(),game)) {
    ActivatedAbility ability=abilities.values().iterator().next();
    if (!ability.getTargets().isEmpty() || !(ability.getCosts().size() == 1 && ability.getCosts().get(0) instanceof SacrificeSourceCost) || !(ability.getCosts().size() == 2 && ability.getCosts().get(0) instanceof TapSourceCost && ability.getCosts().get(0) instanceof SacrificeSourceCost)) {
      activateAbility(ability,game);
      return;
    }
  }
  if (userData.isUseFirstManaAbility() && object instanceof Permanent && object.isLand()) {
    ActivatedAbility ability=abilities.values().iterator().next();
    if (ability instanceof ActivatedManaAbilityImpl) {
      activateAbility(ability,game);
      return;
    }
  }
  prepareForResponse(game);
  if (!isExecutingMacro()) {
    game.fireGetChoiceEvent(playerId,name,object,new ArrayList<>(abilities.values()));
  }
  waitForResponse(game);
  if (response.getUUID() != null && isInGame()) {
    if (abilities.containsKey(response.getUUID())) {
      activateAbility(abilities.get(response.getUUID()),game);
    }
  }
}
Program: 157813
Project: 157813
Buggy source:
@Override public UUID chooseAttackerOrder(List<Permanent> attackers,Game game){
  updateGameStatePriority("String_Node_Str",game);
  while (!abort) {
    if (!isExecutingMacro()) {
      game.fireSelectTargetEvent(playerId,"String_Node_Str",attackers,true);
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      for (      Permanent perm : attackers) {
        if (perm.getId().equals(response.getUUID())) {
          return perm.getId();
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public UUID chooseAttackerOrder(List<Permanent> attackers,Game game){
  updateGameStatePriority("String_Node_Str",game);
  while (!abort) {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireSelectTargetEvent(playerId,"String_Node_Str",attackers,true);
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      for (      Permanent perm : attackers) {
        if (perm.getId().equals(response.getUUID())) {
          return perm.getId();
        }
      }
    }
  }
  return null;
}
Program: 157814
Project: 157814
Buggy source:
@Override public void setResponseString(String responseString){
synchronized (response) {
    response.setString(responseString);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void setResponseString(String responseString){
  waitResponseOpen();
synchronized (response) {
    response.setString(responseString);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157815
Project: 157815
Buggy source:
protected void specialManaAction(ManaCost unpaid,Game game){
  LinkedHashMap<UUID,SpecialAction> specialActions=game.getState().getSpecialActions().getControlledBy(playerId,true);
  if (!specialActions.isEmpty()) {
    updateGameStatePriority("String_Node_Str",game);
    if (!isExecutingMacro()) {
      game.fireGetChoiceEvent(playerId,name,null,new ArrayList<>(specialActions.values()));
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      if (specialActions.containsKey(response.getUUID())) {
        SpecialAction specialAction=specialActions.get(response.getUUID());
        if (specialAction != null) {
          specialAction.setUnpaidMana(unpaid);
          activateAbility(specialActions.get(response.getUUID()),game);
        }
      }
    }
  }
}

Fixed version (ground truth):
protected void specialManaAction(ManaCost unpaid,Game game){
  LinkedHashMap<UUID,SpecialAction> specialActions=game.getState().getSpecialActions().getControlledBy(playerId,true);
  if (!specialActions.isEmpty()) {
    updateGameStatePriority("String_Node_Str",game);
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireGetChoiceEvent(playerId,name,null,new ArrayList<>(specialActions.values()));
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      if (specialActions.containsKey(response.getUUID())) {
        SpecialAction specialAction=specialActions.get(response.getUUID());
        if (specialAction != null) {
          specialAction.setUnpaidMana(unpaid);
          activateAbility(specialActions.get(response.getUUID()),game);
        }
      }
    }
  }
}
Program: 157816
Project: 157816
Buggy source:
@Override public UUID chooseBlockerOrder(List<Permanent> blockers,CombatGroup combatGroup,List<UUID> blockerOrder,Game game){
  updateGameStatePriority("String_Node_Str",game);
  while (!abort) {
    if (!isExecutingMacro()) {
      game.fireSelectTargetEvent(playerId,"String_Node_Str",blockers,true);
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      for (      Permanent perm : blockers) {
        if (perm.getId().equals(response.getUUID())) {
          return perm.getId();
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public UUID chooseBlockerOrder(List<Permanent> blockers,CombatGroup combatGroup,List<UUID> blockerOrder,Game game){
  updateGameStatePriority("String_Node_Str",game);
  while (!abort) {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireSelectTargetEvent(playerId,"String_Node_Str",blockers,true);
    }
    waitForResponse(game);
    if (response.getUUID() != null) {
      for (      Permanent perm : blockers) {
        if (perm.getId().equals(response.getUUID())) {
          return perm.getId();
        }
      }
    }
  }
  return null;
}
Program: 157817
Project: 157817
Buggy source:
@Override public void selectBlockers(Game game,UUID defendingPlayerId){
  updateGameStatePriority("String_Node_Str",game);
  FilterCreatureForCombatBlock filter=filterCreatureForCombatBlock.copy();
  filter.add(new ControllerIdPredicate(defendingPlayerId));
  if (game.getBattlefield().count(filter,null,playerId,game) == 0 && !getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockerIfNoneAvailable()) {
    return;
  }
  while (!abort) {
    if (!isExecutingMacro()) {
      game.fireSelectEvent(playerId,"String_Node_Str");
    }
    waitForResponse(game);
    if (response.getBoolean() != null) {
      return;
    }
 else     if (response.getInteger() != null) {
      return;
    }
 else     if (response.getUUID() != null) {
      Permanent blocker=game.getPermanent(response.getUUID());
      if (blocker != null) {
        boolean removeBlocker=false;
        if (filter.match(blocker,null,playerId,game)) {
          selectCombatGroup(defendingPlayerId,blocker.getId(),game);
        }
 else         if (filterBlock.match(blocker,null,playerId,game) && game.getStack().isEmpty()) {
          removeBlocker=true;
        }
        if (removeBlocker) {
          game.getCombat().removeBlocker(blocker.getId(),game);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void selectBlockers(Game game,UUID defendingPlayerId){
  updateGameStatePriority("String_Node_Str",game);
  FilterCreatureForCombatBlock filter=filterCreatureForCombatBlock.copy();
  filter.add(new ControllerIdPredicate(defendingPlayerId));
  if (game.getBattlefield().count(filter,null,playerId,game) == 0 && !getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareBlockerIfNoneAvailable()) {
    return;
  }
  while (!abort) {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireSelectEvent(playerId,"String_Node_Str");
    }
    waitForResponse(game);
    if (response.getBoolean() != null) {
      return;
    }
 else     if (response.getInteger() != null) {
      return;
    }
 else     if (response.getUUID() != null) {
      Permanent blocker=game.getPermanent(response.getUUID());
      if (blocker != null) {
        boolean removeBlocker=false;
        if (filter.match(blocker,null,playerId,game)) {
          selectCombatGroup(defendingPlayerId,blocker.getId(),game);
        }
 else         if (filterBlock.match(blocker,null,playerId,game) && game.getStack().isEmpty()) {
          removeBlocker=true;
        }
        if (removeBlocker) {
          game.getCombat().removeBlocker(blocker.getId(),game);
        }
      }
    }
  }
}
Program: 157818
Project: 157818
Buggy source:
@Override public boolean choosePile(Outcome outcome,String message,List<? extends Card> pile1,List<? extends Card> pile2,Game game){
  updateGameStatePriority("String_Node_Str",game);
  do {
    if (!isExecutingMacro()) {
      game.fireChoosePileEvent(playerId,message,pile1,pile2);
    }
    waitForResponse(game);
  }
 while (response.getBoolean() == null && !abort);
  if (!abort) {
    return response.getBoolean();
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean choosePile(Outcome outcome,String message,List<? extends Card> pile1,List<? extends Card> pile2,Game game){
  updateGameStatePriority("String_Node_Str",game);
  do {
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireChoosePileEvent(playerId,message,pile1,pile2);
    }
    waitForResponse(game);
  }
 while (response.getBoolean() == null && !abort);
  if (!abort) {
    return response.getBoolean();
  }
  return false;
}
Program: 157819
Project: 157819
Buggy source:
@Override public void signalPlayerConcede(){
synchronized (response) {
    response.setResponseConcedeCheck();
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void signalPlayerConcede(){
  waitResponseOpen();
synchronized (response) {
    response.setResponseConcedeCheck();
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157821
Project: 157821
Buggy source:
@Override public int chooseReplacementEffect(Map<String,String> rEffects,Game game){
  updateGameStatePriority("String_Node_Str",game);
  if (rEffects.size() <= 1) {
    return 0;
  }
  if (!autoSelectReplacementEffects.isEmpty()) {
    for (    String autoKey : autoSelectReplacementEffects) {
      int count=0;
      for (      String effectKey : rEffects.keySet()) {
        if (effectKey.equals(autoKey)) {
          return count;
        }
        count++;
      }
    }
  }
  replacementEffectChoice.getChoices().clear();
  replacementEffectChoice.setKeyChoices(rEffects);
  while (!abort) {
    if (!isExecutingMacro()) {
      game.fireChooseChoiceEvent(playerId,replacementEffectChoice);
    }
    updateGameStatePriority("String_Node_Str",game);
    waitForResponse(game);
    logger.debug("String_Node_Str" + response.getString());
    if (response.getString() != null) {
      if (response.getString().startsWith("String_Node_Str")) {
        autoSelectReplacementEffects.add(response.getString().substring(1));
        replacementEffectChoice.setChoiceByKey(response.getString().substring(1));
      }
 else {
        replacementEffectChoice.setChoiceByKey(response.getString());
      }
      if (replacementEffectChoice.getChoiceKey() != null) {
        int index=0;
        for (        String key : rEffects.keySet()) {
          if (replacementEffectChoice.getChoiceKey().equals(key)) {
            return index;
          }
          index++;
        }
      }
    }
  }
  return 0;
}

Fixed version (ground truth):
@Override public int chooseReplacementEffect(Map<String,String> rEffects,Game game){
  updateGameStatePriority("String_Node_Str",game);
  if (rEffects.size() <= 1) {
    return 0;
  }
  if (!autoSelectReplacementEffects.isEmpty()) {
    for (    String autoKey : autoSelectReplacementEffects) {
      int count=0;
      for (      String effectKey : rEffects.keySet()) {
        if (effectKey.equals(autoKey)) {
          return count;
        }
        count++;
      }
    }
  }
  replacementEffectChoice.getChoices().clear();
  replacementEffectChoice.setKeyChoices(rEffects);
  while (!abort) {
    updateGameStatePriority("String_Node_Str",game);
    prepareForResponse(game);
    if (!isExecutingMacro()) {
      game.fireChooseChoiceEvent(playerId,replacementEffectChoice);
    }
    waitForResponse(game);
    logger.debug("String_Node_Str" + response.getString());
    if (response.getString() != null) {
      if (response.getString().startsWith("String_Node_Str")) {
        autoSelectReplacementEffects.add(response.getString().substring(1));
        replacementEffectChoice.setChoiceByKey(response.getString().substring(1));
      }
 else {
        replacementEffectChoice.setChoiceByKey(response.getString());
      }
      if (replacementEffectChoice.getChoiceKey() != null) {
        int index=0;
        for (        String key : rEffects.keySet()) {
          if (replacementEffectChoice.getChoiceKey().equals(key)) {
            return index;
          }
          index++;
        }
      }
    }
  }
  return 0;
}
Program: 157822
Project: 157822
Buggy source:
@Override public void setResponseUUID(UUID responseUUID){
synchronized (response) {
    response.setUUID(responseUUID);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}

Fixed version (ground truth):
@Override public void setResponseUUID(UUID responseUUID){
  waitResponseOpen();
synchronized (response) {
    response.setUUID(responseUUID);
    response.notifyAll();
    logger.debug("String_Node_Str" + getId());
  }
}
Program: 157823
Project: 157823
Buggy source:
@Override public SpellAbility chooseSpellAbilityForCast(SpellAbility ability,Game game,boolean noMana){
switch (ability.getSpellAbilityType()) {
case SPLIT:
case SPLIT_FUSED:
case SPLIT_AFTERMATH:
    MageObject object=game.getObject(ability.getSourceId());
  if (object != null) {
    LinkedHashMap<UUID,ActivatedAbility> useableAbilities=getSpellAbilities(object,game.getState().getZone(object.getId()),game);
    if (useableAbilities != null && useableAbilities.size() == 1) {
      return (SpellAbility)useableAbilities.values().iterator().next();
    }
 else     if (useableAbilities != null && !useableAbilities.isEmpty()) {
      if (!isExecutingMacro()) {
        game.fireGetChoiceEvent(playerId,name,object,new ArrayList<>(useableAbilities.values()));
      }
      waitForResponse(game);
      if (response.getUUID() != null) {
        if (useableAbilities.containsKey(response.getUUID())) {
          return (SpellAbility)useableAbilities.get(response.getUUID());
        }
      }
    }
  }
return null;
default :
return ability;
}
}

Fixed version (ground truth):
@Override public SpellAbility chooseSpellAbilityForCast(SpellAbility ability,Game game,boolean noMana){
switch (ability.getSpellAbilityType()) {
case SPLIT:
case SPLIT_FUSED:
case SPLIT_AFTERMATH:
    MageObject object=game.getObject(ability.getSourceId());
  if (object != null) {
    LinkedHashMap<UUID,ActivatedAbility> useableAbilities=getSpellAbilities(object,game.getState().getZone(object.getId()),game);
    if (useableAbilities != null && useableAbilities.size() == 1) {
      return (SpellAbility)useableAbilities.values().iterator().next();
    }
 else     if (useableAbilities != null && !useableAbilities.isEmpty()) {
      prepareForResponse(game);
      if (!isExecutingMacro()) {
        game.fireGetChoiceEvent(playerId,name,object,new ArrayList<>(useableAbilities.values()));
      }
      waitForResponse(game);
      if (response.getUUID() != null) {
        if (useableAbilities.containsKey(response.getUUID())) {
          return (SpellAbility)useableAbilities.get(response.getUUID());
        }
      }
    }
  }
return null;
default :
return ability;
}
}
Program: 157825
Project: 157825
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  return game.getPermanent(this.getSourceId()).getAttachedTo().equals(event.getPlayerId());
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent sourceObject=game.getPermanentOrLKIBattlefield(this.getSourceId());
  return sourceObject != null && sourceObject.getAttachedTo().equals(event.getPlayerId());
}
Program: 157826
Project: 157826
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    Set<Card> toExile=new HashSet<>();
    for (    UUID permanentId : targetPointer.getTargets(game,source)) {
      Permanent target=game.getPermanent(permanentId);
      if (target != null) {
        toExile.add(target);
      }
    }
    controller.moveCards(toExile,Zone.EXILED,source,game);
    game.applyEffects();
    Set<Card> toBattlefield=new HashSet<>();
    for (    Card card : toExile) {
      Zone currentZone=game.getState().getZone(card.getId());
      if (Zone.BATTLEFIELD != currentZone && currentZone.isPublicZone()) {
        toBattlefield.add(game.getCard(card.getId()));
      }
    }
    controller.moveCards(toBattlefield,Zone.BATTLEFIELD,source,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    Set<Card> toExile=new HashSet<>();
    for (    UUID permanentId : targetPointer.getTargets(game,source)) {
      Permanent target=game.getPermanent(permanentId);
      if (target != null) {
        toExile.add(target);
      }
    }
    controller.moveCards(toExile,Zone.EXILED,source,game);
    game.applyEffects();
    Set<Card> toBattlefield=new HashSet<>();
    for (    Card card : toExile) {
      Zone currentZone=game.getState().getZone(card.getId());
      if (Zone.BATTLEFIELD != currentZone && currentZone.isPublicZone()) {
        toBattlefield.add(card);
      }
    }
    controller.moveCards(toBattlefield,Zone.BATTLEFIELD,source,game);
    return true;
  }
  return false;
}
Program: 157827
Project: 157827
Buggy source:
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  Player controller=game.getPlayer(abilityToModify.getControllerId());
  if (controller != null) {
    Mana mana=abilityToModify.getManaCostsToPay().getMana();
    int reduceMax=mana.getGeneric();
    if (reduceMax > 0 && mana.count() == mana.getGeneric()) {
      reduceMax--;
    }
    if (reduceMax > 2) {
      reduceMax=2;
    }
    if (reduceMax > 0) {
      ChoiceImpl choice=new ChoiceImpl(true);
      Set<String> set=new LinkedHashSet<>();
      for (int i=0; i <= reduceMax; i++) {
        set.add(String.valueOf(i));
      }
      choice.setChoices(set);
      choice.setMessage("String_Node_Str");
      if (controller.choose(Outcome.Benefit,choice,game)) {
        int reduce=Integer.parseInt(choice.getChoice());
        CardUtil.reduceCost(abilityToModify,reduce);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  Player controller=game.getPlayer(abilityToModify.getControllerId());
  if (controller != null) {
    Mana mana=abilityToModify.getManaCostsToPay().getMana();
    int reduceMax=mana.getGeneric();
    if (reduceMax > 0 && mana.count() == mana.getGeneric()) {
      reduceMax--;
    }
    if (reduceMax > 2) {
      reduceMax=2;
    }
    if (reduceMax > 0) {
      ChoiceImpl choice=new ChoiceImpl(true);
      Set<String> set=new LinkedHashSet<>();
      for (int i=0; i <= reduceMax; i++) {
        set.add(String.valueOf(i));
      }
      choice.setChoices(set);
      choice.setMessage("String_Node_Str");
      while (!choice.isChosen()) {
        controller.choose(Outcome.Benefit,choice,game);
        if (!controller.isInGame()) {
          return false;
        }
      }
      int reduce=Integer.parseInt(choice.getChoice());
      CardUtil.reduceCost(abilityToModify,reduce);
    }
    return true;
  }
  return false;
}
Program: 157828
Project: 157828
Buggy source:
@Override public void restoreState(int bookmark,String context){
  if (!simulation && !this.hasEnded()) {
    if (bookmark != 0) {
      if (!savedStates.contains(bookmark - 1)) {
        throw new UnsupportedOperationException("String_Node_Str" + (bookmark - 1) + "String_Node_Str"+ context);
      }
      int stateNum=savedStates.get(bookmark - 1);
      removeBookmark(bookmark);
      GameState restore=gameStates.rollback(stateNum);
      if (restore != null) {
        state.restore(restore);
        playerList.setCurrent(state.getPlayerByOrderId());
      }
    }
  }
}

Fixed version (ground truth):
@Override public void restoreState(int bookmark,String context){
  if (!simulation && !this.hasEnded()) {
    if (bookmark != 0) {
      if (!savedStates.contains(bookmark - 1)) {
        logger.error("String_Node_Str" + (bookmark - 1) + "String_Node_Str"+ context);
        logger.info("String_Node_Str" + savedStates.toString());
      }
 else {
        int stateNum=savedStates.get(bookmark - 1);
        removeBookmark(bookmark);
        GameState restore=gameStates.rollback(stateNum);
        if (restore != null) {
          state.restore(restore);
          playerList.setCurrent(state.getPlayerByOrderId());
        }
      }
    }
  }
}
Program: 157832
Project: 157832
Buggy source:
public Player getNext(Game game){
  Player player;
  UUID start=this.get();
  while (true) {
    player=game.getPlayer(super.getNext());
    if (!player.hasLeft() && !player.hasLost()) {
      break;
    }
    if (!player.hasReachedNextTurnAfterLeaving()) {
      player.setReachedNextTurnAfterLeaving(true);
    }
    if (player.getId().equals(start)) {
      return null;
    }
  }
  return player;
}

Fixed version (ground truth):
public Player getNext(Game game){
  UUID start=this.get();
  if (start == null) {
    return null;
  }
  Player player;
  while (true) {
    player=game.getPlayer(super.getNext());
    if (!player.hasLeft() && !player.hasLost()) {
      break;
    }
    if (!player.hasReachedNextTurnAfterLeaving()) {
      player.setReachedNextTurnAfterLeaving(true);
    }
    if (player.getId().equals(start)) {
      return null;
    }
  }
  return player;
}
Program: 157833
Project: 157833
Buggy source:
@Before public void reset() throws GameException, FileNotFoundException {
  if (currentGame != null) {
    logger.debug("String_Node_Str");
    currentGame=null;
    System.gc();
  }
  currentGame=createNewGameAndPlayers();
  activePlayer=playerA;
  stopOnTurn=2;
  stopAtStep=PhaseStep.UNTAP;
  for (  Player player : currentGame.getPlayers().values()) {
    TestPlayer testPlayer=(TestPlayer)player;
    getCommands(testPlayer).clear();
    getLibraryCards(testPlayer).clear();
    getHandCards(testPlayer).clear();
    getBattlefieldCards(testPlayer).clear();
    getGraveCards(testPlayer).clear();
    ((TestPlayer)player).setInitialTurns(0);
  }
  gameOptions=new GameOptions();
}

Fixed version (ground truth):
@Before public void reset() throws GameException, FileNotFoundException {
  if (currentGame != null) {
    logger.debug("String_Node_Str");
    currentGame=null;
  }
  currentGame=createNewGameAndPlayers();
  activePlayer=playerA;
  stopOnTurn=2;
  stopAtStep=PhaseStep.UNTAP;
  for (  Player player : currentGame.getPlayers().values()) {
    TestPlayer testPlayer=(TestPlayer)player;
    getCommands(testPlayer).clear();
    getLibraryCards(testPlayer).clear();
    getHandCards(testPlayer).clear();
    getBattlefieldCards(testPlayer).clear();
    getGraveCards(testPlayer).clear();
    ((TestPlayer)player).setInitialTurns(0);
  }
  gameOptions=new GameOptions();
}
Program: 157835
Project: 157835
Buggy source:
public OathswornVampirePlayEffect(final OathswornVampirePlayEffect effect){
  super(effect);
}

Fixed version (ground truth):
public OathswornVampirePlayEffect(final OathswornVampirePlayEffect effect){
  super(effect);
  this.condition=effect.condition;
}
Program: 157837
Project: 157837
Buggy source:
public void showUserRequestDialog(final UserRequestMessage userRequestMessage){
  final UserRequestDialog userRequestDialog=new UserRequestDialog();
  userRequestDialog.setLocation(100,100);
  desktopPane.add(userRequestDialog,JLayeredPane.POPUP_LAYER);
  if (SwingUtilities.isEventDispatchThread()) {
    userRequestDialog.showDialog(userRequestMessage);
  }
 else {
    SwingUtilities.invokeLater(() -> userRequestDialog.showDialog(userRequestMessage));
  }
}

Fixed version (ground truth):
public void showUserRequestDialog(final UserRequestMessage userRequestMessage){
  final UserRequestDialog userRequestDialog=new UserRequestDialog();
  userRequestDialog.setLocation(100,100);
  desktopPane.add(userRequestDialog,JLayeredPane.MODAL_LAYER);
  if (SwingUtilities.isEventDispatchThread()) {
    userRequestDialog.showDialog(userRequestMessage);
  }
 else {
    SwingUtilities.invokeLater(() -> userRequestDialog.showDialog(userRequestMessage));
  }
}
Program: 157838
Project: 157838
Buggy source:
public void btnAboutActionPerformed(java.awt.event.ActionEvent evt){
  JInternalFrame[] windows=desktopPane.getAllFramesInLayer(JLayeredPane.POPUP_LAYER);
  for (  JInternalFrame window : windows) {
    if (window instanceof AboutDialog) {
      return;
    }
  }
  AboutDialog aboutDialog=new AboutDialog();
  desktopPane.add(aboutDialog,JLayeredPane.POPUP_LAYER);
  aboutDialog.showDialog(VERSION);
}

Fixed version (ground truth):
public void btnAboutActionPerformed(java.awt.event.ActionEvent evt){
  JInternalFrame[] windows=desktopPane.getAllFramesInLayer(JLayeredPane.MODAL_LAYER);
  for (  JInternalFrame window : windows) {
    if (window instanceof AboutDialog) {
      return;
    }
  }
  AboutDialog aboutDialog=new AboutDialog();
  desktopPane.add(aboutDialog,JLayeredPane.MODAL_LAYER);
  aboutDialog.showDialog(VERSION);
}