nus-yam/ex-repair huggingface dataset:
Program: 159151
Project: 159151
Buggy source:
@Override public boolean canPay(Ability ability,UUID sourceId,UUID controllerId,Game game){
  Permanent planeswalker=game.getPermanent(sourceId);
  return planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game);
}

Fixed version (ground truth):
@Override public boolean canPay(Ability ability,UUID sourceId,UUID controllerId,Game game){
  Permanent planeswalker=game.getPermanent(sourceId);
  return planeswalker != null && planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game);
}
Program: 159152
Project: 159152
Buggy source:
@Override public boolean canPay(Ability ability,UUID sourceId,UUID controllerId,Game game){
  Permanent permanent=game.getPermanent(sourceId);
  if (permanent.getCounters().getCount(name) >= amount) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canPay(Ability ability,UUID sourceId,UUID controllerId,Game game){
  Permanent permanent=game.getPermanent(sourceId);
  if (permanent != null && permanent.getCounters().getCount(name) >= amount) {
    return true;
  }
  return false;
}
Program: 159153
Project: 159153
Buggy source:
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt){
  try {
    if (session.isTableOwner(roomId,tableId)) {
      session.removeTable(roomId,tableId);
    }
 else {
      if (!session.leaveTable(roomId,tableId)) {
        return;
      }
    }
  }
 catch (  Exception e) {
    logger.error(e);
  }
  closeDialog();
}

Fixed version (ground truth):
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt){
  try {
    if (!session.leaveTable(roomId,tableId)) {
      return;
    }
  }
 catch (  Exception e) {
    logger.error(e);
  }
  closeDialog();
}
Program: 159155
Project: 159155
Buggy source:
/** 
 * All activities of the table end (only replay of games (if active) and display tournament results)
 */
public void closeTable(){
  setState(TableState.FINISHED);
  this.validator=null;
}

Fixed version (ground truth):
/** 
 * All activities of the table end (only replay of games (if active) and display tournament results)
 */
public void closeTable(){
  if (!getState().equals(TableState.WAITING) && !getState().equals(TableState.READY_TO_START)) {
    setState(TableState.FINISHED);
  }
  this.validator=null;
}
Program: 159156
Project: 159156
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card card=game.getCard(source.getSourceId());
  if (card != null) {
    if (source.getTargets().get(0).isLegal(source,game)) {
      Permanent creature1=game.getPermanent(source.getTargets().get(0).getFirstTarget());
      Permanent creature2=game.getPermanent(source.getSourceId());
      if (creature1 != null && creature2 != null) {
        if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) {
          creature1.damage(creature2.getPower().getValue(),creature2.getId(),game,false,true);
          creature2.damage(creature1.getPower().getValue(),creature1.getId(),game,false,true);
          return true;
        }
      }
    }
    game.informPlayers(card.getName() + "String_Node_Str");
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent originalPermanent=game.getPermanentOrLKIBattlefield(source.getSourceId());
  if (originalPermanent != null) {
    Permanent sourcePermanent=game.getPermanent(source.getSourceId());
    if (source.getTargets().get(0).isLegal(source,game)) {
      Permanent creature1=game.getPermanent(source.getTargets().get(0).getFirstTarget());
      if (creature1 != null && sourcePermanent != null) {
        if (creature1.getCardType().contains(CardType.CREATURE) && sourcePermanent.getCardType().contains(CardType.CREATURE)) {
          creature1.damage(sourcePermanent.getPower().getValue(),sourcePermanent.getId(),game,false,true);
          sourcePermanent.damage(creature1.getPower().getValue(),creature1.getId(),game,false,true);
          return true;
        }
      }
    }
    game.informPlayers(originalPermanent.getLogName() + "String_Node_Str");
  }
  return false;
}
Program: 159157
Project: 159157
Buggy source:
@Override public boolean applies(UUID sourceId,Ability source,UUID affectedControllerId,Game game){
  if (getTargetPointer().getFirst(game,source).equals(sourceId) && affectedControllerId.equals(source.getControllerId())) {
    Card card=game.getCard(sourceId);
    if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
      Player player=game.getPlayer(affectedControllerId);
      player.setCastSourceIdWithoutMana(sourceId);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(UUID objectId,Ability source,UUID affectedControllerId,Game game){
  if (objectId.equals(getTargetPointer().getFirst(game,source)) && affectedControllerId.equals(source.getControllerId())) {
    Card card=game.getCard(objectId);
    if (card != null && game.getState().getZone(objectId) == Zone.EXILED) {
      Player player=game.getPlayer(affectedControllerId);
      player.setCastSourceIdWithoutMana(objectId);
      return true;
    }
  }
  return false;
}
Program: 159158
Project: 159158
Buggy source:
@Override public String getRule(){
  StringBuilder sb=new StringBuilder("String_Node_Str").append(manaCosts.getText());
  sb.append("String_Node_Str").append(costs.getText()).append("String_Node_Str").toString();
  return sb.toString();
}

Fixed version (ground truth):
@Override public String getRule(){
  StringBuilder sb=new StringBuilder("String_Node_Str").append(manaCosts.getText());
  sb.append("String_Node_Str").append(getManaCosts().getText()).append("String_Node_Str").append(getCosts().getText()).append("String_Node_Str").toString();
  return sb.toString();
}
Program: 159159
Project: 159159
Buggy source:
public Counter(Counter counter){
  this.name=counter.name;
  this.count=counter.count;
}

Fixed version (ground truth):
public Counter(final Counter counter){
  this.name=counter.name;
  this.count=counter.count;
}
Program: 159160
Project: 159160
Buggy source:
@Override public Object getValueAt(int arg0,int arg1){
switch (arg1) {
case 0:
    return matches[arg0].getName();
case 1:
  return matches[arg0].getGameType();
case 2:
return matches[arg0].getDeckType();
case 3:
return matches[arg0].getPlayers();
case 4:
return matches[arg0].getResult();
case 5:
return timeFormatter.format(matches[arg0].getStartTime());
case 6:
if (matches[arg0].getEndTime() != null) {
return timeFormatter.format(matches[arg0].getEndTime());
}
 else {
return "String_Node_Str";
}
case 7:
if (matches[arg0].isTournament()) {
return "String_Node_Str";
}
 else {
if (matches[arg0].isReplayAvailable()) {
return "String_Node_Str";
}
 else {
return "String_Node_Str";
}
}
case 8:
return matches[arg0].getGames();
}
return "String_Node_Str";
}

Fixed version (ground truth):
@Override public Object getValueAt(int arg0,int arg1){
switch (arg1) {
case 0:
    return matches[arg0].getName();
case 1:
  return matches[arg0].getGameType();
case 2:
return matches[arg0].getDeckType();
case 3:
return matches[arg0].getPlayers();
case 4:
return matches[arg0].getResult();
case 5:
if (matches[arg0].getStartTime() != null) {
return timeFormatter.format(matches[arg0].getStartTime());
}
 else {
return "String_Node_Str";
}
case 6:
if (matches[arg0].getEndTime() != null) {
return timeFormatter.format(matches[arg0].getEndTime());
}
 else {
return "String_Node_Str";
}
case 7:
if (matches[arg0].isTournament()) {
return "String_Node_Str";
}
 else {
if (matches[arg0].isReplayAvailable()) {
return "String_Node_Str";
}
 else {
return "String_Node_Str";
}
}
case 8:
return matches[arg0].getGames();
}
return "String_Node_Str";
}
Program: 159162
Project: 159162
Buggy source:
public GameState rollback(int index){
  if (states.size() > 0 && index < states.size()) {
    while (states.size() > index + 1) {
      states.remove(states.size() - 1);
    }
    logger.debug("String_Node_Str" + index);
    return states.get(index);
  }
  return null;
}

Fixed version (ground truth):
public GameState rollback(int index){
  if (states.size() > 0 && index < states.size()) {
    while (states.size() > index + 1) {
      states.remove(states.size() - 1);
    }
    logger.trace("String_Node_Str" + index);
    return states.get(index);
  }
  return null;
}
Program: 159163
Project: 159163
Buggy source:
@Override public boolean hasStarted(){
  return startTime != null;
}

Fixed version (ground truth):
@Override public boolean hasStarted(){
  return startedGames > 0;
}
Program: 159164
Project: 159164
Buggy source:
public MatchImpl(MatchOptions options){
  this.options=options;
  startTime=null;
  replayAvailable=false;
  draws=0;
}

Fixed version (ground truth):
public MatchImpl(MatchOptions options){
  this.options=options;
  this.startTime=new Date();
  replayAvailable=false;
  draws=0;
}
Program: 159165
Project: 159165
Buggy source:
private void checkTableHealthState(){
  if (logger.isDebugEnabled()) {
    debugServerState();
  }
  logger.debug("String_Node_Str");
  List<UUID> toRemove=new ArrayList<>();
  ArrayList<Table> tableCopy=new ArrayList<>();
  tableCopy.addAll(tables.values());
  for (  Table table : tableCopy) {
    try {
      if (!table.getState().equals(TableState.FINISHED)) {
        logger.debug(table.getId() + "String_Node_Str" + table.getName()+ "String_Node_Str"+ formatter.format(table.getStartTime())+ "String_Node_Str"+ table.getState().toString()+ "String_Node_Str"+ (table.isTournament() ? "String_Node_Str" : "String_Node_Str"));
        TableController tableController=getController(table.getId());
        if (tableController != null) {
          if (table.isTournament()) {
            if (!tableController.isTournamentStillValid()) {
              toRemove.add(table.getId());
            }
          }
 else {
            if (!tableController.isMatchTableStillValid()) {
              toRemove.add(table.getId());
            }
          }
        }
      }
    }
 catch (    Exception ex) {
      logger.debug("String_Node_Str" + table.getId());
      logger.debug(Arrays.toString(ex.getStackTrace()));
    }
  }
  for (  UUID tableId : toRemove) {
    try {
      removeTable(tableId);
    }
 catch (    Exception e) {
      logger.error(e);
    }
  }
  logger.debug("String_Node_Str");
}

Fixed version (ground truth):
private void checkTableHealthState(){
  if (logger.isDebugEnabled()) {
    debugServerState();
  }
  logger.debug("String_Node_Str");
  List<UUID> toRemove=new ArrayList<>();
  ArrayList<Table> tableCopy=new ArrayList<>();
  tableCopy.addAll(tables.values());
  for (  Table table : tableCopy) {
    try {
      if (!table.getState().equals(TableState.FINISHED)) {
        logger.debug(table.getId() + "String_Node_Str" + table.getName()+ "String_Node_Str"+ formatter.format(table.getStartTime() == null ? table.getCreateTime() : table.getCreateTime())+ "String_Node_Str"+ table.getState().toString()+ "String_Node_Str"+ (table.isTournament() ? "String_Node_Str" : "String_Node_Str"));
        TableController tableController=getController(table.getId());
        if (tableController != null) {
          if (table.isTournament()) {
            if (!tableController.isTournamentStillValid()) {
              toRemove.add(table.getId());
            }
          }
 else {
            if (!tableController.isMatchTableStillValid()) {
              toRemove.add(table.getId());
            }
          }
        }
      }
    }
 catch (    Exception ex) {
      logger.debug("String_Node_Str" + table.getId());
      logger.debug(Arrays.toString(ex.getStackTrace()));
    }
  }
  for (  UUID tableId : toRemove) {
    try {
      removeTable(tableId);
    }
 catch (    Exception e) {
      logger.error(e);
    }
  }
  logger.debug("String_Node_Str");
}
Program: 159166
Project: 159166
Buggy source:
@Override public boolean apply(Game game,Ability source){
  UUID defenderId=game.getCombat().getDefenderId(source.getSourceId());
  Player defender=game.getPlayer(defenderId);
  if (defender != null) {
    Cards cards=new CardsImpl();
    Card card=defender.getLibrary().getFromTop(game);
    if (card != null) {
      cards.add(card);
      defender.revealCards("String_Node_Str",cards,game);
      if (card.getCardType().contains(CardType.LAND)) {
        defender.getLibrary().removeFromTop(game);
        defender.moveCardToHandWithInfo(card,source.getSourceId(),game,Zone.LIBRARY);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  UUID defenderId=game.getCombat().getDefendingPlayerId(source.getSourceId(),game);
  Player defender=game.getPlayer(defenderId);
  if (defender != null) {
    Cards cards=new CardsImpl();
    Card card=defender.getLibrary().getFromTop(game);
    if (card != null) {
      cards.add(card);
      defender.revealCards("String_Node_Str",cards,game);
      if (card.getCardType().contains(CardType.LAND)) {
        defender.moveCardToHandWithInfo(card,source.getSourceId(),game,Zone.LIBRARY);
      }
    }
    return true;
  }
  return false;
}
Program: 159168
Project: 159168
Buggy source:
@Override public Date getStartTime(){
  return new Date(startTime.getTime());
}

Fixed version (ground truth):
@Override public Date getStartTime(){
  if (startTime != null) {
    return new Date(startTime.getTime());
  }
  return null;
}
Program: 159169
Project: 159169
Buggy source:
@Override public void run(){
  checkExpired();
}

Fixed version (ground truth):
@Override public void run(){
  try {
    checkTableHealthState();
  }
 catch (  Exception ex) {
    logger.fatal("String_Node_Str");
    ex.printStackTrace();
  }
}
Program: 159170
Project: 159170
Buggy source:
private TableManager(){
  expireExecutor.scheduleAtFixedRate(new Runnable(){
    @Override public void run(){
      checkExpired();
    }
  }
,EXPIRE_CHECK_PERIOD,EXPIRE_CHECK_PERIOD,TimeUnit.MINUTES);
}

Fixed version (ground truth):
private TableManager(){
  expireExecutor.scheduleAtFixedRate(new Runnable(){
    @Override public void run(){
      try {
        checkTableHealthState();
      }
 catch (      Exception ex) {
        logger.fatal("String_Node_Str");
        ex.printStackTrace();
      }
    }
  }
,EXPIRE_CHECK_PERIOD,EXPIRE_CHECK_PERIOD,TimeUnit.MINUTES);
}
Program: 159171
Project: 159171
Buggy source:
public void debugServerState(){
  logger.debug("String_Node_Str");
  Collection<User> users=UserManager.getInstance().getUsers();
  logger.debug("String_Node_Str" + users.size() + "String_Node_Str");
  for (  User user : users) {
    logger.debug(user.getId() + "String_Node_Str" + formatter.format(user.getConnectionTime())+ "String_Node_Str"+ user.getName()+ "String_Node_Str"+ user.getUserState().toString()+ "String_Node_Str");
  }
  ArrayList<ChatSession> chatSessions=ChatManager.getInstance().getChatSessions();
  logger.debug("String_Node_Str" + chatSessions.size() + "String_Node_Str");
  for (  ChatSession chatSession : chatSessions) {
    logger.debug(chatSession.getChatId() + "String_Node_Str" + formatter.format(chatSession.getCreateTime())+ "String_Node_Str"+ chatSession.getInfo()+ "String_Node_Str"+ chatSession.getClients().values().toString());
  }
  logger.debug("String_Node_Str" + tables.size() + "String_Node_Str");
  for (  Table table : tables.values()) {
    logger.debug(table.getId() + "String_Node_Str" + table.getName()+ "String_Node_Str"+ formatter.format(table.getStartTime())+ "String_Node_Str"+ table.getState().toString()+ "String_Node_Str");
  }
  logger.debug("String_Node_Str" + GameManager.getInstance().getNumberActiveGames() + "String_Node_Str");
  for (  Entry<UUID,GameController> entry : GameManager.getInstance().getGameController().entrySet()) {
    logger.debug(entry.getKey() + entry.getValue().getPlayerNameList());
  }
  logger.debug("String_Node_Str");
}

Fixed version (ground truth):
public void debugServerState(){
  logger.debug("String_Node_Str");
  Collection<User> users=UserManager.getInstance().getUsers();
  logger.debug("String_Node_Str" + users.size() + "String_Node_Str");
  for (  User user : users) {
    logger.debug(user.getId() + "String_Node_Str" + formatter.format(user.getConnectionTime())+ "String_Node_Str"+ user.getName()+ "String_Node_Str"+ user.getUserState().toString()+ "String_Node_Str");
  }
  ArrayList<ChatSession> chatSessions=ChatManager.getInstance().getChatSessions();
  logger.debug("String_Node_Str" + chatSessions.size() + "String_Node_Str");
  for (  ChatSession chatSession : chatSessions) {
    logger.debug(chatSession.getChatId() + "String_Node_Str" + formatter.format(chatSession.getCreateTime())+ "String_Node_Str"+ chatSession.getInfo()+ "String_Node_Str"+ chatSession.getClients().values().toString());
  }
  logger.debug("String_Node_Str" + GameManager.getInstance().getNumberActiveGames() + "String_Node_Str");
  for (  Entry<UUID,GameController> entry : GameManager.getInstance().getGameController().entrySet()) {
    logger.debug(entry.getKey() + entry.getValue().getPlayerNameList());
  }
  logger.debug("String_Node_Str");
}
Program: 159173
Project: 159173
Buggy source:
private void saveDividerLocations(){
  Rectangle rec=MageFrame.getDesktop().getBounds();
  StringBuilder sb=new StringBuilder(Double.toString(rec.getWidth())).append("String_Node_Str").append(Double.toString(rec.getHeight()));
  PreferencesDialog.saveValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE,sb.toString());
  PreferencesDialog.saveValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_1,Integer.toString(this.jSplitPane1.getDividerLocation()));
  PreferencesDialog.saveValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_2,Integer.toString(this.jSplitPane2.getDividerLocation()));
}

Fixed version (ground truth):
private void saveDividerLocations(){
  Rectangle rec=MageFrame.getDesktop().getBounds();
  String sb=Double.toString(rec.getWidth()) + "String_Node_Str" + Double.toString(rec.getHeight());
  PreferencesDialog.saveValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE,sb);
  PreferencesDialog.saveValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_1,Integer.toString(this.jSplitPane1.getDividerLocation()));
  PreferencesDialog.saveValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_2,Integer.toString(this.jSplitPane2.getDividerLocation()));
}
Program: 159175
Project: 159175
Buggy source:
private void restoreDividerLocations(){
  Rectangle rec=MageFrame.getDesktop().getBounds();
  if (rec != null) {
    String size=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE,null);
    StringBuilder sb=new StringBuilder(Double.toString(rec.getWidth())).append("String_Node_Str").append(Double.toString(rec.getHeight()));
    if (size != null && size.equals(sb.toString())) {
      String location=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_1,null);
      if (location != null && jSplitPane1 != null) {
        jSplitPane1.setDividerLocation(Integer.parseInt(location));
      }
      location=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_2,null);
      if (location != null && jSplitPane2 != null) {
        jSplitPane2.setDividerLocation(Integer.parseInt(location));
      }
    }
  }
}

Fixed version (ground truth):
private void restoreDividerLocations(){
  Rectangle rec=MageFrame.getDesktop().getBounds();
  if (rec != null) {
    String size=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE,null);
    String sb=Double.toString(rec.getWidth()) + "String_Node_Str" + Double.toString(rec.getHeight());
    if (size != null && size.equals(sb)) {
      String location=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_1,null);
      if (location != null && jSplitPane1 != null) {
        jSplitPane1.setDividerLocation(Integer.parseInt(location));
      }
      location=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_2,null);
      if (location != null && jSplitPane2 != null) {
        jSplitPane2.setDividerLocation(Integer.parseInt(location));
      }
    }
  }
}
Program: 159176
Project: 159176
Buggy source:
public boolean isMatchTableStillValid(){
  if (!table.isTournament() && !table.isTournamentSubTable()) {
    int humanPlayers=0;
    int validHumanPlayers=0;
    if (match == null) {
      return false;
    }
    for (    Map.Entry<UUID,UUID> userPlayerEntry : userPlayerMap.entrySet()) {
      MatchPlayer matchPlayer=match.getPlayer(userPlayerEntry.getValue());
      if (matchPlayer.getPlayer().isHuman()) {
        humanPlayers++;
        if (!matchPlayer.hasQuit()) {
          User user=UserManager.getInstance().getUser(userPlayerEntry.getKey());
          if (user != null && user.isExpired(null)) {
            validHumanPlayers++;
          }
        }
      }
    }
    return validHumanPlayers >= 2 || validHumanPlayers == humanPlayers;
  }
  return true;
}

Fixed version (ground truth):
public boolean isMatchTableStillValid(){
  if (!table.isTournament()) {
    int humanPlayers=0;
    int aiPlayers=0;
    int validHumanPlayers=0;
    if (match == null && !(table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING) || table.getState().equals(TableState.READY_TO_START))) {
      logger.debug("String_Node_Str");
      logger.debug("String_Node_Str" + match.getId() + "String_Node_Str"+ match.getName()+ "String_Node_Str");
    }
    if (match.isDoneSideboarding()) {
      if (match.getGame() == null) {
        logger.debug("String_Node_Str");
        logger.debug("String_Node_Str" + match.getId() + "String_Node_Str"+ match.getName()+ "String_Node_Str");
      }
    }
    for (    Map.Entry<UUID,UUID> userPlayerEntry : userPlayerMap.entrySet()) {
      MatchPlayer matchPlayer=match.getPlayer(userPlayerEntry.getValue());
      if (matchPlayer == null) {
        logger.debug("String_Node_Str");
        logger.debug("String_Node_Str" + match.getId());
        logger.debug("String_Node_Str" + userPlayerEntry.getKey());
        logger.debug("String_Node_Str" + userPlayerEntry.getValue());
        continue;
      }
      if (matchPlayer.getPlayer().isHuman()) {
        humanPlayers++;
        User user=UserManager.getInstance().getUser(userPlayerEntry.getKey());
        if (!matchPlayer.hasQuit()) {
          if (user == null) {
            logger.debug("String_Node_Str");
            logger.debug("String_Node_Str" + match.getId());
            logger.debug("String_Node_Str" + userPlayerEntry.getKey());
            logger.debug("String_Node_Str" + userPlayerEntry.getValue());
            return false;
          }
          validHumanPlayers++;
        }
      }
 else {
        aiPlayers++;
      }
    }
    return validHumanPlayers >= 2 || validHumanPlayers == humanPlayers || aiPlayers > 1;
  }
  return true;
}
Program: 159177
Project: 159177
Buggy source:
private void initTournament(){
  TableManager.getInstance().initTournament(tableId);
}

Fixed version (ground truth):
private void initTournament(){
  if (!TableManager.getInstance().getTable(tableId).getState().equals(TableState.DUELING)) {
    TableManager.getInstance().initTournament(tableId);
  }
}
Program: 159178
Project: 159178
Buggy source:
private void startMatch(TournamentPairing pair,MatchOptions matchOptions){
  try {
    TableManager tableManager=TableManager.getInstance();
    Table table=tableManager.createTable(GamesRoomManager.getInstance().getMainRoomId(),matchOptions);
    table.setTournamentSubTable(true);
    table.setTournament(tournament);
    TournamentPlayer player1=pair.getPlayer1();
    TournamentPlayer player2=pair.getPlayer2();
    tableManager.addPlayer(getPlayerUserId(player1.getPlayer().getId()),table.getId(),player1.getPlayer(),player1.getPlayerType(),player1.getDeck());
    tableManager.addPlayer(getPlayerUserId(player2.getPlayer().getId()),table.getId(),player2.getPlayer(),player2.getPlayerType(),player2.getDeck());
    tableManager.startTournamentSubMatch(null,table.getId());
    pair.setMatch(tableManager.getMatch(table.getId()));
    pair.setTableId(table.getId());
    player1.setState(TournamentPlayerState.DUELING);
    player2.setState(TournamentPlayerState.DUELING);
  }
 catch (  GameException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private void startMatch(TournamentPairing pair,MatchOptions matchOptions){
  try {
    TableManager tableManager=TableManager.getInstance();
    Table table=tableManager.createTable(GamesRoomManager.getInstance().getMainRoomId(),matchOptions);
    table.setTournamentSubTable(true);
    table.setTournament(tournament);
    table.setState(TableState.WAITING);
    TournamentPlayer player1=pair.getPlayer1();
    TournamentPlayer player2=pair.getPlayer2();
    tableManager.addPlayer(getPlayerUserId(player1.getPlayer().getId()),table.getId(),player1.getPlayer(),player1.getPlayerType(),player1.getDeck());
    tableManager.addPlayer(getPlayerUserId(player2.getPlayer().getId()),table.getId(),player2.getPlayer(),player2.getPlayerType(),player2.getDeck());
    table.setState(TableState.STARTING);
    tableManager.startTournamentSubMatch(null,table.getId());
    pair.setMatch(tableManager.getMatch(table.getId()));
    pair.setTableId(table.getId());
    player1.setState(TournamentPlayerState.DUELING);
    player2.setState(TournamentPlayerState.DUELING);
  }
 catch (  GameException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}
Program: 159180
Project: 159180
Buggy source:
public MatchView(Table table){
  this.tableId=table.getId();
  this.isTournament=true;
  this.matchId=table.getTournament().getId();
  this.matchName=table.getName();
  this.gameType=table.getGameType();
  if (table.getTournament().getOptions().getNumberRounds() > 0) {
    this.gameType=new StringBuilder(this.gameType).append("String_Node_Str").append(table.getTournament().getOptions().getNumberRounds()).append("String_Node_Str").toString();
  }
  this.deckType=new StringBuilder(table.getDeckType()).append("String_Node_Str").append(table.getTournament().getBoosterInfo()).toString();
  StringBuilder sb1=new StringBuilder();
  for (  TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
    sb1.append(tPlayer.getPlayer().getName()).append("String_Node_Str").append(tPlayer.getPoints()).append("String_Node_Str");
  }
  this.players=sb1.toString();
  StringBuilder sb2=new StringBuilder();
  if (table.getTournament().getRounds().size() > 0) {
    for (    TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
      sb2.append(tPlayer.getPlayer().getName()).append("String_Node_Str").append(tPlayer.getResults()).append("String_Node_Str");
    }
  }
 else {
    sb2.append("String_Node_Str");
  }
  this.result=sb2.toString();
  this.startTime=table.getTournament().getStartTime();
  this.endTime=table.getTournament().getEndTime();
  this.replayAvailable=false;
}

Fixed version (ground truth):
public MatchView(Table table){
  this.tableId=table.getId();
  this.isTournament=table.isTournament();
  if (table.isTournament()) {
    initTournamentTable(table);
  }
 else {
    initMatchTable(table);
  }
}
Program: 159182
Project: 159182
Buggy source:
public void userQuitTournamentSubTables(UUID tournamentId,UUID userId){
  for (  TableController controller : controllers.values()) {
    if (controller.getTable().isTournamentSubTable() && controller.getTable().getTournament().getId().equals(tournamentId)) {
      Match match=controller.getTable().getMatch();
      if (match != null) {
        if (match.getGame() != null) {
          GameManager.getInstance().quitMatch(match.getGame().getId(),userId);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void userQuitTournamentSubTables(UUID tournamentId,UUID userId){
  for (  TableController controller : controllers.values()) {
    if (controller.getTable().isTournamentSubTable() && controller.getTable().getTournament().getId().equals(tournamentId)) {
      if (controller.isPlayer(userId)) {
        Match match=controller.getTable().getMatch();
        if (match != null) {
          if (!match.hasEnded() && match.getGame() != null) {
            GameManager.getInstance().quitMatch(match.getGame().getId(),userId);
          }
        }
      }
    }
  }
}
Program: 159183
Project: 159183
Buggy source:
public void handleException(Exception ex){
  if (ex != null) {
    logger.fatal("String_Node_Str");
    ex.printStackTrace();
  }
 else {
    logger.fatal("String_Node_Str");
  }
}

Fixed version (ground truth):
public void handleException(Exception ex){
  if (ex != null) {
    logger.fatal("String_Node_Str" + (ex.getMessage() == null ? "String_Node_Str" : ex.getMessage()));
    if (ex.getCause() != null) {
      logger.debug("String_Node_Str" + (ex.getCause().getMessage() == null ? "String_Node_Str" : ex.getCause().getMessage()));
    }
    ex.printStackTrace();
  }
 else {
    logger.fatal("String_Node_Str");
  }
}
Program: 159184
Project: 159184
Buggy source:
private synchronized void endGameInfo(){
  Table table=TableManager.getInstance().getTable(tableId);
  if (table != null) {
    if (table.getMatch() != null) {
      for (      final GameSession gameSession : gameSessions.values()) {
        gameSession.endGameInfo(table.getMatch());
      }
    }
  }
}

Fixed version (ground truth):
private synchronized void endGameInfo(){
  Table table=TableManager.getInstance().getTable(tableId);
  if (table != null) {
    if (table.getMatch() != null) {
      for (      final GameSession gameSession : gameSessions.values()) {
        gameSession.endGameInfo(table);
      }
    }
  }
}
Program: 159185
Project: 159185
Buggy source:
public void endGameInfo(Match match){
  if (!killed) {
    User user=UserManager.getInstance().getUser(userId);
    if (user != null) {
      user.fireCallback(new ClientCallback("String_Node_Str",game.getId(),getGameEndView(playerId,match)));
    }
  }
}

Fixed version (ground truth):
public void endGameInfo(Table table){
  if (!killed) {
    User user=UserManager.getInstance().getUser(userId);
    if (user != null) {
      user.fireCallback(new ClientCallback("String_Node_Str",game.getId(),getGameEndView(playerId,table)));
    }
  }
}
Program: 159186
Project: 159186
Buggy source:
public GameEndView getGameEndView(UUID playerId,Match match){
  return new GameEndView(game.getState(),game,playerId,match);
}

Fixed version (ground truth):
public GameEndView getGameEndView(UUID playerId,Table table){
  return new GameEndView(game.getState(),game,playerId,table);
}
Program: 159187
Project: 159187
Buggy source:
private void update(){
  ArrayList<TableView> tableList=new ArrayList<>();
  ArrayList<MatchView> matchList=new ArrayList<>();
  List<Table> allTables=new ArrayList<>(tables.values());
  Collections.sort(allTables,new TableListSorter());
  for (  Table table : allTables) {
    if (table.getState() != TableState.FINISHED) {
      tableList.add(new TableView(table));
    }
 else     if (matchList.size() < 50) {
      if (table.isTournament()) {
        matchList.add(new MatchView(table));
      }
 else {
        matchList.add(new MatchView(table.getMatch()));
      }
    }
 else {
      if (table.isTournament()) {
        TournamentManager.getInstance().removeTournament(table.getTournament().getId());
      }
      this.removeTable(table.getId());
    }
  }
  tableView=tableList;
  matchView=matchList;
  List<UsersView> users=new ArrayList<>();
  for (  User user : UserManager.getInstance().getUsers()) {
    try {
      users.add(new UsersView(user.getName(),user.getInfo(),user.getGameInfo(),user.getPingInfo()));
    }
 catch (    Exception ex) {
      logger.fatal("String_Node_Str" + user.getName() + "String_Node_Str"+ ex.toString(),ex);
      users.add(new UsersView(user.getName(),user.getInfo(),"String_Node_Str",user.getPingInfo()));
    }
  }
  Collections.sort(users,new UserNameSorter());
  List<RoomUsersView> roomUserInfo=new ArrayList<>();
  roomUserInfo.add(new RoomUsersView(users,GameManager.getInstance().getNumberActiveGames()));
  roomUsersView=roomUserInfo;
}

Fixed version (ground truth):
private void update(){
  ArrayList<TableView> tableList=new ArrayList<>();
  ArrayList<MatchView> matchList=new ArrayList<>();
  List<Table> allTables=new ArrayList<>(tables.values());
  Collections.sort(allTables,new TableListSorter());
  for (  Table table : allTables) {
    if (table.getState() != TableState.FINISHED) {
      tableList.add(new TableView(table));
    }
 else     if (matchList.size() < 50) {
      if (table.isTournament()) {
        matchList.add(new MatchView(table));
      }
 else {
        matchList.add(new MatchView(table));
      }
    }
 else {
      if (table.isTournament()) {
        TournamentManager.getInstance().removeTournament(table.getTournament().getId());
      }
      this.removeTable(table.getId());
    }
  }
  tableView=tableList;
  matchView=matchList;
  List<UsersView> users=new ArrayList<>();
  for (  User user : UserManager.getInstance().getUsers()) {
    try {
      users.add(new UsersView(user.getName(),user.getInfo(),user.getGameInfo(),user.getPingInfo()));
    }
 catch (    Exception ex) {
      logger.fatal("String_Node_Str" + user.getName() + "String_Node_Str"+ ex.toString(),ex);
      users.add(new UsersView(user.getName(),user.getInfo(),"String_Node_Str",user.getPingInfo()));
    }
  }
  Collections.sort(users,new UserNameSorter());
  List<RoomUsersView> roomUserInfo=new ArrayList<>();
  roomUserInfo.add(new RoomUsersView(users,GameManager.getInstance().getNumberActiveGames()));
  roomUsersView=roomUserInfo;
}
Program: 159188
Project: 159188
Buggy source:
@Override public boolean leave(UUID playerId){
  MatchPlayer mPlayer=getPlayer(playerId);
  if (mPlayer != null) {
    if (startedGames == 0) {
      return players.remove(mPlayer);
    }
    mPlayer.setQuit(true);
synchronized (this) {
      this.notifyAll();
    }
    checkIfMatchEnds();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean leave(UUID playerId){
  MatchPlayer mPlayer=getPlayer(playerId);
  if (mPlayer != null) {
    if (!hasStarted()) {
      return players.remove(mPlayer);
    }
    mPlayer.setQuit(true);
synchronized (this) {
      this.notifyAll();
    }
    checkIfMatchEnds();
    return true;
  }
  return false;
}
Program: 159189
Project: 159189
Buggy source:
public MatchImpl(MatchOptions options){
  this.options=options;
  startTime=new Date();
  replayAvailable=false;
  draws=0;
}

Fixed version (ground truth):
public MatchImpl(MatchOptions options){
  this.options=options;
  startTime=null;
  replayAvailable=false;
  draws=0;
}
Program: 159190
Project: 159190
Buggy source:
public boolean isExpired(Date expired){
  if (lastActivity.before(expired)) {
    logger.debug(new StringBuilder(userName).append("String_Node_Str"));
    return true;
  }
  logger.trace(new StringBuilder("String_Node_Str").append(userName).append("String_Node_Str").append(lastActivity).append("String_Node_Str").append(expired).toString());
  return false;
}

Fixed version (ground truth):
public boolean isExpired(Date expired){
  if (lastActivity.before(expired)) {
    logger.debug(userName + "String_Node_Str");
    return true;
  }
  logger.trace(new StringBuilder("String_Node_Str").append(userName).append("String_Node_Str").append(lastActivity).append("String_Node_Str").append(expired).toString());
  return false;
}
Program: 159191
Project: 159191
Buggy source:
@Override public boolean leave(UUID playerId){
  MatchPlayer mPlayer=getPlayer(playerId);
  if (mPlayer != null) {
    if (games.isEmpty()) {
      return players.remove(mPlayer);
    }
    mPlayer.setQuit(true);
synchronized (this) {
      this.notifyAll();
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean leave(UUID playerId){
  MatchPlayer mPlayer=getPlayer(playerId);
  if (mPlayer != null) {
    if (startedGames == 0) {
      return players.remove(mPlayer);
    }
    mPlayer.setQuit(true);
synchronized (this) {
      this.notifyAll();
    }
    checkIfMatchEnds();
    return true;
  }
  return false;
}
Program: 159192
Project: 159192
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player you=game.getPlayer(source.getControllerId());
  if (you == null) {
    return false;
  }
  Permanent arsenalThresher=game.getPermanent(source.getSourceId());
  FilterArtifactCard filter=new FilterArtifactCard();
  filter.add(new AnotherPredicate());
  if (you.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
    Cards cards=new CardsImpl();
    if (you.getHand().count(filter,game) > 0) {
      TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
      if (you.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
        for (        UUID uuid : target.getTargets()) {
          cards.add(you.getHand().get(uuid,game));
        }
        you.revealCards("String_Node_Str",cards,game);
        if (arsenalThresher != null) {
          arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()),game);
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player you=game.getPlayer(source.getControllerId());
  if (you == null) {
    return false;
  }
  Permanent arsenalThresher=game.getPermanent(source.getSourceId());
  FilterArtifactCard filter=new FilterArtifactCard();
  filter.add(new AnotherPredicate());
  if (you.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
    Cards cards=new CardsImpl();
    if (you.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
      if (you.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
        for (        UUID uuid : target.getTargets()) {
          cards.add(you.getHand().get(uuid,game));
        }
        you.revealCards("String_Node_Str",cards,game);
        if (arsenalThresher != null) {
          arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()),game);
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159193
Project: 159193
Buggy source:
public void update(TableView table){
  try {
    if (table != null) {
switch (table.getTableState()) {
case STARTING:
        this.btnStart.setEnabled(true);
      this.btnMoveDown.setEnabled(true);
    this.btnMoveUp.setEnabled(true);
  break;
case WAITING:
this.btnStart.setEnabled(false);
this.btnMoveDown.setEnabled(false);
this.btnMoveUp.setEnabled(false);
break;
default :
closeDialog();
return;
}
int row=this.tableSeats.getSelectedRow();
tableWaitModel.loadData(table);
this.tableSeats.repaint();
this.tableSeats.getSelectionModel().setSelectionInterval(row,row);
}
 else {
closeDialog();
}
}
 catch (Exception ex) {
closeDialog();
}
}

Fixed version (ground truth):
public void update(TableView table){
  try {
    if (table != null) {
switch (table.getTableState()) {
case READY_TO_START:
        this.btnStart.setEnabled(true);
      this.btnMoveDown.setEnabled(true);
    this.btnMoveUp.setEnabled(true);
  break;
case WAITING:
this.btnStart.setEnabled(false);
this.btnMoveDown.setEnabled(false);
this.btnMoveUp.setEnabled(false);
break;
default :
closeDialog();
return;
}
int row=this.tableSeats.getSelectedRow();
tableWaitModel.loadData(table);
this.tableSeats.repaint();
this.tableSeats.getSelectionModel().setSelectionInterval(row,row);
}
 else {
closeDialog();
}
}
 catch (Exception ex) {
closeDialog();
}
}
Program: 159194
Project: 159194
Buggy source:
private void btnStartActionPerformed(java.awt.event.ActionEvent evt){
  if (!isTournament) {
    session.startMatch(roomId,tableId);
  }
 else {
    session.startTournament(roomId,tableId);
  }
  closeDialog();
}

Fixed version (ground truth):
private void btnStartActionPerformed(java.awt.event.ActionEvent evt){
  if (!isTournament) {
    if (session.startMatch(roomId,tableId)) {
      closeDialog();
    }
  }
 else {
    if (session.startTournament(roomId,tableId)) {
      closeDialog();
    }
  }
}
Program: 159195
Project: 159195
Buggy source:
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt){
  try {
    if (session.isTableOwner(roomId,tableId)) {
      session.removeTable(roomId,tableId);
    }
 else {
      session.leaveTable(roomId,tableId);
    }
  }
 catch (  Exception e) {
    logger.error(e);
  }
  closeDialog();
}

Fixed version (ground truth):
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt){
  try {
    if (session.isTableOwner(roomId,tableId)) {
      session.removeTable(roomId,tableId);
    }
 else {
      if (!session.leaveTable(roomId,tableId)) {
        return;
      }
    }
  }
 catch (  Exception e) {
    logger.error(e);
  }
  closeDialog();
}
Program: 159196
Project: 159196
Buggy source:
void startTournament(String sessionId,UUID roomId,UUID tableId) throws MageException ;

Fixed version (ground truth):
boolean startTournament(String sessionId,UUID roomId,UUID tableId) throws MageException ;
Program: 159197
Project: 159197
Buggy source:
void startMatch(String sessionId,UUID roomId,UUID tableId) throws MageException ;

Fixed version (ground truth):
boolean startMatch(String sessionId,UUID roomId,UUID tableId) throws MageException ;
Program: 159198
Project: 159198
Buggy source:
void leaveTable(String sessionId,UUID roomId,UUID tableId) throws MageException ;

Fixed version (ground truth):
boolean leaveTable(String sessionId,UUID roomId,UUID tableId) throws MageException ;
Program: 159199
Project: 159199
Buggy source:
@Override public boolean startTournament(UUID roomId,UUID tableId){
  try {
    if (isConnected()) {
      server.startTournament(sessionId,roomId,tableId);
      return true;
    }
  }
 catch (  MageException ex) {
    handleMageException(ex);
  }
catch (  Throwable t) {
    handleThrowable(t);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean startTournament(UUID roomId,UUID tableId){
  try {
    if (isConnected() && server.startTournament(sessionId,roomId,tableId)) {
      return true;
    }
  }
 catch (  MageException ex) {
    handleMageException(ex);
  }
catch (  Throwable t) {
    handleThrowable(t);
  }
  return false;
}
Program: 159200
Project: 159200
Buggy source:
@Override public boolean startMatch(UUID roomId,UUID tableId){
  try {
    if (isConnected()) {
      server.startMatch(sessionId,roomId,tableId);
      return true;
    }
  }
 catch (  MageException ex) {
    handleMageException(ex);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean startMatch(UUID roomId,UUID tableId){
  try {
    if (isConnected()) {
      return (server.startMatch(sessionId,roomId,tableId));
    }
  }
 catch (  MageException ex) {
    handleMageException(ex);
  }
  return false;
}
Program: 159201
Project: 159201
Buggy source:
@Override public boolean leaveTable(UUID roomId,UUID tableId){
  try {
    if (isConnected()) {
      server.leaveTable(sessionId,roomId,tableId);
      return true;
    }
  }
 catch (  MageException ex) {
    handleMageException(ex);
  }
catch (  Throwable t) {
    handleThrowable(t);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean leaveTable(UUID roomId,UUID tableId){
  try {
    if (isConnected() && server.leaveTable(sessionId,roomId,tableId)) {
      return true;
    }
  }
 catch (  MageException ex) {
    handleMageException(ex);
  }
catch (  Throwable t) {
    handleThrowable(t);
  }
  return false;
}
Program: 159203
Project: 159203
Buggy source:
@Override public void startTournament(final String sessionId,final UUID roomId,final UUID tableId) throws MageException {
  execute("String_Node_Str",sessionId,new Action(){
    @Override public void execute(){
      UUID userId=SessionManager.getInstance().getSession(sessionId).getUserId();
      TableManager.getInstance().startTournament(userId,roomId,tableId);
    }
  }
);
}

Fixed version (ground truth):
@Override public boolean startTournament(final String sessionId,final UUID roomId,final UUID tableId) throws MageException {
  if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
    return false;
  }
  execute("String_Node_Str",sessionId,new Action(){
    @Override public void execute(){
      UUID userId=SessionManager.getInstance().getSession(sessionId).getUserId();
      TableManager.getInstance().startTournament(userId,roomId,tableId);
    }
  }
);
  return true;
}
Program: 159204
Project: 159204
Buggy source:
@Override public void startMatch(final String sessionId,final UUID roomId,final UUID tableId) throws MageException {
  execute("String_Node_Str",sessionId,new Action(){
    @Override public void execute(){
      UUID userId=SessionManager.getInstance().getSession(sessionId).getUserId();
      TableManager.getInstance().startMatch(userId,roomId,tableId);
    }
  }
);
}

Fixed version (ground truth):
@Override public boolean startMatch(final String sessionId,final UUID roomId,final UUID tableId) throws MageException {
  if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
    return false;
  }
  execute("String_Node_Str",sessionId,new Action(){
    @Override public void execute(){
      UUID userId=SessionManager.getInstance().getSession(sessionId).getUserId();
      TableManager.getInstance().startMatch(userId,roomId,tableId);
    }
  }
);
  return true;
}
Program: 159205
Project: 159205
Buggy source:
@Override public void leaveTable(final String sessionId,final UUID roomId,final UUID tableId) throws MageException {
  execute("String_Node_Str",sessionId,new Action(){
    @Override public void execute(){
      UUID userId=SessionManager.getInstance().getSession(sessionId).getUserId();
      GamesRoomManager.getInstance().getRoom(roomId).leaveTable(userId,tableId);
    }
  }
);
}

Fixed version (ground truth):
@Override public boolean leaveTable(final String sessionId,final UUID roomId,final UUID tableId) throws MageException {
  TableState tableState=TableManager.getInstance().getController(tableId).getTableState();
  if (!tableState.equals(TableState.WAITING) && !tableState.equals(TableState.READY_TO_START)) {
    return false;
  }
  execute("String_Node_Str",sessionId,new Action(){
    @Override public void execute(){
      UUID userId=SessionManager.getInstance().getSession(sessionId).getUserId();
      GamesRoomManager.getInstance().getRoom(roomId).leaveTable(userId,tableId);
    }
  }
);
  return true;
}
Program: 159206
Project: 159206
Buggy source:
public void joinChat(UUID chatId,UUID userId){
  if (chatSessions.containsKey(chatId)) {
    chatSessions.get(chatId).join(userId);
  }
 else {
    logger.trace("String_Node_Str" + chatId + "String_Node_Str"+ userId);
  }
}

Fixed version (ground truth):
public void joinChat(UUID chatId,UUID userId){
  ChatSession chatSession=chatSessions.get(chatId);
  if (chatSession != null) {
    chatSession.join(userId);
  }
 else {
    logger.trace("String_Node_Str" + chatId + "String_Node_Str"+ userId);
  }
}
Program: 159207
Project: 159207
Buggy source:
public void destroyChatSession(UUID chatId){
  if (chatId != null && chatSessions.containsKey(chatId)) {
    chatSessions.remove(chatId);
    logger.debug("String_Node_Str" + chatId);
  }
 else {
    logger.trace("String_Node_Str" + chatId);
  }
}

Fixed version (ground truth):
public void destroyChatSession(UUID chatId){
  if (chatId != null) {
    ChatSession chatSession=chatSessions.get(chatId);
    if (chatSession != null) {
synchronized (chatSession) {
        if (chatSessions.containsKey(chatId)) {
          chatSessions.remove(chatId);
          logger.debug("String_Node_Str" + chatId);
        }
 else {
          logger.trace("String_Node_Str" + chatId);
        }
      }
    }
  }
}