Trial trial = experiment.getTrials()[currentTrial];
Trial[] trials = experiment.getTrials(); Trial trial = null; if (currentTrial < trials.length) { trial = trials[currentTrial]; } else { trial = trials[0]; if (log.isWarnEnabled()) log.warn("saveResults: Bug 2071/2. currentTrial=" + currentTrial + ", trials.length=" + trials.length); currentTrial--; }
  private void saveResults() {    if (currentTrial < 0)      return; // nothing to save    String dirname = makeResultDirectory();    if (experiment != null && usingExperiment) {      try {        String myHostName = InetAddress.getLocalHost().getHostName();        URL url = new URL("file", myHostName, dirname);        Trial trial = experiment.getTrials()[currentTrial];        trial.addTrialResult(new TrialResult(runStart, url));      } catch (Exception e) {        if(log.isErrorEnabled()) {          log.error("Exception creating trial results URL: ", e);        }      }    }    Collection values = nodeToNodeInfo.values();    java.util.List contactedAS = new ArrayList();    for (Iterator i = values.iterator(); i.hasNext(); ) {      NodeInfo ni = (NodeInfo)i.next();      RemoteHost remoteAppServer = ni.appServer;      // Ask appServerSupport if this guy is legit?      if (remoteAppServer != null && !contactedAS.contains(remoteAppServer) && appServerSupport.isValidRemoteHost(remoteAppServer)) {	contactedAS.add(remoteAppServer);	RemoteFileSystem remoteFS = null;	try {	  remoteFS = remoteAppServer.getRemoteFileSystem();	} catch (Exception e) {	  final String host = ni.hostName;	  SwingUtilities.invokeLater(new Runnable() {	      public void run() {		JOptionPane.showMessageDialog(CSMARTConsole.this,		      "Cannot save results.  Unable to access filesystem for " + 		      host + ".",		      "Unable to access file system",		      JOptionPane.WARNING_MESSAGE);	      }	    });	  if (log.isErrorEnabled())	    log.error("saveResults failed to get filesystem on " + ni.hostName + ": ", e);	  // Tell appServerSupport to see if the host is legit	  appServerSupport.haveNewNodes();	  continue;	}	copyResultFiles(remoteFS, dirname);      }    }  }