Program: 119145
Project: 119145
Buggy source:
private static void sortClasspath(Set<String> jobModuleList,IProcess process) throws CoreException, BusinessException {
  ITalendProcessJavaProject jProject=getTalendJavaProject();
  if (jProject == null) {
    return;
  }
  Set<String> listModulesReallyNeeded=ModuleNameExtractor.extractFileName(jobModuleList);
  Set<String> listModulesNeededByProcess=new HashSet<String>();
  if (listModulesReallyNeeded != null && listModulesReallyNeeded.size() > 0) {
    for (    String jobModule : listModulesReallyNeeded) {
      listModulesNeededByProcess.add(jobModule);
    }
  }
  Set<String> optionalJarsOnlyForRoutines=new HashSet<String>();
  if (listModulesReallyNeeded == null) {
    listModulesReallyNeeded=new HashSet<String>();
  }
  for (  ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
    optionalJarsOnlyForRoutines.add(moduleNeeded.getModuleName());
  }
  optionalJarsOnlyForRoutines.removeAll(listModulesReallyNeeded);
  for (  String jar : optionalJarsOnlyForRoutines) {
    listModulesReallyNeeded.add(jar);
  }
  addLog4jToJarList(listModulesReallyNeeded);
  File libDir=getJavaProjectLibFolder();
  if ((libDir != null) && (libDir.isDirectory())) {
    Set<String> jarsNeedRetrieve=new HashSet<String>(listModulesReallyNeeded);
    for (    File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) {
      jarsNeedRetrieve.remove(externalLib.getName());
    }
    if (!jarsNeedRetrieve.isEmpty()) {
      Set<String> originalConexts=new HashSet<String>();
      Iterator<String> iterator=jarsNeedRetrieve.iterator();
      while (iterator.hasNext()) {
        String jarNeedRetrieve=iterator.next();
        if (ContextParameterUtils.isContainContextParam(jarNeedRetrieve) && process instanceof IProcess2) {
          iterator.remove();
          IContext lastRunContext=((IProcess2)process).getLastRunContext();
          if (lastRunContext != null) {
            String contextValue=ContextParameterUtils.parseScriptContextCode(jarNeedRetrieve,lastRunContext);
            if (contextValue != null) {
              originalConexts.add(new File(contextValue).getName());
            }
          }
 else {
            IContextManager contextManager=process.getContextManager();
            if (contextManager != null) {
              String contextValue=ContextParameterUtils.parseScriptContextCode(jarNeedRetrieve,contextManager.getDefaultContext());
              if (contextValue != null) {
                originalConexts.add(new File(contextValue).getName());
              }
            }
          }
        }
      }
      jarsNeedRetrieve.addAll(originalConexts);
      ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
      repositoryBundleService.retrieve(jarsNeedRetrieve,libDir.getAbsolutePath());
      if (process instanceof IProcess2) {
        ((IProcess2)process).checkProcess();
      }
    }
  }
  String missingJars=null;
  Set<String> missingJarsForRoutinesOnly=new HashSet<String>();
  Set<String> missingJarsForProcessOnly=new HashSet<String>();
  for (  String jar : listModulesReallyNeeded) {
    if (ContextParameterUtils.isContainContextParam(jar)) {
      continue;
    }
    if (listModulesNeededByProcess.contains(jar)) {
      missingJarsForProcessOnly.add(jar);
    }
 else {
      missingJarsForRoutinesOnly.add(jar);
    }
    if (missingJars == null) {
      missingJars=Messages.getString("String_Node_Str") + jar;
    }
 else {
      missingJars=missingJars + "String_Node_Str" + jar;
    }
  }
  if (missingJars != null) {
    handleMissingJarsForProcess(missingJarsForRoutinesOnly,missingJarsForProcessOnly,missingJars);
  }
}

Fixed version (ground truth):
private static void sortClasspath(Set<String> jobModuleList,IProcess process) throws CoreException, BusinessException {
  ITalendProcessJavaProject jProject=getTalendJavaProject();
  if (jProject == null) {
    return;
  }
  Set<String> listModulesReallyNeeded=ModuleNameExtractor.extractFileName(jobModuleList);
  Set<String> listModulesNeededByProcess=new HashSet<String>();
  if (listModulesReallyNeeded != null && listModulesReallyNeeded.size() > 0) {
    for (    String jobModule : listModulesReallyNeeded) {
      listModulesNeededByProcess.add(jobModule);
    }
  }
  Set<String> optionalJarsOnlyForRoutines=new HashSet<String>();
  if (listModulesReallyNeeded == null) {
    listModulesReallyNeeded=new HashSet<String>();
  }
  for (  ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
    optionalJarsOnlyForRoutines.add(moduleNeeded.getModuleName());
  }
  optionalJarsOnlyForRoutines.removeAll(listModulesReallyNeeded);
  for (  String jar : optionalJarsOnlyForRoutines) {
    listModulesReallyNeeded.add(jar);
  }
  addLog4jToJarList(listModulesReallyNeeded);
  String missingJars=null;
  Set<String> missingJarsForRoutinesOnly=new HashSet<String>();
  Set<String> missingJarsForProcessOnly=new HashSet<String>();
  File libDir=getJavaProjectLibFolder();
  if ((libDir != null) && (libDir.isDirectory())) {
    Set<String> jarsNeedRetrieve=new HashSet<String>(listModulesReallyNeeded);
    for (    File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) {
      jarsNeedRetrieve.remove(externalLib.getName());
    }
    if (!jarsNeedRetrieve.isEmpty()) {
      Set<String> originalConexts=new HashSet<String>();
      Iterator<String> iterator=jarsNeedRetrieve.iterator();
      while (iterator.hasNext()) {
        String jarNeedRetrieve=iterator.next();
        if (ContextParameterUtils.isContainContextParam(jarNeedRetrieve) && process instanceof IProcess2) {
          iterator.remove();
          IContext lastRunContext=((IProcess2)process).getLastRunContext();
          if (lastRunContext != null) {
            String contextValue=ContextParameterUtils.parseScriptContextCode(jarNeedRetrieve,lastRunContext);
            if (contextValue != null) {
              originalConexts.add(new File(contextValue).getName());
            }
          }
 else {
            IContextManager contextManager=process.getContextManager();
            if (contextManager != null) {
              String contextValue=ContextParameterUtils.parseScriptContextCode(jarNeedRetrieve,contextManager.getDefaultContext());
              if (contextValue != null) {
                originalConexts.add(new File(contextValue).getName());
              }
            }
          }
        }
      }
      jarsNeedRetrieve.addAll(originalConexts);
      ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
      repositoryBundleService.retrieve(jarsNeedRetrieve,libDir.getAbsolutePath());
      if (process instanceof IProcess2) {
        ((IProcess2)process).checkProcess();
      }
    }
    for (    File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) {
      jarsNeedRetrieve.remove(externalLib.getName());
    }
    for (    String jar : jarsNeedRetrieve) {
      if (ContextParameterUtils.isContainContextParam(jar)) {
        continue;
      }
      if (listModulesNeededByProcess.contains(jar)) {
        missingJarsForProcessOnly.add(jar);
      }
 else {
        missingJarsForRoutinesOnly.add(jar);
      }
      if (missingJars == null) {
        missingJars=Messages.getString("String_Node_Str") + jar;
      }
 else {
        missingJars=missingJars + "String_Node_Str" + jar;
      }
    }
  }
  if (missingJars != null) {
    handleMissingJarsForProcess(missingJarsForRoutinesOnly,missingJarsForProcessOnly,missingJars);
  }
}