Program: 118253
Project: 118253
Buggy source:
private static boolean doExecuteUpdates(final List<UpdateResult> results,final boolean updateAllJobs){
  if (results == null || results.isEmpty()) {
    return false;
  }
  try {
    IWorkspaceRunnable op=new IWorkspaceRunnable(){
      @Override public void run(      IProgressMonitor monitor) throws CoreException {
        monitor.setCanceled(false);
        int size=(results.size() * 2 + 1) * UpdatesConstants.SCALE;
        monitor.beginTask(Messages.getString("String_Node_Str"),size);
        ProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
        Map<String,Set<String>> jobIdToVersion=new HashMap<String,Set<String>>();
        Map<String,Boolean> jobIdClosed=new HashMap<String,Boolean>();
        for (        UpdateResult result : results) {
          String id=result.getObjectId();
          String version=result.getObjectVersion();
          if (id == null) {
            if (result.getJob() != null && result.getJob() instanceof IProcess) {
              IProcess process=(IProcess)result.getJob();
              if (process instanceof IProcess2 && ERepositoryStatus.LOCK_BY_OTHER.equals(factory.getStatus(((IProcess2)process).getProperty().getItem()))) {
                continue;
              }
              id=process.getId();
              version=process.getVersion();
              result.setObjectId(id);
              result.setObjectVersion(version);
            }
 else {
              continue;
            }
          }
          Set<String> versionList;
          if (!jobIdToVersion.containsKey(id)) {
            versionList=new HashSet<String>();
            jobIdToVersion.put(id,versionList);
          }
 else {
            versionList=jobIdToVersion.get(id);
          }
          versionList.add(version);
          jobIdClosed.put(id + "String_Node_Str" + version,result.isFromItem());
        }
        for (        String currentId : jobIdToVersion.keySet()) {
          for (          String version : jobIdToVersion.get(currentId)) {
            IRepositoryViewObject currentObj=null;
            boolean closedItem=jobIdClosed.get(currentId + "String_Node_Str" + version);
            IProcess process=null;
            Item item=null;
            if (closedItem) {
              boolean checkOnlyLastVersion=Boolean.parseBoolean(DesignerPlugin.getDefault().getPreferenceStore().getString("String_Node_Str"));
              try {
                if (checkOnlyLastVersion || version == null) {
                  currentObj=factory.getLastVersion(currentId);
                }
 else {
                  List<IRepositoryViewObject> allVersion=factory.getAllVersion(currentId);
                  for (                  IRepositoryViewObject obj : allVersion) {
                    if (obj.getVersion().equals(version)) {
                      currentObj=obj;
                    }
                  }
                }
              }
 catch (              PersistenceException e) {
                ExceptionHandler.process(e);
              }
              if (currentObj == null) {
                continue;
              }
              item=currentObj.getProperty().getItem();
              IDesignerCoreService designerCoreService=CorePlugin.getDefault().getDesignerCoreService();
              if (item instanceof ProcessItem) {
                process=designerCoreService.getProcessFromProcessItem((ProcessItem)item);
              }
 else               if (item instanceof JobletProcessItem) {
                process=designerCoreService.getProcessFromJobletProcessItem((JobletProcessItem)item);
              }
            }
            for (            UpdateResult result : results) {
              if (!StringUtils.equals(currentId,result.getObjectId())) {
                continue;
              }
              if (closedItem) {
                if (result.getJob() == null) {
                  result.setJob(process);
                }
 else {
                  process=(IProcess)result.getJob();
                }
                IUpdateItemType jobletContextType=UpdateManagerProviderDetector.INSTANCE.getUpdateItemType(UpdateManagerHelper.TYPE_JOBLET_CONTEXT);
                if (process != null && jobletContextType != null && (jobletContextType.equals(result.getUpdateType()))) {
                  if ((result.getParameter() instanceof List) && process.getContextManager() != null) {
                    process.getContextManager().setListContext((List<IContext>)result.getParameter());
                  }
                }
              }
              executeUpdate(result,monitor,updateAllJobs);
              if (closedItem) {
                result.setJob(null);
              }
            }
            boolean isTestContainer=false;
            ITestContainerProviderService testContainerService=null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
              testContainerService=(ITestContainerProviderService)GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
              if (testContainerService != null) {
                isTestContainer=testContainerService.isTestContainerItem(item);
              }
            }
            if (closedItem && process instanceof IProcess2) {
              IProcess2 process2=(IProcess2)process;
              ProcessType processType;
              try {
                processType=process2.saveXmlFile(false);
                if (isTestContainer) {
                  testContainerService.setTestContainerProcess(processType,item);
                }
 else                 if (item instanceof JobletProcessItem) {
                  ((JobletProcessItem)item).setJobletProcess((JobletProcess)processType);
                }
 else {
                  ((ProcessItem)item).setProcess(processType);
                }
                factory.save(item);
              }
 catch (              IOException e) {
                ExceptionHandler.process(e);
              }
catch (              PersistenceException e) {
                ExceptionHandler.process(e);
              }
            }
            if (closedItem && !ERepositoryStatus.LOCK_BY_USER.equals(factory.getStatus(item))) {
              try {
                factory.unloadResources(item.getProperty());
              }
 catch (              PersistenceException e) {
                ExceptionHandler.process(e);
              }
            }
          }
        }
        UpdateManagerProviderDetector.INSTANCE.postUpdate(results);
        upadateJobletReferenceInfor();
        Display.getDefault().asyncExec(new Runnable(){
          @Override public void run(){
            refreshRelatedViewers(results);
            checkandRefreshProcess(results);
          }
        }
);
        monitor.worked(1 * UpdatesConstants.SCALE);
        monitor.done();
      }
    }
;
    IRunnableWithProgress iRunnableWithProgress=new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        IWorkspace workspace=ResourcesPlugin.getWorkspace();
        try {
          ISchedulingRule schedulingRule=workspace.getRoot();
          workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
        }
 catch (        CoreException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
;
    try {
      new ProgressMonitorDialog(null).run(true,false,iRunnableWithProgress);
    }
 catch (    InvocationTargetException e) {
      ExceptionHandler.process(e);
    }
catch (    InterruptedException e) {
    }
    return !results.isEmpty();
  }
  finally {
    results.clear();
  }
}

Fixed version (ground truth):
private static boolean doExecuteUpdates(final List<UpdateResult> results,final boolean updateAllJobs){
  if (results == null || results.isEmpty()) {
    return false;
  }
  try {
    IWorkspaceRunnable op=new IWorkspaceRunnable(){
      @Override public void run(      IProgressMonitor monitor) throws CoreException {
        monitor.setCanceled(false);
        int size=(results.size() * 2 + 1) * UpdatesConstants.SCALE;
        monitor.beginTask(Messages.getString("String_Node_Str"),size);
        ProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
        Map<String,Set<String>> jobIdToVersion=new HashMap<String,Set<String>>();
        Map<String,Boolean> jobIdClosed=new HashMap<String,Boolean>();
        for (        UpdateResult result : results) {
          String id=result.getObjectId();
          String version=result.getObjectVersion();
          if (id == null) {
            if (result.getJob() != null && result.getJob() instanceof IProcess) {
              IProcess process=(IProcess)result.getJob();
              if (process instanceof IProcess2 && ERepositoryStatus.LOCK_BY_OTHER.equals(factory.getStatus(((IProcess2)process).getProperty().getItem()))) {
                continue;
              }
              id=process.getId();
              version=process.getVersion();
              result.setObjectId(id);
              result.setObjectVersion(version);
            }
 else {
              continue;
            }
          }
          Set<String> versionList;
          if (!jobIdToVersion.containsKey(id)) {
            versionList=new HashSet<String>();
            jobIdToVersion.put(id,versionList);
          }
 else {
            versionList=jobIdToVersion.get(id);
          }
          versionList.add(version);
          jobIdClosed.put(id + "String_Node_Str" + version,result.isFromItem());
        }
        for (        String currentId : jobIdToVersion.keySet()) {
          for (          String version : jobIdToVersion.get(currentId)) {
            IRepositoryViewObject currentObj=null;
            boolean closedItem=jobIdClosed.get(currentId + "String_Node_Str" + version);
            IProcess process=null;
            Item item=null;
            if (closedItem) {
              boolean checkOnlyLastVersion=Boolean.parseBoolean(DesignerPlugin.getDefault().getPreferenceStore().getString("String_Node_Str"));
              try {
                if (checkOnlyLastVersion || version == null) {
                  currentObj=factory.getLastVersion(currentId);
                }
 else {
                  List<IRepositoryViewObject> allVersion=factory.getAllVersion(currentId);
                  for (                  IRepositoryViewObject obj : allVersion) {
                    if (obj.getVersion().equals(version)) {
                      currentObj=obj;
                    }
                  }
                }
              }
 catch (              PersistenceException e) {
                ExceptionHandler.process(e);
              }
              if (currentObj == null) {
                continue;
              }
              item=currentObj.getProperty().getItem();
              IDesignerCoreService designerCoreService=CorePlugin.getDefault().getDesignerCoreService();
              if (item instanceof ProcessItem) {
                process=designerCoreService.getProcessFromProcessItem((ProcessItem)item);
              }
 else               if (item instanceof JobletProcessItem) {
                process=designerCoreService.getProcessFromJobletProcessItem((JobletProcessItem)item);
              }
            }
            for (            UpdateResult result : results) {
              if (!StringUtils.equals(currentId,result.getObjectId())) {
                continue;
              }
              if (closedItem) {
                if (result.getJob() == null) {
                  result.setJob(process);
                }
 else {
                  process=(IProcess)result.getJob();
                }
                IUpdateItemType jobletContextType=UpdateManagerProviderDetector.INSTANCE.getUpdateItemType(UpdateManagerHelper.TYPE_JOBLET_CONTEXT);
                if (process != null && jobletContextType != null && (jobletContextType.equals(result.getUpdateType()))) {
                  if ((result.getParameter() instanceof List) && process.getContextManager() != null) {
                    process.getContextManager().setListContext((List<IContext>)result.getParameter());
                  }
                }
              }
              executeUpdate(result,monitor,updateAllJobs);
              if (closedItem) {
                result.setJob(null);
              }
            }
            boolean isTestContainer=false;
            ITestContainerProviderService testContainerService=null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
              testContainerService=(ITestContainerProviderService)GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
              if (testContainerService != null) {
                isTestContainer=testContainerService.isTestContainerItem(item);
              }
            }
            if (closedItem && process instanceof IProcess2) {
              IProcess2 process2=(IProcess2)process;
              ProcessType processType;
              try {
                processType=process2.saveXmlFile(false);
                if (isTestContainer) {
                  testContainerService.setTestContainerProcess(processType,item);
                }
 else                 if (item instanceof JobletProcessItem) {
                  ((JobletProcessItem)item).setJobletProcess((JobletProcess)processType);
                }
 else {
                  ((ProcessItem)item).setProcess(processType);
                }
                factory.save(item);
              }
 catch (              IOException e) {
                ExceptionHandler.process(e);
              }
catch (              PersistenceException e) {
                ExceptionHandler.process(e);
              }
            }
            if (closedItem && !ERepositoryStatus.LOCK_BY_USER.equals(factory.getStatus(item))) {
              try {
                factory.unloadResources(item.getProperty());
              }
 catch (              PersistenceException e) {
                ExceptionHandler.process(e);
              }
            }
          }
        }
        UpdateManagerProviderDetector.INSTANCE.postUpdate(results);
        upadateJobletReferenceInfor();
        Display.getDefault().asyncExec(new Runnable(){
          @Override public void run(){
            refreshRelatedViewers(results);
            checkandRefreshProcess(results);
          }
        }
);
        monitor.worked(1 * UpdatesConstants.SCALE);
        monitor.done();
      }
    }
;
    IRunnableWithProgress iRunnableWithProgress=new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        IWorkspace workspace=ResourcesPlugin.getWorkspace();
        try {
          ISchedulingRule schedulingRule=workspace.getRoot();
          workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
        }
 catch (        CoreException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
;
    try {
      new ProgressMonitorDialog(null).run(true,true,iRunnableWithProgress);
    }
 catch (    InvocationTargetException e) {
      ExceptionHandler.process(e);
    }
catch (    InterruptedException e) {
    }
    return !results.isEmpty();
  }
  finally {
    results.clear();
  }
}