Program: 128642
Project: 128642
Buggy source:
/** 
 * ggu Comment method "checkJobItemsForUpdate".
 * @param types - need update types of jobs.
 * @param sourceIdMap - map old source id to new one.
 * @param sourceItem - modified repository item.
 * @return
 */
private List<UpdateResult> checkJobItemsForUpdate(IProgressMonitor parentMonitor,final Set<EUpdateItemType> types,final boolean onlySimpleShow) throws InterruptedException {
  if (types == null || types.isEmpty()) {
    return null;
  }
  final List<IEditorReference> list=new ArrayList<IEditorReference>();
  Display.getDefault().syncExec(new Runnable(){
    public void run(){
      IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
      list.addAll(Arrays.asList(reference));
    }
  }
);
  List<IProcess2> openedProcessList=CoreRuntimePlugin.getInstance().getDesignerCoreService().getOpenedProcess(getEditors());
  try {
    List<UpdateResult> resultList=new ArrayList<UpdateResult>();
    int size=openedProcessList.size();
    IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    MultiKeyMap openProcessMap=createOpenProcessMap(openedProcessList);
    if (isItemIndexChecked() && parameter != null && relations != null) {
      size=size + relations.size();
      parentMonitor.beginTask(Messages.getString("String_Node_Str"),size);
      parentMonitor.setTaskName(Messages.getString("String_Node_Str"));
      for (int i=0; i < relations.size(); i++) {
        RelationshipItemBuilder.Relation relation=relations.get(i);
        IRepositoryViewObject relatedObj=factory.getLastVersion(relation.getId());
        if (relatedObj == null) {
          continue;
        }
        List<IRepositoryViewObject> allVersionList=new ArrayList<IRepositoryViewObject>();
        if (!onlyOpeningJob) {
          boolean checkOnlyLastVersion=Boolean.parseBoolean(CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStore("String_Node_Str"));
          allVersionList=new ArrayList<IRepositoryViewObject>();
          if (!checkOnlyLastVersion) {
            List<IRepositoryViewObject> allVersion=factory.getAllVersion(relatedObj.getId());
            for (            IRepositoryViewObject object : allVersion) {
              if (factory.getStatus(object) != ERepositoryStatus.LOCK_BY_OTHER) {
                allVersionList.add(object);
              }
            }
          }
 else {
            IRepositoryViewObject lastVersion=relatedObj;
            ERepositoryStatus status=factory.getStatus(lastVersion);
            if (status != ERepositoryStatus.LOCK_BY_OTHER) {
              allVersionList.add(lastVersion);
            }
          }
          checkMonitorCanceled(parentMonitor);
          int index=0;
          for (          IRepositoryViewObject repositoryObj : allVersionList) {
            checkMonitorCanceled(parentMonitor);
            Item item=repositoryObj.getProperty().getItem();
            if (isOpenedItem(item,openProcessMap)) {
              continue;
            }
            parentMonitor.subTask(getUpdateJobInfor(repositoryObj.getProperty()));
            List<UpdateResult> updatesNeededFromItems=getUpdatesNeededFromItems(parentMonitor,item,types,onlySimpleShow);
            if (updatesNeededFromItems != null && !updatesNeededFromItems.isEmpty()) {
              resultList.addAll(updatesNeededFromItems);
            }
            index++;
            if (!ERepositoryStatus.LOCK_BY_USER.equals(factory.getStatus(item))) {
              if (repositoryObj instanceof RepositoryObject) {
                ((RepositoryObject)repositoryObj).unload();
              }
            }
          }
          parentMonitor.worked(1);
        }
      }
    }
 else {
      parentMonitor.beginTask(Messages.getString("String_Node_Str"),size);
      parentMonitor.setTaskName(Messages.getString("String_Node_Str"));
    }
    for (    IProcess2 process : openedProcessList) {
      checkMonitorCanceled(parentMonitor);
      parentMonitor.subTask(getUpdateJobInfor(process.getProperty()));
      List<UpdateResult> resultFromProcess=getResultFromProcess(process,types,onlySimpleShow);
      if (resultFromProcess != null) {
        resultList.addAll(resultFromProcess);
      }
      parentMonitor.worked(1);
    }
    if (isDetectAndUpdate) {
      resultList=updateAllProcess(parentMonitor,resultList,openedProcessList,types,onlySimpleShow);
    }
    if (!onlyOpeningJob) {
      List<UpdateResult> templateSetUpdate=checkSettingInJobTemplateWizard();
      if (templateSetUpdate != null) {
        resultList.addAll(templateSetUpdate);
      }
    }
    parentMonitor.done();
    return resultList;
  }
 catch (  PersistenceException e) {
  }
  return null;
}

Fixed version (ground truth):
/** 
 * ggu Comment method "checkJobItemsForUpdate".
 * @param types - need update types of jobs.
 * @param sourceIdMap - map old source id to new one.
 * @param sourceItem - modified repository item.
 * @return
 */
private List<UpdateResult> checkJobItemsForUpdate(IProgressMonitor parentMonitor,final Set<EUpdateItemType> types,final boolean onlySimpleShow) throws InterruptedException {
  if (types == null || types.isEmpty()) {
    return null;
  }
  final List<IEditorReference> list=new ArrayList<IEditorReference>();
  Display.getDefault().syncExec(new Runnable(){
    @Override public void run(){
      IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
      list.addAll(Arrays.asList(reference));
    }
  }
);
  List<IProcess2> openedProcessList=CoreRuntimePlugin.getInstance().getDesignerCoreService().getOpenedProcess(getEditors());
  try {
    List<UpdateResult> resultList=new ArrayList<UpdateResult>();
    int size=openedProcessList.size();
    IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    MultiKeyMap openProcessMap=createOpenProcessMap(openedProcessList);
    if (isItemIndexChecked() && parameter != null && relations != null) {
      size=size + relations.size();
      parentMonitor.beginTask(Messages.getString("String_Node_Str"),size);
      parentMonitor.setTaskName(Messages.getString("String_Node_Str"));
      for (int i=0; i < relations.size(); i++) {
        RelationshipItemBuilder.Relation relation=relations.get(i);
        IRepositoryViewObject relatedObj=factory.getLastVersion(relation.getId());
        if (relatedObj == null) {
          continue;
        }
        List<IRepositoryViewObject> allVersionList=new ArrayList<IRepositoryViewObject>();
        if (!onlyOpeningJob) {
          boolean checkOnlyLastVersion=Boolean.parseBoolean(CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStore("String_Node_Str"));
          allVersionList=new ArrayList<IRepositoryViewObject>();
          if (!checkOnlyLastVersion) {
            List<IRepositoryViewObject> allVersion=factory.getAllVersion(relatedObj.getId());
            for (            IRepositoryViewObject object : allVersion) {
              if (factory.getStatus(object) != ERepositoryStatus.LOCK_BY_OTHER) {
                allVersionList.add(object);
              }
            }
          }
 else {
            IRepositoryViewObject lastVersion=relatedObj;
            ERepositoryStatus status=factory.getStatus(lastVersion);
            if (status != ERepositoryStatus.LOCK_BY_OTHER) {
              allVersionList.add(lastVersion);
            }
          }
          checkMonitorCanceled(parentMonitor);
          int index=0;
          for (          IRepositoryViewObject repositoryObj : allVersionList) {
            checkMonitorCanceled(parentMonitor);
            Item item=repositoryObj.getProperty().getItem();
            if (isOpenedItem(item,openProcessMap)) {
              continue;
            }
            parentMonitor.subTask(getUpdateJobInfor(repositoryObj.getProperty()));
            List<UpdateResult> updatesNeededFromItems=getUpdatesNeededFromItems(parentMonitor,item,types,onlySimpleShow);
            if (updatesNeededFromItems != null && !updatesNeededFromItems.isEmpty()) {
              resultList.addAll(updatesNeededFromItems);
            }
            index++;
            if (!ERepositoryStatus.LOCK_BY_USER.equals(factory.getStatus(item))) {
              if (repositoryObj instanceof RepositoryObject) {
                ((RepositoryObject)repositoryObj).unload();
              }
            }
          }
          parentMonitor.worked(1);
        }
      }
    }
 else {
      parentMonitor.beginTask(Messages.getString("String_Node_Str"),size);
      parentMonitor.setTaskName(Messages.getString("String_Node_Str"));
    }
    for (    IProcess2 process : openedProcessList) {
      checkMonitorCanceled(parentMonitor);
      parentMonitor.subTask(getUpdateJobInfor(process.getProperty()));
      List<UpdateResult> resultFromProcess=getResultFromProcess(process,types,onlySimpleShow);
      if (resultFromProcess != null) {
        resultList.addAll(resultFromProcess);
      }
      parentMonitor.worked(1);
    }
    if (isDetectAndUpdate) {
      resultList=updateAllProcess(parentMonitor,resultList,openedProcessList,types,onlySimpleShow);
    }
    if (!onlyOpeningJob) {
      List<UpdateResult> templateSetUpdate=checkSettingInJobTemplateWizard();
      if (templateSetUpdate != null) {
        resultList.addAll(templateSetUpdate);
      }
    }
    parentMonitor.done();
    return resultList;
  }
 catch (  PersistenceException e) {
  }
  return null;
}