Program: 119487
Project: 119487
Buggy source:
/** 
 * Launch the process.
 */
public void exec(final Shell shell){
  if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
    org.talend.designer.core.ui.editor.process.Process prs=(org.talend.designer.core.ui.editor.process.Process)process;
    prs.checkDifferenceWithRepository();
  }
  checkTraces();
  if (ProcessContextComposite.promptConfirmLauch(shell,getSelectedContext(),process)) {
    if (getSelectedTargetExecutionConfig() == null || !getSelectedTargetExecutionConfig().isRemote()) {
      IPreferenceStore preferenceStore=RunProcessPlugin.getDefault().getPreferenceStore();
      int num=preferenceStore.getInt(RunProcessTokenCollector.TOS_COUNT_RUNS.getPrefKey());
      preferenceStore.setValue(RunProcessTokenCollector.TOS_COUNT_RUNS.getPrefKey(),num + 1);
    }
    ClearPerformanceAction clearPerfAction=new ClearPerformanceAction();
    clearPerfAction.setProcess(process);
    clearPerfAction.run();
    ClearTraceAction clearTraceAction=new ClearTraceAction();
    clearTraceAction.setProcess(process);
    clearTraceAction.run();
    if (monitorPerf) {
      this.getStatisticsPort();
    }
    final IProcessor processor=getProcessor(process,process.getProperty());
    IProgressService progressService=PlatformUI.getWorkbench().getProgressService();
    try {
      progressService.run(false,true,new IRunnableWithProgress(){
        @Override public void run(        final IProgressMonitor monitor){
          final IProgressMonitor progressMonitor=SubMonitor.convert(monitor);
          progressMonitor.beginTask(Messages.getString("String_Node_Str"),IProgressMonitor.UNKNOWN);
          try {
            testPort();
            if (monitorPerf || monitorTrace) {
              if (traceConnectionsManager != null) {
                traceConnectionsManager.clear();
              }
              traceConnectionsManager=new TraceConnectionsManager(process);
              traceConnectionsManager.init();
            }
            final IContext context=getSelectedContext();
            if (monitorPerf) {
              clearThreads();
              perfMonitor=new PerformanceMonitor();
              new Thread(perfMonitor,"String_Node_Str" + process.getLabel()).start();
              perMonitorList.add(perfMonitor);
            }
            if (monitorTrace) {
              traceMonitor=new TraceMonitor();
              new Thread(traceMonitor,"String_Node_Str" + process.getLabel()).start();
            }
            final String watchParam=RunProcessContext.this.isWatchAllowed() ? WATCH_PARAM : null;
            String level=RunProcessContext.this.getLog4jLevel();
            if (!isUseCustomLevel()) {
              level=null;
            }
 else {
              if (level != null) {
                level=LOG4J_LEVEL_ARG + (level.equals("String_Node_Str") ? "String_Node_Str" : level.toLowerCase());
              }
            }
            final String log4jLevel=level;
            processor.setContext(context);
            ((IEclipseProcessor)processor).setTargetExecutionConfig(getSelectedTargetExecutionConfig());
            ProcessorUtilities.generateCode(processor,process,context,getStatisticsPort() != IProcessor.NO_STATISTICS,getTracesPort() != IProcessor.NO_TRACES && hasConnectionTrace(),true,progressMonitor);
            final boolean[] refreshUiAndWait=new boolean[1];
            refreshUiAndWait[0]=true;
            final Display display=shell.getDisplay();
            new Thread(new Runnable(){
              @Override public void run(){
                display.syncExec(new Runnable(){
                  @Override public void run(){
                    try {
                      startingMessageWritten=false;
                      if (!JobErrorsChecker.hasErrors(shell)) {
                        ps=processor.run(getStatisticsPort(),getTracesPort(),watchParam,log4jLevel,progressMonitor,processMessageManager);
                      }
                      if (ps != null && !progressMonitor.isCanceled()) {
                        setRunning(true);
                        psMonitor=createProcessMonitor(ps);
                        startingMessageWritten=true;
                        final String startingPattern=Messages.getString("String_Node_Str");
                        MessageFormat mf=new MessageFormat(startingPattern);
                        String welcomeMsg=mf.format(new Object[]{process.getLabel(),new Date()});
                        processMessageManager.addMessage(new ProcessMessage(MsgType.CORE_OUT,welcomeMsg + "String_Node_Str"));
                        processMonitorThread=new Thread(psMonitor);
                        processMonitorThread.start();
                      }
 else {
                        kill();
                        running=true;
                        setRunning(false);
                      }
                    }
 catch (                    Throwable e) {
                      running=true;
                      Throwable cause=e.getCause();
                      if (cause != null && cause.getClass().equals(InterruptedException.class)) {
                        setRunning(false);
                        addErrorMessage(e);
                      }
 else {
                        ExceptionHandler.process(e);
                        addErrorMessage(e);
                        kill();
                      }
                    }
 finally {
                      refreshUiAndWait[0]=false;
                    }
                  }
                }
);
              }
            }
,"String_Node_Str" + process.getLabel()).start();
            while (refreshUiAndWait[0] && !progressMonitor.isCanceled()) {
              if (!display.readAndDispatch()) {
                display.sleep();
              }
synchronized (this) {
                try {
                  final long waitTime=50;
                  wait(waitTime);
                }
 catch (                InterruptedException e) {
                }
              }
            }
          }
 catch (          Throwable e) {
            running=true;
            ExceptionHandler.process(e);
            addErrorMessage(e);
            kill();
          }
 finally {
            progressMonitor.done();
          }
        }
      }
);
    }
 catch (    InvocationTargetException e1) {
      addErrorMessage(e1);
    }
catch (    InterruptedException e1) {
      addErrorMessage(e1);
    }
  }
 else {
    this.running=true;
    setRunning(false);
  }
}

Fixed version (ground truth):
/** 
 * Launch the process.
 */
public void exec(final Shell shell){
  if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
    org.talend.designer.core.ui.editor.process.Process prs=(org.talend.designer.core.ui.editor.process.Process)process;
    prs.checkDifferenceWithRepository();
  }
  checkTraces();
  if (ProcessContextComposite.promptConfirmLauch(shell,getSelectedContext(),process)) {
    if (getSelectedTargetExecutionConfig() == null || !getSelectedTargetExecutionConfig().isRemote()) {
      IPreferenceStore preferenceStore=RunProcessPlugin.getDefault().getPreferenceStore();
      int num=preferenceStore.getInt(RunProcessTokenCollector.TOS_COUNT_RUNS.getPrefKey());
      preferenceStore.setValue(RunProcessTokenCollector.TOS_COUNT_RUNS.getPrefKey(),num + 1);
    }
    ClearPerformanceAction clearPerfAction=new ClearPerformanceAction();
    clearPerfAction.setProcess(process);
    clearPerfAction.run();
    ClearTraceAction clearTraceAction=new ClearTraceAction();
    clearTraceAction.setProcess(process);
    clearTraceAction.run();
    if (monitorPerf) {
      this.getStatisticsPort();
    }
    final IProcessor processor=getProcessor(process,process.getProperty());
    IProgressService progressService=PlatformUI.getWorkbench().getProgressService();
    try {
      progressService.run(false,true,new IRunnableWithProgress(){
        @Override public void run(        final IProgressMonitor monitor){
          final IProgressMonitor progressMonitor=new EventLoopProgressMonitor(monitor);
          progressMonitor.beginTask(Messages.getString("String_Node_Str"),IProgressMonitor.UNKNOWN);
          try {
            testPort();
            if (monitorPerf || monitorTrace) {
              if (traceConnectionsManager != null) {
                traceConnectionsManager.clear();
              }
              traceConnectionsManager=new TraceConnectionsManager(process);
              traceConnectionsManager.init();
            }
            final IContext context=getSelectedContext();
            if (monitorPerf) {
              clearThreads();
              perfMonitor=new PerformanceMonitor();
              new Thread(perfMonitor,"String_Node_Str" + process.getLabel()).start();
              perMonitorList.add(perfMonitor);
            }
            if (monitorTrace) {
              traceMonitor=new TraceMonitor();
              new Thread(traceMonitor,"String_Node_Str" + process.getLabel()).start();
            }
            final String watchParam=RunProcessContext.this.isWatchAllowed() ? WATCH_PARAM : null;
            String level=RunProcessContext.this.getLog4jLevel();
            if (!isUseCustomLevel()) {
              level=null;
            }
 else {
              if (level != null) {
                level=LOG4J_LEVEL_ARG + (level.equals("String_Node_Str") ? "String_Node_Str" : level.toLowerCase());
              }
            }
            final String log4jLevel=level;
            processor.setContext(context);
            ((IEclipseProcessor)processor).setTargetExecutionConfig(getSelectedTargetExecutionConfig());
            ProcessorUtilities.generateCode(processor,process,context,getStatisticsPort() != IProcessor.NO_STATISTICS,getTracesPort() != IProcessor.NO_TRACES && hasConnectionTrace(),true,progressMonitor);
            final boolean[] refreshUiAndWait=new boolean[1];
            refreshUiAndWait[0]=true;
            final Display display=shell.getDisplay();
            new Thread(new Runnable(){
              @Override public void run(){
                display.syncExec(new Runnable(){
                  @Override public void run(){
                    try {
                      startingMessageWritten=false;
                      if (!JobErrorsChecker.hasErrors(shell)) {
                        ps=processor.run(getStatisticsPort(),getTracesPort(),watchParam,log4jLevel,progressMonitor,processMessageManager);
                      }
                      if (ps != null && !progressMonitor.isCanceled()) {
                        setRunning(true);
                        psMonitor=createProcessMonitor(ps);
                        startingMessageWritten=true;
                        final String startingPattern=Messages.getString("String_Node_Str");
                        MessageFormat mf=new MessageFormat(startingPattern);
                        String welcomeMsg=mf.format(new Object[]{process.getLabel(),new Date()});
                        processMessageManager.addMessage(new ProcessMessage(MsgType.CORE_OUT,welcomeMsg + "String_Node_Str"));
                        processMonitorThread=new Thread(psMonitor);
                        processMonitorThread.start();
                      }
 else {
                        kill();
                        running=true;
                        setRunning(false);
                      }
                    }
 catch (                    Throwable e) {
                      running=true;
                      Throwable cause=e.getCause();
                      if (cause != null && cause.getClass().equals(InterruptedException.class)) {
                        setRunning(false);
                        addErrorMessage(e);
                      }
 else {
                        ExceptionHandler.process(e);
                        addErrorMessage(e);
                        kill();
                      }
                    }
 finally {
                      refreshUiAndWait[0]=false;
                    }
                  }
                }
);
              }
            }
,"String_Node_Str" + process.getLabel()).start();
            while (refreshUiAndWait[0] && !progressMonitor.isCanceled()) {
              if (!display.readAndDispatch()) {
                display.sleep();
              }
synchronized (this) {
                try {
                  final long waitTime=50;
                  wait(waitTime);
                }
 catch (                InterruptedException e) {
                }
              }
            }
          }
 catch (          Throwable e) {
            running=true;
            ExceptionHandler.process(e);
            addErrorMessage(e);
            kill();
          }
 finally {
            progressMonitor.done();
          }
        }
      }
);
    }
 catch (    InvocationTargetException e1) {
      addErrorMessage(e1);
    }
catch (    InterruptedException e1) {
      addErrorMessage(e1);
    }
  }
 else {
    this.running=true;
    setRunning(false);
  }
}