Program: 119101
Project: 119101
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);
  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);
  }
}

Fixed version (ground truth):
private static void sortClasspath(Set<ModuleNeeded> jobModuleList,IProcess process) throws CoreException, BusinessException {
  ITalendProcessJavaProject jProject=getTalendJavaProject();
  if (jProject == null) {
    return;
  }
  Set<ModuleNeeded> listModulesReallyNeeded=new HashSet<ModuleNeeded>();
  listModulesReallyNeeded.addAll(jobModuleList);
  Set<ModuleNeeded> optionalJarsOnlyForRoutines=new HashSet<ModuleNeeded>();
  for (  ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
    optionalJarsOnlyForRoutines.add(moduleNeeded);
  }
  optionalJarsOnlyForRoutines.removeAll(listModulesReallyNeeded);
  for (  ModuleNeeded jar : optionalJarsOnlyForRoutines) {
    listModulesReallyNeeded.add(jar);
  }
  addLog4jToModuleList(listModulesReallyNeeded);
  String missingJars=null;
  Set<String> missingJarsForRoutinesOnly=new HashSet<String>();
  Set<String> missingJarsForProcessOnly=new HashSet<String>();
  File libDir=getJavaProjectLibFolder();
  ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
  if ((libDir != null) && (libDir.isDirectory())) {
    Set<String> jarsNeedRetrieve=new HashSet<String>();
    for (    ModuleNeeded moduleNeeded : listModulesReallyNeeded) {
      jarsNeedRetrieve.add(moduleNeeded.getModuleName());
    }
    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);
      repositoryBundleService.retrieve(jarsNeedRetrieve,libDir.getAbsolutePath());
      if (process instanceof IProcess2) {
        ((IProcess2)process).checkProcess();
      }
    }
    for (    File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) {
      jarsNeedRetrieve.remove(externalLib.getName());
    }
    Set<String> jarStringListNeededByProcess=new HashSet<String>();
    for (    ModuleNeeded moduleNeeded : jobModuleList) {
      jarStringListNeededByProcess.add(moduleNeeded.getModuleName());
    }
    for (    String jar : jarsNeedRetrieve) {
      if (ContextParameterUtils.isContainContextParam(jar)) {
        continue;
      }
      if (jobModuleList.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);
  }
  repositoryBundleService.deployModules(listModulesReallyNeeded,null);
}