Program: 159125
Project: 159125
Buggy source:
public synchronized void leaveTable(UUID userId){
  if (table == null) {
    logger.error("String_Node_Str" + userId);
    return;
  }
  if (table.isTournament() && tournament == null) {
    logger.error("String_Node_Str" + userId + "String_Node_Str"+ table.getId());
    return;
  }
  if (table != null && this.userId.equals(userId) && (table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.READY_TO_START))) {
    TableManager.getInstance().removeTable(table.getId());
  }
 else {
    UUID playerId=userPlayerMap.get(userId);
    if (playerId != null) {
      if (table.getState() == TableState.WAITING || table.getState() == TableState.READY_TO_START) {
        table.leaveNotStartedTable(playerId);
        if (table.isTournament()) {
          tournament.removePlayer(playerId);
        }
 else {
          match.quitMatch(playerId);
        }
        User user=UserManager.getInstance().getUser(userId);
        if (user != null) {
          ChatManager.getInstance().broadcast(chatId,user.getName(),"String_Node_Str",ChatMessage.MessageColor.BLUE,true,ChatMessage.MessageType.STATUS,ChatMessage.SoundToPlay.PlayerLeft);
          user.removeTable(playerId);
        }
 else {
          logger.debug("String_Node_Str" + userId + "String_Node_Str"+ table.getId());
        }
        userPlayerMap.remove(userId);
      }
 else       if (!table.getState().equals(TableState.FINISHED)) {
        if (table.isTournament()) {
          logger.debug("String_Node_Str" + userId);
          TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(),userId);
          logger.debug("String_Node_Str" + table.getTournament().getId() + "String_Node_Str"+ table.getTournament().getTournamentState()+ "String_Node_Str");
          TournamentManager.getInstance().quit(tournament.getId(),userId);
        }
 else {
          MatchPlayer matchPlayer=match.getPlayer(playerId);
          if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) {
            Game game=match.getGame();
            if (game != null && !game.hasEnded()) {
              Player player=match.getPlayer(playerId).getPlayer();
              if (player != null && player.isInGame()) {
                GameManager.getInstance().quitMatch(game.getId(),userId);
              }
              match.quitMatch(playerId);
            }
 else {
              if (table.getState().equals(TableState.SIDEBOARDING)) {
                if (!matchPlayer.isDoneSideboarding()) {
                  matchPlayer.submitDeck(matchPlayer.getDeck());
                }
              }
              match.quitMatch(playerId);
            }
          }
        }
      }
    }
 else {
      logger.error("String_Node_Str" + userId);
    }
  }
}

Fixed version (ground truth):
public synchronized void leaveTable(UUID userId){
  if (table == null) {
    logger.error("String_Node_Str" + userId);
    return;
  }
  if (table.isTournament() && tournament == null) {
    logger.error("String_Node_Str" + userId + "String_Node_Str"+ table.getId());
    return;
  }
  if (table != null && this.userId != null && this.userId.equals(userId) && (table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.READY_TO_START))) {
    TableManager.getInstance().removeTable(table.getId());
  }
 else {
    UUID playerId=userPlayerMap.get(userId);
    if (playerId != null) {
      if (table.getState() == TableState.WAITING || table.getState() == TableState.READY_TO_START) {
        table.leaveNotStartedTable(playerId);
        if (table.isTournament()) {
          tournament.removePlayer(playerId);
        }
 else {
          match.quitMatch(playerId);
        }
        User user=UserManager.getInstance().getUser(userId);
        if (user != null) {
          ChatManager.getInstance().broadcast(chatId,user.getName(),"String_Node_Str",ChatMessage.MessageColor.BLUE,true,ChatMessage.MessageType.STATUS,ChatMessage.SoundToPlay.PlayerLeft);
          user.removeTable(playerId);
        }
 else {
          logger.debug("String_Node_Str" + userId + "String_Node_Str"+ table.getId());
        }
        userPlayerMap.remove(userId);
      }
 else       if (!table.getState().equals(TableState.FINISHED)) {
        if (table.isTournament()) {
          logger.debug("String_Node_Str" + userId);
          TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(),userId);
          logger.debug("String_Node_Str" + table.getTournament().getId() + "String_Node_Str"+ table.getTournament().getTournamentState()+ "String_Node_Str");
          TournamentManager.getInstance().quit(tournament.getId(),userId);
        }
 else {
          MatchPlayer matchPlayer=match.getPlayer(playerId);
          if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) {
            Game game=match.getGame();
            if (game != null && !game.hasEnded()) {
              Player player=match.getPlayer(playerId).getPlayer();
              if (player != null && player.isInGame()) {
                GameManager.getInstance().quitMatch(game.getId(),userId);
              }
              match.quitMatch(playerId);
            }
 else {
              if (table.getState().equals(TableState.SIDEBOARDING)) {
                if (!matchPlayer.isDoneSideboarding()) {
                  matchPlayer.submitDeck(matchPlayer.getDeck());
                }
              }
              match.quitMatch(playerId);
            }
          }
        }
      }
    }
 else {
      logger.error("String_Node_Str" + userId);
    }
  }
}