nus-yam/ex-repair huggingface dataset:
Program: 159208
Project: 159208
Buggy source:
@Override public void handleConnectionException(Throwable throwable,Client client){
  Session session=SessionManager.getInstance().getSession(client.getSessionId());
  if (session != null) {
    StringBuilder sessionInfo=new StringBuilder();
    User user=UserManager.getInstance().getUser(session.getUserId());
    if (user != null) {
      sessionInfo.append(user.getName());
    }
 else {
      sessionInfo.append("String_Node_Str");
    }
    sessionInfo.append("String_Node_Str").append(session.getHost()).append("String_Node_Str").append(session.getId());
    if (throwable instanceof ClientDisconnectedException) {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      if (logger.isDebugEnabled()) {
        throwable.printStackTrace();
      }
    }
 else {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      if (logger.isDebugEnabled()) {
        throwable.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void handleConnectionException(Throwable throwable,Client client){
  Session session=SessionManager.getInstance().getSession(client.getSessionId());
  if (session != null) {
    StringBuilder sessionInfo=new StringBuilder();
    User user=UserManager.getInstance().getUser(session.getUserId());
    if (user != null) {
      sessionInfo.append(user.getName());
    }
 else {
      sessionInfo.append("String_Node_Str");
    }
    sessionInfo.append("String_Node_Str").append(session.getHost()).append("String_Node_Str").append(session.getId());
    if (throwable instanceof ClientDisconnectedException) {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      if (logger.isDebugEnabled()) {
        throwable.printStackTrace();
      }
    }
 else {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      if (logger.isDebugEnabled()) {
        if (throwable == null) {
          logger.debug("String_Node_Str");
        }
 else {
          throwable.printStackTrace();
        }
      }
    }
  }
}
Program: 159209
Project: 159209
Buggy source:
synchronized public void userLostConnection(){
  User user=UserManager.getInstance().getUser(userId);
  if (user == null || !user.isConnected()) {
    return;
  }
  logger.info("String_Node_Str" + user.getName());
  UserManager.getInstance().disconnect(userId,DisconnectReason.LostConnection);
}

Fixed version (ground truth):
synchronized public void userLostConnection(){
  User user=UserManager.getInstance().getUser(userId);
  if (user == null || !user.isConnected()) {
    return;
  }
  if (!user.getSessionId().equals(sessionId)) {
    logger.info("String_Node_Str" + user.getName());
    return;
  }
  logger.info("String_Node_Str" + user.getName());
  UserManager.getInstance().disconnect(userId,DisconnectReason.LostConnection);
}
Program: 159211
Project: 159211
Buggy source:
public void updateLastActivity(){
  lastActivity=new Date();
}

Fixed version (ground truth):
public void updateLastActivity(){
  lastActivity=new Date();
  if (userState == UserState.Disconnected) {
    userState=UserState.Reconnected;
  }
}
Program: 159212
Project: 159212
Buggy source:
public void handleException(Exception ex){
  if (ex != null && !ex.getMessage().equals("String_Node_Str")) {
    logger.fatal("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
public void handleException(Exception ex){
  if (ex != null) {
    logger.fatal("String_Node_Str");
    ex.printStackTrace();
  }
 else {
    logger.fatal("String_Node_Str");
  }
}
Program: 159213
Project: 159213
Buggy source:
@Override public boolean apply(Game game,Ability source){
  boolean result=false;
  String cardName="String_Node_Str";
  UUID targetPlayerId=null;
  if (source instanceof SpellAbility) {
    Card sourceCard=game.getCard(source.getSourceId());
    if (sourceCard != null) {
      cardName=sourceCard.getName();
    }
  }
 else {
    Permanent sourcePermanent=game.getPermanent(source.getSourceId());
    if (sourcePermanent != null) {
      cardName=sourcePermanent.getName();
    }
  }
  Target exileTarget=null;
  for (  Target target : source.getTargets()) {
    if (!(target instanceof TargetPlayer)) {
      exileTarget=target;
      break;
    }
  }
  if (exileTarget != null && exileTarget instanceof TargetPermanent) {
    Permanent permanentToExile=game.getPermanent(exileTarget.getFirstTarget());
    if (permanentToExile != null) {
      targetPlayerId=permanentToExile.getControllerId();
      result=permanentToExile.moveToExile(null,"String_Node_Str",source.getSourceId(),game);
    }
  }
  this.applySearchAndExile(game,source,cardName,targetPlayerId);
  return result;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  boolean result=false;
  UUID targetPlayerId=null;
  Target exileTarget=null;
  for (  Target target : source.getTargets()) {
    if (target instanceof TargetPermanent) {
      exileTarget=target;
      break;
    }
  }
  if (exileTarget != null) {
    Permanent permanentToExile=game.getPermanent(exileTarget.getFirstTarget());
    if (permanentToExile != null) {
      targetPlayerId=permanentToExile.getControllerId();
      result=permanentToExile.moveToExile(null,"String_Node_Str",source.getSourceId(),game);
      this.applySearchAndExile(game,source,permanentToExile.getName(),targetPlayerId);
    }
  }
  return result;
}
Program: 159215
Project: 159215
Buggy source:
public void join(UUID userId){
  UUID playerId=userPlayerMap.get(userId);
  GameSession gameSession=new GameSession(game,userId,playerId,useTimeout);
  gameSessions.put(playerId,gameSession);
  User user=UserManager.getInstance().getUser(userId);
  gameSession.setUserData(user.getUserData());
  user.addGame(playerId,gameSession);
  logger.debug(new StringBuilder("String_Node_Str").append(playerId).append("String_Node_Str").append(game.getId()).toString());
  ChatManager.getInstance().broadcast(chatId,"String_Node_Str",new StringBuilder(game.getPlayer(playerId).getName()).append("String_Node_Str").toString(),MessageColor.ORANGE,true,MessageType.GAME);
  checkStart();
}

Fixed version (ground truth):
public void join(UUID userId){
  UUID playerId=userPlayerMap.get(userId);
  User user=UserManager.getInstance().getUser(userId);
  if (userId == null || playerId == null) {
    logger.fatal("String_Node_Str");
    logger.fatal("String_Node_Str" + game.getId());
    logger.fatal("String_Node_Str" + userId);
    return;
  }
  Player player=game.getPlayer(playerId);
  if (player == null) {
    logger.fatal("String_Node_Str" + playerId);
    return;
  }
  GameSession gameSession=gameSessions.get(playerId);
  String joinType;
  if (gameSession == null) {
    gameSession=new GameSession(game,userId,playerId,useTimeout);
    gameSessions.put(playerId,gameSession);
    gameSession.setUserData(user.getUserData());
    joinType="String_Node_Str";
  }
 else {
    joinType="String_Node_Str";
  }
  user.addGame(playerId,gameSession);
  logger.debug("String_Node_Str" + playerId + "String_Node_Str"+ joinType+ "String_Node_Str"+ game.getId());
  ChatManager.getInstance().broadcast(chatId,"String_Node_Str",game.getPlayer(playerId).getName() + "String_Node_Str" + joinType+ "String_Node_Str",MessageColor.ORANGE,true,MessageType.GAME);
  checkStart();
}
Program: 159216
Project: 159216
Buggy source:
public void timeout(UUID userId){
  if (userPlayerMap.containsKey(userId)) {
    StringBuilder sb=new StringBuilder(game.getPlayer(userPlayerMap.get(userId)).getName()).append("String_Node_Str").append(ConfigSettings.getInstance().getMaxSecondsIdle()).append("String_Node_Str");
    ChatManager.getInstance().broadcast(chatId,"String_Node_Str",sb.toString(),MessageColor.BLACK,true,MessageType.STATUS);
    game.idleTimeout(getPlayerId(userId));
  }
}

Fixed version (ground truth):
public void timeout(UUID userId){
  if (userPlayerMap.containsKey(userId)) {
    String sb=game.getPlayer(userPlayerMap.get(userId)).getName() + "String_Node_Str" + ConfigSettings.getInstance().getMaxSecondsIdle()+ "String_Node_Str";
    ChatManager.getInstance().broadcast(chatId,"String_Node_Str",sb,MessageColor.BLACK,true,MessageType.STATUS);
    game.idleTimeout(getPlayerId(userId));
  }
}
Program: 159217
Project: 159217
Buggy source:
protected LinkedHashMap<UUID,ManaAbility> getUseableManaAbilities(MageObject object,Zone zone,Game game){
  LinkedHashMap<UUID,ManaAbility> useable=new LinkedHashMap<>();
  for (  ManaAbility ability : object.getAbilities().getManaAbilities(zone)) {
    if (ability.canActivate(playerId,game)) {
      useable.put(ability.getId(),ability);
    }
  }
  return useable;
}

Fixed version (ground truth):
protected LinkedHashMap<UUID,ManaAbility> getUseableManaAbilities(MageObject object,Zone zone,Game game){
  LinkedHashMap<UUID,ManaAbility> useable=new LinkedHashMap<>();
  if (!(object instanceof Permanent) || ((Permanent)object).canUseActivatedAbilities(game)) {
    for (    ManaAbility ability : object.getAbilities().getManaAbilities(zone)) {
      if (ability.canActivate(playerId,game)) {
        useable.put(ability.getId(),ability);
      }
    }
  }
  return useable;
}
Program: 159218
Project: 159218
Buggy source:
@Override public void init(Ability source,Game game){
  targetPointer.init(game,source);
  if (AbilityType.ACTIVATED.equals(source.getAbilityType()) || AbilityType.TRIGGERED.equals(source.getAbilityType())) {
    if (layer != null) {
switch (layer) {
case CopyEffects_1:
case ControlChangingEffects_2:
case TextChangingEffects_3:
case TypeChangingEffects_4:
case ColorChangingEffects_5:
case AbilityAddingRemovingEffects_6:
case PTChangingEffects_7:
        this.affectedObjectsSet=true;
    }
  }
 else {
    if (hasLayer(Layer.CopyEffects_1) || hasLayer(Layer.ControlChangingEffects_2) || hasLayer(Layer.TextChangingEffects_3)|| hasLayer(Layer.TypeChangingEffects_4)|| hasLayer(Layer.ColorChangingEffects_5)|| hasLayer(Layer.AbilityAddingRemovingEffects_6)|| hasLayer(Layer.PTChangingEffects_7)) {
      this.affectedObjectsSet=true;
    }
  }
}
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  targetPointer.init(game,source);
  if (AbilityType.ACTIVATED.equals(source.getAbilityType()) || AbilityType.SPELL.equals(source.getAbilityType()) || AbilityType.TRIGGERED.equals(source.getAbilityType())) {
    if (layer != null) {
switch (layer) {
case CopyEffects_1:
case ControlChangingEffects_2:
case TextChangingEffects_3:
case TypeChangingEffects_4:
case ColorChangingEffects_5:
case AbilityAddingRemovingEffects_6:
case PTChangingEffects_7:
        this.affectedObjectsSet=true;
    }
  }
 else {
    if (hasLayer(Layer.CopyEffects_1) || hasLayer(Layer.ControlChangingEffects_2) || hasLayer(Layer.TextChangingEffects_3)|| hasLayer(Layer.TypeChangingEffects_4)|| hasLayer(Layer.ColorChangingEffects_5)|| hasLayer(Layer.AbilityAddingRemovingEffects_6)|| hasLayer(Layer.PTChangingEffects_7)) {
      this.affectedObjectsSet=true;
    }
  }
}
}
Program: 159219
Project: 159219
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  Permanent perm : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
      if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
        perm.addPower(power.calculate(game,source,this));
        perm.addToughness(toughness.calculate(game,source,this));
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  if (this.affectedObjectsSet) {
    for (Iterator<UUID> it=objects.iterator(); it.hasNext(); ) {
      UUID permanentId=it.next();
      Permanent permanent=game.getPermanent(permanentId);
      if (permanent != null) {
        permanent.addPower(power.calculate(game,source,this));
        permanent.addToughness(toughness.calculate(game,source,this));
      }
 else {
        it.remove();
      }
    }
  }
 else {
    for (    Permanent perm : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
      if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
        perm.addPower(power.calculate(game,source,this));
        perm.addToughness(toughness.calculate(game,source,this));
      }
    }
  }
  return true;
}
Program: 159220
Project: 159220
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  String key=permanent.getId() + keyString;
  long zoneChangeCount=permanent.getZoneChangeCounter();
  long turnNum=game.getTurnNum();
  Long activationState=zoneChangeCount << 32 | turnNum & 0xFFFFFFFFL;
  Map.Entry<Long,Set<UUID>> turnIgnoringPlayersPair=(Map.Entry<Long,Set<UUID>>)game.getState().getValue(key);
  if (turnIgnoringPlayersPair == null || !activationState.equals(turnIgnoringPlayersPair.getKey())) {
    turnIgnoringPlayersPair=new AbstractMap.SimpleImmutableEntry<Long,Set<UUID>>(activationState,new HashSet<UUID>());
    game.getState().setValue(key,turnIgnoringPlayersPair);
  }
  turnIgnoringPlayersPair.getValue().add(game.getActivePlayerId());
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  String key=permanent.getId() + keyString;
  long zoneChangeCount=permanent.getZoneChangeCounter();
  long turnNum=game.getTurnNum();
  Long activationState=zoneChangeCount << 32 | turnNum & 0xFFFFFFFFL;
  Map.Entry<Long,Set<UUID>> turnIgnoringPlayersPair=(Map.Entry<Long,Set<UUID>>)game.getState().getValue(key);
  if (turnIgnoringPlayersPair == null || !activationState.equals(turnIgnoringPlayersPair.getKey())) {
    turnIgnoringPlayersPair=new AbstractMap.SimpleImmutableEntry<Long,Set<UUID>>(activationState,new HashSet<UUID>());
    game.getState().setValue(key,turnIgnoringPlayersPair);
  }
  turnIgnoringPlayersPair.getValue().add(game.getPriorityPlayerId());
  return true;
}
Program: 159222
Project: 159222
Buggy source:
@Override public Set<UUID> possibleTargets(UUID sourceControllerId,Game game){
  Set<UUID> possibleTargets=new HashSet<UUID>();
  for (  UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null && filter.match(player,game)) {
      possibleTargets.add(playerId);
    }
  }
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),sourceControllerId,game)) {
    if (filter.match(permanent,null,sourceControllerId,game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}

Fixed version (ground truth):
@Override public Set<UUID> possibleTargets(UUID sourceControllerId,Game game){
  Set<UUID> possibleTargets=new HashSet<>();
  for (  UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null && filter.match(player,game)) {
      possibleTargets.add(playerId);
    }
  }
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),sourceControllerId,game)) {
    if (filter.match(permanent,null,sourceControllerId,game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
Program: 159223
Project: 159223
Buggy source:
@Override public boolean chooseTargetAmount(Outcome outcome,TargetAmount target,Ability source,Game game){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + outcome.toString() + "String_Node_Str"+ target.toString());
  }
  UUID opponentId=game.getOpponents(playerId).iterator().next();
  if (target instanceof TargetCreatureOrPlayerAmount) {
    if (game.getPlayer(opponentId).getLife() <= target.getAmountRemaining()) {
      target.addTarget(opponentId,target.getAmountRemaining(),source,game);
      return true;
    }
    List<Permanent> targets;
    if (outcome.isGood()) {
      targets=threats(playerId,source.getSourceId(),new FilterCreaturePermanent(),game,target.getTargets());
    }
 else {
      targets=threats(opponentId,source.getSourceId(),new FilterCreaturePermanent(),game,target.getTargets());
    }
    for (    Permanent permanent : targets) {
      if (target.canTarget(permanent.getId(),source,game)) {
        if (permanent.getToughness().getValue() <= target.getAmountRemaining()) {
          target.addTarget(permanent.getId(),permanent.getToughness().getValue(),source,game);
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean chooseTargetAmount(Outcome outcome,TargetAmount target,Ability source,Game game){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + outcome.toString() + "String_Node_Str"+ target.toString());
  }
  UUID opponentId=game.getOpponents(playerId).iterator().next();
  if (target instanceof TargetCreatureOrPlayerAmount) {
    if (outcome.equals(Outcome.Damage) && game.getPlayer(opponentId).getLife() <= target.getAmountRemaining()) {
      target.addTarget(opponentId,target.getAmountRemaining(),source,game);
      return true;
    }
    List<Permanent> targets;
    if (outcome.isGood()) {
      targets=threats(playerId,source.getSourceId(),new FilterCreaturePermanent(),game,target.getTargets());
    }
 else {
      targets=threats(opponentId,source.getSourceId(),new FilterCreaturePermanent(),game,target.getTargets());
    }
    for (    Permanent permanent : targets) {
      if (target.canTarget(permanent.getId(),source,game)) {
        if (permanent.getToughness().getValue() <= target.getAmountRemaining()) {
          target.addTarget(permanent.getId(),permanent.getToughness().getValue(),source,game);
          return true;
        }
      }
    }
    if (outcome.isGood() && target.canTarget(playerId,playerId,source,game)) {
      target.addTarget(opponentId,target.getAmountRemaining(),source,game);
      return true;
    }
 else     if (target.canTarget(playerId,opponentId,source,game)) {
      target.addTarget(opponentId,target.getAmountRemaining(),source,game);
      return true;
    }
 else     if (target.canTarget(playerId,playerId,source,game)) {
      target.addTarget(opponentId,target.getAmountRemaining(),source,game);
      return true;
    }
  }
  return false;
}
Program: 159224
Project: 159224
Buggy source:
public Combat(final Combat combat){
  this.attackerId=combat.attackerId;
  for (  CombatGroup group : combat.groups) {
    groups.add(group.copy());
  }
  defenders.addAll(combat.defenders);
  for (  Map.Entry<UUID,CombatGroup> group : combat.blockingGroups.entrySet()) {
    blockingGroups.put(group.getKey(),group.getValue());
  }
  this.useToughnessForDamage=combat.useToughnessForDamage;
}

Fixed version (ground truth):
public Combat(final Combat combat){
  this.attackerId=combat.attackerId;
  for (  CombatGroup group : combat.groups) {
    groups.add(group.copy());
  }
  defenders.addAll(combat.defenders);
  for (  Map.Entry<UUID,CombatGroup> group : combat.blockingGroups.entrySet()) {
    blockingGroups.put(group.getKey(),group.getValue());
  }
  this.useToughnessForDamage=combat.useToughnessForDamage;
  for (  Map.Entry<UUID,Set<UUID>> group : combat.numberCreaturesDefenderAttackedBy.entrySet()) {
    this.numberCreaturesDefenderAttackedBy.put(group.getKey(),group.getValue());
  }
  for (  Map.Entry<UUID,Set<UUID>> group : combat.creatureMustBlockAttackers.entrySet()) {
    this.creatureMustBlockAttackers.put(group.getKey(),group.getValue());
  }
  for (  Map.Entry<UUID,Set<UUID>> group : combat.creaturesForcedToAttack.entrySet()) {
    this.creaturesForcedToAttack.put(group.getKey(),group.getValue());
  }
  this.maxAttackers=combat.maxAttackers;
}
Program: 159225
Project: 159225
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  List<UUID> perms=new ArrayList<UUID>();
  for (  UUID playerId : controller.getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      int numTargets=Math.min(amount.calculate(game,source,this),game.getBattlefield().countAll(filter,player.getId(),game));
      TargetControlledPermanent target=new TargetControlledPermanent(numTargets,numTargets,filter,false);
      if (target.canChoose(player.getId(),game)) {
        while (!target.isChosen() && player.isInGame()) {
          player.choose(Outcome.Sacrifice,target,source.getSourceId(),game);
        }
        perms.addAll(target.getTargets());
      }
    }
  }
  for (  UUID permID : perms) {
    Permanent permanent=game.getPermanent(permID);
    if (permanent != null) {
      permanent.sacrifice(source.getSourceId(),game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  List<UUID> perms=new ArrayList<>();
  for (  UUID playerId : controller.getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      int numTargets=Math.min(amount.calculate(game,source,this),game.getBattlefield().countAll(filter,player.getId(),game));
      TargetControlledPermanent target=new TargetControlledPermanent(numTargets,numTargets,filter,true);
      if (target.canChoose(player.getId(),game)) {
        while (!target.isChosen() && player.isInGame()) {
          player.choose(Outcome.Sacrifice,target,source.getSourceId(),game);
        }
        perms.addAll(target.getTargets());
      }
    }
  }
  for (  UUID permID : perms) {
    Permanent permanent=game.getPermanent(permID);
    if (permanent != null) {
      permanent.sacrifice(source.getSourceId(),game);
    }
  }
  return true;
}
Program: 159226
Project: 159226
Buggy source:
private boolean checkIfGameIsOver(){
  if (state.isGameOver()) {
    return true;
  }
  int remainingPlayers=0;
  int numLosers=0;
  for (  Player player : state.getPlayers().values()) {
    if (!player.hasLeft()) {
      remainingPlayers++;
    }
    if (player.hasLost()) {
      numLosers++;
    }
  }
  if (remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1) {
    end();
    for (    Player player : state.getPlayers().values()) {
      if (!player.hasLeft() && !player.hasLost()) {
        logger.debug(new StringBuilder("String_Node_Str").append(player.getName()).append("String_Node_Str").append(this.getId()));
        player.won(this);
      }
    }
    endTime=new Date();
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean checkIfGameIsOver(){
  if (state.isGameOver()) {
    return true;
  }
  int remainingPlayers=0;
  int numLosers=0;
  for (  Player player : state.getPlayers().values()) {
    if (!player.hasLeft()) {
      remainingPlayers++;
    }
    if (player.hasLost()) {
      numLosers++;
    }
  }
  if (remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1) {
    end();
    for (    Player player : state.getPlayers().values()) {
      if (!player.hasLeft() && !player.hasLost()) {
        logger.debug(new StringBuilder("String_Node_Str").append(player.getName()).append("String_Node_Str").append(this.getId()));
        player.won(this);
      }
    }
    return true;
  }
  return false;
}
Program: 159227
Project: 159227
Buggy source:
@Override public void end(){
  if (!state.isGameOver()) {
    state.endGame();
    for (    Player player : state.getPlayers().values()) {
      player.abort();
    }
  }
}

Fixed version (ground truth):
@Override public void end(){
  if (!state.isGameOver()) {
    endTime=new Date();
    state.endGame();
    for (    Player player : state.getPlayers().values()) {
      player.abort();
    }
  }
}
Program: 159228
Project: 159228
Buggy source:
@Override public Filter getSourceFilter(){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
@Override public Filter getSourceFilter(){
  for (  T cost : this) {
    if (cost.getSourceFilter() != null) {
      return cost.getSourceFilter();
    }
  }
  return null;
}
Program: 159230
Project: 159230
Buggy source:
public GarrukApexPredatorEmblem(){
  Effect effect=new BoostTargetEffect(5,5,Duration.EndOfGame);
  effect.setText("String_Node_Str");
  Ability ability=new AttackedByCreatureTriggeredAbility(Zone.COMMAND,effect,false,true);
  effect=new GainAbilityTargetEffect(TrampleAbility.getInstance(),Duration.EndOfTurn,"String_Node_Str");
  ability.addEffect(effect);
  this.getAbilities().add(ability);
}

Fixed version (ground truth):
public GarrukApexPredatorEmblem(){
  Effect effect=new BoostTargetEffect(5,5,Duration.EndOfTurn);
  effect.setText("String_Node_Str");
  Ability ability=new AttackedByCreatureTriggeredAbility(Zone.COMMAND,effect,false,true);
  effect=new GainAbilityTargetEffect(TrampleAbility.getInstance(),Duration.EndOfTurn,"String_Node_Str");
  ability.addEffect(effect);
  this.getAbilities().add(ability);
}
Program: 159231
Project: 159231
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && game.getOpponents(super.getControllerId()).contains(spell.getControllerId()) && game.getActivePlayerId().equals(super.getControllerId())) {
      return true;
    }
  }
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
    if (super.getSourceId().equals(event.getTargetId())) {
      MageObject before=game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
      Zone after=game.getState().getZone(event.getTargetId());
      return before != null && after != null && Zone.GRAVEYARD.match(after);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && game.getOpponents(super.getControllerId()).contains(spell.getControllerId()) && game.getActivePlayerId().equals(super.getControllerId())) {
      return true;
    }
  }
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE && getSourceId().equals(event.getTargetId())) {
    ZoneChangeEvent zce=(ZoneChangeEvent)event;
    return zce.getFromZone().equals(Zone.BATTLEFIELD) && zce.getToZone().equals(Zone.GRAVEYARD);
  }
  return false;
}
Program: 159232
Project: 159232
Buggy source:
public VoiceOfResurgenceToken(){
  super("String_Node_Str","String_Node_Str");
  cardType.add(CardType.CREATURE);
  color.setGreen(true);
  color.setWhite(true);
  subtype.add("String_Node_Str");
  power=new MageInt(0);
  toughness=new MageInt(0);
  FilterControlledPermanent filter=new FilterControlledPermanent("String_Node_Str");
  filter.add(new CardTypePredicate(CardType.CREATURE));
  DynamicValue creaturesControlled=new PermanentsOnBattlefieldCount(filter);
  this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,new SetPowerToughnessSourceEffect(creaturesControlled,Duration.EndOfGame)));
}

Fixed version (ground truth):
public VoiceOfResurgenceToken(){
  super("String_Node_Str","String_Node_Str");
  setOriginalExpansionSetCode("String_Node_Str");
  cardType.add(CardType.CREATURE);
  color.setGreen(true);
  color.setWhite(true);
  subtype.add("String_Node_Str");
  power=new MageInt(0);
  toughness=new MageInt(0);
  this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,new SetPowerToughnessSourceEffect(creaturesControlled,Duration.EndOfGame)));
}
Program: 159233
Project: 159233
Buggy source:
@Override public boolean apply(Game game,Ability source){
  List<Permanent> permanents=game.getBattlefield().getActivePermanents(filter,source.getControllerId(),game);
  for (  Permanent permanent : permanents) {
    permanent.damage(amount.calculate(game,source,this),source.getSourceId(),game,false,true);
  }
  for (  UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      player.damage(amount.calculate(game,source,this),source.getSourceId(),game,false,true);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int damage=amount.calculate(game,source,this);
  List<Permanent> permanents=game.getBattlefield().getActivePermanents(filter,source.getControllerId(),game);
  for (  Permanent permanent : permanents) {
    permanent.damage(damage,source.getSourceId(),game,false,true);
  }
  for (  UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      player.damage(damage,source.getSourceId(),game,false,true);
    }
  }
  return true;
}
Program: 159234
Project: 159234
Buggy source:
@Override protected void paintComponent(Graphics g){
  Graphics2D g2d=(Graphics2D)g;
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  if (alpha != 1.0f) {
    AlphaComposite composite=AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,alpha);
    g2d.setComposite(composite);
  }
  if (!hasImage) {
    g2d.setColor(new Color(30,200,200,120));
  }
 else {
    g2d.setColor(new Color(0,0,0,0));
  }
  int cornerSize=Math.max(4,Math.round(cardWidth * ROUNDED_CORNER_SIZE));
  g2d.fillRoundRect(cardXOffset,cardYOffset,cardWidth,cardHeight,cornerSize,cornerSize);
  if (isSelected) {
    g2d.setColor(Color.green);
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
 else   if (isChoosable) {
    g2d.setColor(new Color(250,250,0,230));
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
  if (isPlayable) {
    g2d.setColor(new Color(250,250,0,200));
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
  if (canAttack) {
    g2d.setColor(new Color(250,250,0,200));
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  Graphics2D g2d=(Graphics2D)g;
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  if (alpha != 1.0f) {
    AlphaComposite composite=AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,alpha);
    g2d.setComposite(composite);
  }
  if (!hasImage) {
    g2d.setColor(new Color(30,200,200,120));
  }
 else {
    g2d.setColor(new Color(0,0,0,0));
  }
  int cornerSize=Math.max(4,Math.round(cardWidth * ROUNDED_CORNER_SIZE));
  g2d.fillRoundRect(cardXOffset,cardYOffset,cardWidth,cardHeight,cornerSize,cornerSize);
  if (isSelected) {
    g2d.setColor(Color.green);
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
 else   if (isChoosable) {
    g2d.setColor(new Color(250,250,0,230));
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
  if (isPlayable) {
    g2d.setColor(new Color(250,250,0,200));
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
  if (canAttack) {
    g2d.setColor(new Color(0,0,150,180));
    g2d.fillRoundRect(cardXOffset + 1,cardYOffset + 1,cardWidth - 2,cardHeight - 2,cornerSize,cornerSize);
  }
}
Program: 159235
Project: 159235
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
    Permanent p=game.getPermanent(event.getTargetId());
    if (p != null && p.getCardType().contains(CardType.CREATURE)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
    Permanent permanent=((EntersTheBattlefieldEvent)event).getTarget();
    if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
      game.getContinuousEffects().replaceEvent(event,game);
      return true;
    }
  }
  return false;
}
Program: 159237
Project: 159237
Buggy source:
public boolean replaceEvent(GameEvent event,Game game){
  return effects.replaceEvent(event,game);
}

Fixed version (ground truth):
public boolean replaceEvent(GameEvent event,Game game){
  if (effects.preventedByRuleModification(event,game,false)) {
    return true;
  }
  return effects.replaceEvent(event,game);
}
Program: 159238
Project: 159238
Buggy source:
private static String getMatchResultString(TournamentPlayer p1,TournamentPlayer p2,Match match){
  MatchPlayer mp1=match.getPlayer(p1.getPlayer().getId());
  MatchPlayer mp2=match.getPlayer(p2.getPlayer().getId());
  StringBuilder matchResult=new StringBuilder();
  matchResult.append(p2.getPlayer().getName());
  matchResult.append("String_Node_Str").append(mp1.getWins());
  if (mp1.hasQuit()) {
    matchResult.append(mp1.getPlayer().hasIdleTimeout() ? "String_Node_Str" : (mp1.getPlayer().hasTimerTimeout() ? "String_Node_Str" : "String_Node_Str"));
  }
  if (match.getDraws() > 0) {
    matchResult.append(match.getDraws()).append("String_Node_Str");
  }
  matchResult.append("String_Node_Str").append(mp2.getWins());
  if (mp2.hasQuit()) {
    matchResult.append(mp2.getPlayer().hasIdleTimeout() ? "String_Node_Str" : (mp2.getPlayer().hasTimerTimeout() ? "String_Node_Str" : "String_Node_Str"));
  }
  matchResult.append("String_Node_Str");
  return matchResult.toString();
}

Fixed version (ground truth):
private static String getMatchResultString(TournamentPlayer p1,TournamentPlayer p2,Match match){
  MatchPlayer mp1=match.getPlayer(p1.getPlayer().getId());
  MatchPlayer mp2=match.getPlayer(p2.getPlayer().getId());
  StringBuilder matchResult=new StringBuilder();
  matchResult.append(p2.getPlayer().getName());
  matchResult.append("String_Node_Str").append(mp1.getWins());
  if (mp1.hasQuit()) {
    matchResult.append(mp1.getPlayer().hasIdleTimeout() ? "String_Node_Str" : (mp1.getPlayer().hasTimerTimeout() ? "String_Node_Str" : "String_Node_Str"));
  }
  if (match.getDraws() > 0) {
    matchResult.append("String_Node_Str").append(match.getDraws());
  }
  matchResult.append("String_Node_Str").append(mp2.getWins());
  if (mp2.hasQuit()) {
    matchResult.append(mp2.getPlayer().hasIdleTimeout() ? "String_Node_Str" : (mp2.getPlayer().hasTimerTimeout() ? "String_Node_Str" : "String_Node_Str"));
  }
  matchResult.append("String_Node_Str");
  return matchResult.toString();
}
Program: 159239
Project: 159239
Buggy source:
public Mana getNetMana(Game game){
  return netMana;
}

Fixed version (ground truth):
public Mana getNetMana(Game game){
  return netMana.copy();
}
Program: 159240
Project: 159240
Buggy source:
@Override public boolean putOntoBattlefield(Game game,Zone fromZone,UUID sourceId,UUID controllerId,boolean tapped,ArrayList<UUID> appliedEffects){
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,controllerId,fromZone,Zone.BATTLEFIELD,appliedEffects,tapped);
  if (!game.replaceEvent(event)) {
    if (fromZone != null) {
      boolean removed=false;
switch (fromZone) {
case GRAVEYARD:
        removed=game.getPlayer(ownerId).removeFromGraveyard(this,game);
      break;
case HAND:
    removed=game.getPlayer(ownerId).removeFromHand(this,game);
  break;
case LIBRARY:
removed=game.getPlayer(ownerId).removeFromLibrary(this,game);
break;
case EXILED:
game.getExile().removeCard(this,game);
if (isFaceDown()) {
this.setFaceDown(false);
}
removed=true;
break;
case COMMAND:
removed=true;
break;
case PICK:
removed=true;
break;
default :
logger.warn("String_Node_Str" + fromZone);
}
game.rememberLKI(objectId,event.getFromZone(),this);
if (!removed) {
logger.warn("String_Node_Str" + getName() + "String_Node_Str"+ fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent=new PermanentCard(this,controllerId);
game.resetForSourceId(permanent.getId());
game.addPermanent(permanent);
game.setZone(objectId,Zone.BATTLEFIELD);
game.setScopeRelevant(true);
game.applyEffects();
permanent.setTapped(tapped);
permanent.entersBattlefield(sourceId,game,event.getFromZone(),true);
game.setScopeRelevant(false);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent,controllerId,fromZone,Zone.BATTLEFIELD));
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean putOntoBattlefield(Game game,Zone fromZone,UUID sourceId,UUID controllerId,boolean tapped,ArrayList<UUID> appliedEffects){
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,controllerId,fromZone,Zone.BATTLEFIELD,appliedEffects,tapped);
  if (!game.replaceEvent(event)) {
    if (fromZone != null) {
      boolean removed=false;
switch (fromZone) {
case GRAVEYARD:
        removed=game.getPlayer(ownerId).removeFromGraveyard(this,game);
      break;
case HAND:
    removed=game.getPlayer(ownerId).removeFromHand(this,game);
  break;
case LIBRARY:
removed=game.getPlayer(ownerId).removeFromLibrary(this,game);
break;
case EXILED:
game.getExile().removeCard(this,game);
if (isFaceDown()) {
this.setFaceDown(false);
}
removed=true;
break;
case COMMAND:
removed=true;
break;
case PICK:
removed=true;
break;
default :
logger.warn("String_Node_Str" + fromZone);
}
game.rememberLKI(objectId,event.getFromZone(),this);
if (!removed) {
logger.warn("String_Node_Str" + getName() + "String_Node_Str"+ fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent=new PermanentCard(this,controllerId);
game.resetForSourceId(permanent.getId());
game.addPermanent(permanent);
game.setZone(objectId,Zone.BATTLEFIELD);
game.setScopeRelevant(true);
permanent.setTapped(tapped);
permanent.entersBattlefield(sourceId,game,event.getFromZone(),true);
game.setScopeRelevant(false);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent,controllerId,fromZone,Zone.BATTLEFIELD));
return true;
}
return false;
}
Program: 159242
Project: 159242
Buggy source:
private void collectAllEffects(){
  allEffectsLists.add(layeredEffects);
  allEffectsLists.add(continuousRuleModifyingEffects);
  allEffectsLists.add(replacementEffects);
  allEffectsLists.add(preventionEffects);
  allEffectsLists.add(requirementEffects);
  allEffectsLists.add(restrictionEffects);
  allEffectsLists.add(restrictionUntapNotMoreThanEffects);
  for (  ContinuousEffectsList asThoughtlist : asThoughEffectsMap.values()) {
    allEffectsLists.add(asThoughtlist);
  }
  allEffectsLists.add(costModificationEffects);
  allEffectsLists.add(spliceCardEffects);
}

Fixed version (ground truth):
private void collectAllEffects(){
  allEffectsLists.add(layeredEffects);
  allEffectsLists.add(continuousRuleModifyingEffects);
  allEffectsLists.add(replacementEffects);
  allEffectsLists.add(preventionEffects);
  allEffectsLists.add(requirementEffects);
  allEffectsLists.add(restrictionEffects);
  allEffectsLists.add(restrictionUntapNotMoreThanEffects);
  allEffectsLists.add(costModificationEffects);
  allEffectsLists.add(spliceCardEffects);
}
Program: 159243
Project: 159243
Buggy source:
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  int count=0;
  for (  StackObject stackObject : game.getStack()) {
    if (canBeChosen(stackObject,sourceControllerId,game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  return canChoose(null,sourceControllerId,game);
}
Program: 159244
Project: 159244
Buggy source:
@Override public boolean apply(Game game,Ability source){
  ExileZone exile=game.getExile().getExileZone(source.getSourceId());
  Card sourceCard=game.getCard(source.getSourceId());
  if (exile != null && sourceCard != null) {
    LinkedList<UUID> cards=new LinkedList<>(exile);
    for (    UUID cardId : cards) {
      Card card=game.getCard(cardId);
      card.moveToZone(Zone.BATTLEFIELD,source.getSourceId(),game,false);
      game.informPlayers(new StringBuilder(sourceCard.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").toString());
    }
    exile.clear();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  ExileZone exile=game.getExile().getExileZone(source.getSourceId());
  MageObject sourceObject=game.getObject(source.getSourceId());
  if (exile != null && sourceObject != null) {
    LinkedList<UUID> cards=new LinkedList<>(exile);
    for (    UUID cardId : cards) {
      Card card=game.getCard(cardId);
      card.moveToZone(Zone.BATTLEFIELD,source.getSourceId(),game,false);
      game.informPlayers(new StringBuilder(sourceObject.getLogName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").toString());
    }
    exile.clear();
    return true;
  }
  return false;
}
Program: 159246
Project: 159246
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    Permanent creature : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),source.getSourceId(),game)) {
      creature.moveToZone(Zone.LIBRARY,source.getSourceId(),game,false);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    Permanent creature : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),controller.getId(),source.getSourceId(),game)) {
      controller.moveCardToLibraryWithInfo(creature,source.getSourceId(),game,Zone.BATTLEFIELD,false,true);
    }
    return true;
  }
  return false;
}
Program: 159247
Project: 159247
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  FilterPermanentCard filter=new FilterPermanentCard("String_Node_Str");
  filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan,source.getManaCostsToPay().getX() + 1));
  TargetCardInLibrary target=new TargetCardInLibrary(filter);
  if (player.searchLibrary(target,game)) {
    if (target.getTargets().size() > 0) {
      Card card=player.getLibrary().getCard(target.getFirstTarget(),game);
      if (card != null) {
        card.putOntoBattlefield(game,Zone.LIBRARY,source.getId(),source.getControllerId());
      }
    }
    player.shuffleLibrary(game);
    return true;
  }
  player.shuffleLibrary(game);
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  FilterPermanentCard filter=new FilterPermanentCard("String_Node_Str");
  filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan,source.getManaCostsToPay().getX() + 1));
  TargetCardInLibrary target=new TargetCardInLibrary(filter);
  if (controller.searchLibrary(target,game)) {
    if (target.getTargets().size() > 0) {
      Card card=controller.getLibrary().getCard(target.getFirstTarget(),game);
      if (card != null) {
        controller.putOntoBattlefieldWithInfo(card,game,Zone.LIBRARY,source.getSourceId());
      }
    }
  }
  controller.shuffleLibrary(game);
  return false;
}
Program: 159248
Project: 159248
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getTargets().getFirstTarget());
  if (permanent != null) {
    if (permanent.sacrifice(this.getId(),game)) {
      Player player=game.getPlayer(permanent.getControllerId());
      if (player != null) {
        Library library=player.getLibrary();
        if (library.size() > 0) {
          Cards cards=new CardsImpl();
          Card card=null;
          boolean cardFound=false;
          if (library.size() > 0) {
            do {
              card=library.removeFromTop(game);
              cards.add(card);
              for (              CardType cardType : permanent.getCardType()) {
                if (card.getCardType().contains(cardType)) {
                  if (!card.getCardType().contains(CardType.INSTANT) && !card.getCardType().contains(CardType.SORCERY)) {
                    cardFound=true;
                    break;
                  }
                }
              }
            }
 while (!cardFound && library.size() > 0);
            card.putOntoBattlefield(game,Zone.PICK,source.getId(),player.getId());
          }
          if (cards.size() > 0) {
            player.revealCards("String_Node_Str",cards,game);
            Set<Card> cardsToShuffle=cards.getCards(game);
            if (card != null) {
              cardsToShuffle.remove(card);
            }
            library.addAll(cardsToShuffle,game);
          }
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getTargets().getFirstTarget());
  if (permanent != null) {
    if (permanent.sacrifice(source.getSourceId(),game)) {
      Player permanentController=game.getPlayer(permanent.getControllerId());
      if (permanentController != null) {
        Library library=permanentController.getLibrary();
        if (library.size() > 0) {
          Cards cards=new CardsImpl();
          Card card=null;
          boolean cardFound=false;
          if (library.size() > 0) {
            do {
              card=library.removeFromTop(game);
              cards.add(card);
              if (filter.match(card,game)) {
                for (                CardType cardType : permanent.getCardType()) {
                  if (card.getCardType().contains(cardType)) {
                    cardFound=true;
                    break;
                  }
                }
              }
            }
 while (!cardFound && library.size() > 0);
            permanentController.putOntoBattlefieldWithInfo(card,game,Zone.LIBRARY,source.getSourceId());
          }
          if (cards.size() > 0) {
            permanentController.revealCards("String_Node_Str",cards,game);
            if (cardFound && card != null) {
              cards.remove(card);
            }
            library.addAll(cards.getCards(game),game);
            permanentController.shuffleLibrary(game);
          }
        }
        return true;
      }
      return false;
    }
  }
  return true;
}
Program: 159249
Project: 159249
Buggy source:
public void removeUser(UUID userId,DisconnectReason reason){
  Logger.getLogger(ChatManager.class).debug("String_Node_Str");
  for (  ChatSession chat : chatSessions.values()) {
    chat.kill(userId,reason);
  }
  Logger.getLogger(ChatManager.class).debug("String_Node_Str");
}

Fixed version (ground truth):
public void removeUser(UUID userId,DisconnectReason reason){
  Logger.getLogger(ChatManager.class).debug("String_Node_Str" + chatSessions.size());
  for (  ChatSession chat : chatSessions.values()) {
    chat.kill(userId,reason);
  }
  Logger.getLogger(ChatManager.class).debug("String_Node_Str");
}