Program: 95750
Project: 95750
Buggy source:
/** 
 * This method executes the given Test Suite
 * @param testSuite the TestSuitePO that will be tested
 * @param locale Locale
 * @param autoScreenshot whether screenshots should be automatically taken in case of test execution errors
 * @param autId The ID of the Running AUT on which the test will take place.
 * @param externalVars a map of externally set variables; may be <code>null</code>
 * @param summary The Test Result Summary for the executed test.  Must not be <code>null</code>.
 * @param monitor the monitor to use
 * @param noRunOptMode The value of no-run option argument if it was specified, null otherwise
 */
public void executeTestSuite(ITestSuitePO testSuite,Locale locale,AutIdentifier autId,boolean autoScreenshot,Map<String,String> externalVars,ITestResultSummaryPO summary,final IProgressMonitor monitor,String noRunOptMode){
  m_stopped=false;
  m_autoScreenshot=autoScreenshot;
  setPaused(false);
  Validate.notNull(testSuite,Messages.TestsuiteMustNotBeNull);
  m_executionLanguage=locale;
  monitor.subTask(NLS.bind(Messages.PreparingTestSuiteExecution,testSuite.getName()));
  m_externalTestDataBP.clearExternalData();
  if (TestExecution.shouldExecutionStop(noRunOptMode,TestExecutionConstants.runSteps.PTE)) {
    monitor.setCanceled(true);
    return;
  }
  try {
    if (AUTConnection.getInstance().connectToAut(autId,new SubProgressMonitor(monitor,0))) {
      if (TestExecution.shouldExecutionStop(noRunOptMode,TestExecutionConstants.runSteps.CA)) {
        endTestExecution();
        return;
      }
      summary.setAutHostname(AUTConnection.getInstance().getCommunicator().getConnection().getAddress().getCanonicalHostName());
      summary.setAutAgentName(AutAgentConnection.getInstance().getCommunicator().getHostName());
      monitor.subTask(Messages.StartingTestSuite_resolvingPredefinedVariables);
      m_varStore.storeEnvironmentVariables();
      storePredefinedVariables(m_varStore,testSuite);
      storeExternallyDefinedVariables(m_varStore,externalVars);
      if (TestExecution.shouldExecutionStop(noRunOptMode,TestExecutionConstants.runSteps.RPV)) {
        endTestExecution();
        return;
      }
      startTestSuite(testSuite,locale,monitor,noRunOptMode);
      final AtomicBoolean testSuiteFinished=new AtomicBoolean();
      ClientTest.instance().addTestExecutionEventListener(new ITestExecutionEventListener(){
        public void endTestExecution(){
          try {
            AUTConnection.getInstance().close();
          }
 catch (          ConnectionException e) {
          }
          ClientTest.instance().removeTestExecutionEventListener(this);
          testSuiteFinished.set(true);
        }
        public void stateChanged(        TestExecutionEvent event){
        }
      }
);
      while (!testSuiteFinished.get()) {
        TimeUtil.delay(250);
      }
    }
 else {
      handleNoConnectionToAUT(testSuite,autId);
    }
  }
 catch (  ConnectionException e) {
    LOG.error(Messages.UnableToConnectToAUT + StringConstants.DOT,e);
  }
}

Fixed version (ground truth):
/** 
 * This method executes the given Test Suite
 * @param testSuite the TestSuitePO that will be tested
 * @param locale Locale
 * @param autoScreenshot whether screenshots should be automatically taken in case of test execution errors
 * @param autId The ID of the Running AUT on which the test will take place.
 * @param externalVars a map of externally set variables; may be <code>null</code>
 * @param summary The Test Result Summary for the executed test.  Must not be <code>null</code>.
 * @param monitor the monitor to use
 * @param noRunOptMode The value of no-run option argument if it was specified, null otherwise
 */
public void executeTestSuite(ITestSuitePO testSuite,Locale locale,AutIdentifier autId,boolean autoScreenshot,Map<String,String> externalVars,ITestResultSummaryPO summary,final IProgressMonitor monitor,String noRunOptMode){
  m_stopped=false;
  m_autoScreenshot=autoScreenshot;
  setPaused(false);
  Validate.notNull(testSuite,Messages.TestsuiteMustNotBeNull);
  m_executionLanguage=locale;
  monitor.subTask(NLS.bind(Messages.PreparingTestSuiteExecution,testSuite.getName()));
  m_externalTestDataBP.clearExternalData();
  if (TestExecution.shouldExecutionStop(noRunOptMode,TestExecutionConstants.RunSteps.PTE)) {
    monitor.setCanceled(true);
    return;
  }
  try {
    if (AUTConnection.getInstance().connectToAut(autId,new SubProgressMonitor(monitor,0))) {
      if (TestExecution.shouldExecutionStop(noRunOptMode,TestExecutionConstants.RunSteps.CA)) {
        endTestExecution();
        return;
      }
      summary.setAutHostname(AUTConnection.getInstance().getCommunicator().getConnection().getAddress().getCanonicalHostName());
      summary.setAutAgentName(AutAgentConnection.getInstance().getCommunicator().getHostName());
      monitor.subTask(Messages.StartingTestSuite_resolvingPredefinedVariables);
      m_varStore.storeEnvironmentVariables();
      storePredefinedVariables(m_varStore,testSuite);
      storeExternallyDefinedVariables(m_varStore,externalVars);
      if (TestExecution.shouldExecutionStop(noRunOptMode,TestExecutionConstants.RunSteps.RPV)) {
        endTestExecution();
        return;
      }
      startTestSuite(testSuite,locale,monitor,noRunOptMode);
      final AtomicBoolean testSuiteFinished=new AtomicBoolean();
      ClientTest.instance().addTestExecutionEventListener(new ITestExecutionEventListener(){
        public void endTestExecution(){
          try {
            AUTConnection.getInstance().close();
          }
 catch (          ConnectionException e) {
          }
          ClientTest.instance().removeTestExecutionEventListener(this);
          testSuiteFinished.set(true);
        }
        public void stateChanged(        TestExecutionEvent event){
        }
      }
);
      while (!testSuiteFinished.get()) {
        TimeUtil.delay(250);
      }
    }
 else {
      handleNoConnectionToAUT(testSuite,autId);
    }
  }
 catch (  ConnectionException e) {
    LOG.error(Messages.UnableToConnectToAUT + StringConstants.DOT,e);
  }
}