Program: 158077
Project: 158077
Buggy source:
private void btnOkActionPerformed(java.awt.event.ActionEvent evt){
  TournamentTypeView tournamentType=(TournamentTypeView)cbTournamentType.getSelectedItem();
  int numSeats=(Integer)this.spnNumSeats.getValue();
  TournamentOptions tOptions=new TournamentOptions(this.txtName.getText(),"String_Node_Str",numSeats);
  tOptions.setTournamentType(tournamentType.getName());
  tOptions.setPassword(txtPassword.getText());
  tOptions.getPlayerTypes().add(PlayerType.HUMAN);
  tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
  tOptions.setQuitRatio((Integer)spnQuitRatio.getValue());
  for (  TournamentPlayerPanel player : players) {
    tOptions.getPlayerTypes().add((PlayerType)player.getPlayerType().getSelectedItem());
  }
  if (!tournamentType.isElimination()) {
    tOptions.setNumberRounds((Integer)spnNumRounds.getValue());
  }
  if (tournamentType.isDraft()) {
    DraftOptions options=new DraftOptions();
    options.setDraftType("String_Node_Str");
    options.setTiming((TimingOption)this.cbDraftTiming.getSelectedItem());
    tOptions.setLimitedOptions(options);
  }
  if (tOptions.getLimitedOptions() == null) {
    tOptions.setLimitedOptions(new LimitedOptions());
  }
  if (tournamentType.isLimited()) {
    tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
    tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
    if (tournamentType.isCubeBooster()) {
      tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
      if (!(cubeFromDeckFilename.isEmpty())) {
        Deck cubeFromDeck=new Deck();
        try {
          cubeFromDeck=Deck.load(DeckImporterUtil.importDeck(cubeFromDeckFilename),true,true);
        }
 catch (        GameException e1) {
          JOptionPane.showMessageDialog(MageFrame.getDesktop(),e1.getMessage(),"String_Node_Str",JOptionPane.ERROR_MESSAGE);
        }
        if (cubeFromDeck != null) {
          cubeFromDeck.clearLayouts();
          tOptions.getLimitedOptions().setCubeFromDeck(cubeFromDeck);
        }
      }
    }
 else     if (tournamentType.isRandom() || tournamentType.isRichMan()) {
      this.isRandom=tournamentType.isRandom();
      this.isRichMan=tournamentType.isRichMan();
      tOptions.getLimitedOptions().getSetCodes().clear();
      ArrayList<String> selected=randomPackSelector.getSelectedPacks();
      int maxPacks=3 * (players.size() + 1);
      if (tournamentType.isRichMan()) {
        maxPacks=36;
      }
      if (selected.size() > maxPacks) {
        StringBuilder infoString=new StringBuilder("String_Node_Str");
        infoString.append(maxPacks);
        infoString.append("String_Node_Str");
        JOptionPane.showMessageDialog(MageFrame.getDesktop(),infoString,"String_Node_Str",JOptionPane.INFORMATION_MESSAGE);
        Collections.shuffle(selected);
        tOptions.getLimitedOptions().getSetCodes().addAll(selected.subList(0,maxPacks));
      }
 else {
        tOptions.getLimitedOptions().getSetCodes().addAll(selected);
      }
    }
 else {
      for (      JComboBox pack : packs) {
        tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo)pack.getSelectedItem()).getCode());
      }
    }
    tOptions.getMatchOptions().setDeckType("String_Node_Str");
    tOptions.getMatchOptions().setGameType("String_Node_Str");
    tOptions.getMatchOptions().setLimited(true);
  }
 else {
    tOptions.getLimitedOptions().setConstructionTime(0);
    tOptions.getLimitedOptions().setNumberBoosters(0);
    tOptions.getLimitedOptions().setDraftCube(null);
    tOptions.getLimitedOptions().setDraftCubeName("String_Node_Str");
    tOptions.getMatchOptions().setDeckType((String)this.cbDeckType.getSelectedItem());
    tOptions.getMatchOptions().setGameType(((GameTypeView)this.cbGameType.getSelectedItem()).getName());
    tOptions.getMatchOptions().setLimited(false);
  }
  tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit)this.cbTimeLimit.getSelectedItem());
  tOptions.getMatchOptions().setSkillLevel((SkillLevel)this.cbSkillLevel.getSelectedItem());
  tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
  tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
  tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
  tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
  tOptions.getMatchOptions().setRollbackTurnsAllowed(this.chkRollbackTurnsAllowed.isSelected());
  tOptions.getMatchOptions().setRated(this.chkRated.isSelected());
  saveTournamentSettingsToPrefs(tOptions);
  table=SessionHandler.createTournamentTable(roomId,tOptions);
  if (table == null) {
    return;
  }
  if (SessionHandler.joinTournamentTable(roomId,table.getTableId(),this.player1Panel.getPlayerName(),PlayerType.HUMAN,1,DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),tOptions.getPassword())) {
    for (    TournamentPlayerPanel player : players) {
      if (!player.getPlayerType().toString().equals("String_Node_Str")) {
        if (!player.joinTournamentTable(roomId,table.getTableId(),DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
          SessionHandler.removeTable(roomId,table.getTableId());
          table=null;
          return;
        }
      }
    }
    this.hideDialog();
    return;
  }
  JOptionPane.showMessageDialog(MageFrame.getDesktop(),"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
  SessionHandler.removeTable(roomId,table.getTableId());
  table=null;
}

Fixed version (ground truth):
private void btnOkActionPerformed(java.awt.event.ActionEvent evt){
  TournamentTypeView tournamentType=(TournamentTypeView)cbTournamentType.getSelectedItem();
  int numSeats=(Integer)this.spnNumSeats.getValue();
  TournamentOptions tOptions=new TournamentOptions(this.txtName.getText(),"String_Node_Str",numSeats);
  tOptions.setTournamentType(tournamentType.getName());
  tOptions.setPassword(txtPassword.getText());
  tOptions.getPlayerTypes().add(PlayerType.HUMAN);
  tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
  tOptions.setQuitRatio((Integer)spnQuitRatio.getValue());
  for (  TournamentPlayerPanel player : players) {
    tOptions.getPlayerTypes().add((PlayerType)player.getPlayerType().getSelectedItem());
  }
  if (!tournamentType.isElimination()) {
    tOptions.setNumberRounds((Integer)spnNumRounds.getValue());
  }
  if (tournamentType.isDraft()) {
    DraftOptions options=new DraftOptions();
    options.setDraftType("String_Node_Str");
    options.setTiming((TimingOption)this.cbDraftTiming.getSelectedItem());
    tOptions.setLimitedOptions(options);
  }
  if (tOptions.getLimitedOptions() == null) {
    tOptions.setLimitedOptions(new LimitedOptions());
  }
  if (tournamentType.isLimited()) {
    tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
    tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
    if (tournamentType.isCubeBooster()) {
      tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
      if (!(cubeFromDeckFilename.isEmpty())) {
        Deck cubeFromDeck=new Deck();
        try {
          cubeFromDeck=Deck.load(DeckImporterUtil.importDeck(cubeFromDeckFilename),true,true);
        }
 catch (        GameException e1) {
          JOptionPane.showMessageDialog(MageFrame.getDesktop(),e1.getMessage(),"String_Node_Str",JOptionPane.ERROR_MESSAGE);
        }
        if (cubeFromDeck != null) {
          cubeFromDeck.clearLayouts();
          tOptions.getLimitedOptions().setCubeFromDeck(cubeFromDeck);
        }
      }
    }
 else     if (tournamentType.isRandom() || tournamentType.isRichMan()) {
      this.isRandom=tournamentType.isRandom();
      this.isRichMan=tournamentType.isRichMan();
      tOptions.getLimitedOptions().getSetCodes().clear();
      ArrayList<String> selected=randomPackSelector.getSelectedPacks();
      int maxPacks=3 * (players.size() + 1);
      if (tournamentType.isRichMan()) {
        maxPacks=36;
      }
      if (selected.size() > maxPacks) {
        StringBuilder infoString=new StringBuilder("String_Node_Str");
        infoString.append(maxPacks);
        infoString.append("String_Node_Str");
        JOptionPane.showMessageDialog(MageFrame.getDesktop(),infoString,"String_Node_Str",JOptionPane.INFORMATION_MESSAGE);
        Collections.shuffle(selected);
        tOptions.getLimitedOptions().getSetCodes().addAll(selected.subList(0,maxPacks));
      }
 else {
        tOptions.getLimitedOptions().getSetCodes().addAll(selected);
      }
    }
 else {
      for (      JComboBox pack : packs) {
        tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo)pack.getSelectedItem()).getCode());
      }
    }
    tOptions.getMatchOptions().setDeckType("String_Node_Str");
    tOptions.getMatchOptions().setGameType("String_Node_Str");
    tOptions.getMatchOptions().setLimited(true);
  }
 else {
    tOptions.getLimitedOptions().setConstructionTime(0);
    tOptions.getLimitedOptions().setNumberBoosters(0);
    tOptions.getLimitedOptions().setDraftCube(null);
    tOptions.getLimitedOptions().setDraftCubeName("String_Node_Str");
    tOptions.getMatchOptions().setDeckType((String)this.cbDeckType.getSelectedItem());
    tOptions.getMatchOptions().setGameType(((GameTypeView)this.cbGameType.getSelectedItem()).getName());
    tOptions.getMatchOptions().setLimited(false);
  }
  tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit)this.cbTimeLimit.getSelectedItem());
  tOptions.getMatchOptions().setSkillLevel((SkillLevel)this.cbSkillLevel.getSelectedItem());
  tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
  tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
  tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
  tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
  tOptions.getMatchOptions().setRollbackTurnsAllowed(this.chkRollbackTurnsAllowed.isSelected());
  tOptions.getMatchOptions().setRated(this.chkRated.isSelected());
  saveTournamentSettingsToPrefs(tOptions);
  table=SessionHandler.createTournamentTable(roomId,tOptions);
  if (table == null) {
    return;
  }
  if (SessionHandler.joinTournamentTable(roomId,table.getTableId(),this.player1Panel.getPlayerName(),PlayerType.HUMAN,1,DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),tOptions.getPassword())) {
    for (    TournamentPlayerPanel player : players) {
      if (!player.getPlayerType().getSelectedItem().toString().equals("String_Node_Str")) {
        if (!player.joinTournamentTable(roomId,table.getTableId(),DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
          SessionHandler.removeTable(roomId,table.getTableId());
          table=null;
          return;
        }
      }
    }
    this.hideDialog();
    return;
  }
  JOptionPane.showMessageDialog(MageFrame.getDesktop(),"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
  SessionHandler.removeTable(roomId,table.getTableId());
  table=null;
}