Program: 121588
Project: 121588
Buggy source:
private JSONObject collectJobDetails() throws PersistenceException, JSONException {
  JSONObject jObject=new JSONObject();
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  final IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
  int jobsNum=0;
  int componentsNum=0;
  int contextVarsNum=0;
  int businessModelsNum=0;
  int generatedJobDocsNum=0;
  int metadatasNum=0;
  Map<String,Integer> numComponentMap=new HashMap<String,Integer>();
  List<IRepositoryViewObject> all=factory.getAll(currentProject,ERepositoryObjectType.PROCESS);
  jobsNum+=all.size();
  for (  IRepositoryViewObject rvo : all) {
    Item item=rvo.getProperty().getItem();
    if (item instanceof ProcessItem) {
      ProcessType processType=((ProcessItem)item).getProcess();
      componentsNum+=processType.getNode().size();
      for (      NodeType node : (List<NodeType>)processType.getNode()) {
        String componentName=node.getComponentName();
        Integer integer=numComponentMap.get(componentName);
        if (integer == null) {
          numComponentMap.put(componentName,1);
        }
 else {
          numComponentMap.put(componentName,integer + 1);
        }
      }
      EList contexts=processType.getContext();
      if (contexts.size() > 0) {
        ContextType contextType=(ContextType)contexts.get(0);
        contextVarsNum+=contextType.getContextParameter().size();
      }
    }
  }
  businessModelsNum+=factory.getAll(currentProject,ERepositoryObjectType.BUSINESS_PROCESS).size();
  generatedJobDocsNum+=factory.getAll(currentProject,ERepositoryObjectType.JOB_DOC).size();
  for (  DynaEnum type : ERepositoryObjectType.values()) {
    if (type instanceof ERepositoryObjectType) {
      ERepositoryObjectType repType=(ERepositoryObjectType)type;
      String folder=repType.getFolder();
      if (repType.isDIItemType() && repType.isResouce() && folder != null && folder.startsWith(ERepositoryObjectType.METADATA.getFolder())) {
        metadatasNum+=factory.getAll(currentProject,repType).size();
      }
    }
  }
  jObject.put(TOS_COUNT_JOBS.getKey(),jobsNum);
  jObject.put(TOS_COUNT_BUSINESS_MODELS.getKey(),businessModelsNum);
  jObject.put(TOS_COUNT_GENERATED_JOB_DOCS.getKey(),generatedJobDocsNum);
  jObject.put(TOS_COUNT_METADATAS.getKey(),metadatasNum);
  jObject.put(TOS_COUNT_CONTEXT_VARIABLES.getKey(),contextVarsNum);
  jObject.put(TOS_COUNT_COMPONENTS.getKey(),componentsNum);
  jObject.put(TOS_JOB_TOP20_COMPONENTS.getKey(),TokenInforUtil.convertTopComponents(numComponentMap,TOP_USED_COMPONENTS_MAX));
  return jObject;
}

Fixed version (ground truth):
private JSONObject collectJobDetails() throws PersistenceException, JSONException {
  JSONObject jObject=new JSONObject();
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  final IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  int jobsNum=0;
  int componentsNum=0;
  int contextVarsNum=0;
  int businessModelsNum=0;
  int generatedJobDocsNum=0;
  int metadatasNum=0;
  Map<String,Integer> numComponentMap=new HashMap<String,Integer>();
  IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
  List<IProcess2> processes=RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
  Set<String> idsOpened=new HashSet<String>();
  for (  IProcess2 process : processes) {
    idsOpened.add(process.getId());
  }
  List<IRepositoryViewObject> all=factory.getAll(currentProject,ERepositoryObjectType.PROCESS);
  jobsNum+=all.size();
  for (  IRepositoryViewObject rvo : all) {
    Item item=rvo.getProperty().getItem();
    if (item instanceof ProcessItem) {
      ProcessType processType=((ProcessItem)item).getProcess();
      componentsNum+=processType.getNode().size();
      for (      NodeType node : (List<NodeType>)processType.getNode()) {
        String componentName=node.getComponentName();
        Integer integer=numComponentMap.get(componentName);
        if (integer == null) {
          numComponentMap.put(componentName,1);
        }
 else {
          numComponentMap.put(componentName,integer + 1);
        }
      }
      EList contexts=processType.getContext();
      if (contexts.size() > 0) {
        ContextType contextType=(ContextType)contexts.get(0);
        contextVarsNum+=contextType.getContextParameter().size();
      }
    }
    if (factory.getStatus(item) != ERepositoryStatus.LOCK_BY_USER && !idsOpened.contains(item.getProperty().getId())) {
      if (item.getParent() instanceof FolderItem) {
        ((FolderItem)item.getParent()).getChildren().remove(item);
        item.setParent(null);
      }
      item.eResource().unload();
    }
  }
  businessModelsNum+=factory.getAll(currentProject,ERepositoryObjectType.BUSINESS_PROCESS).size();
  generatedJobDocsNum+=factory.getAll(currentProject,ERepositoryObjectType.JOB_DOC).size();
  for (  DynaEnum type : ERepositoryObjectType.values()) {
    if (type instanceof ERepositoryObjectType) {
      ERepositoryObjectType repType=(ERepositoryObjectType)type;
      String folder=repType.getFolder();
      if (repType.isDIItemType() && repType.isResouce() && folder != null && folder.startsWith(ERepositoryObjectType.METADATA.getFolder())) {
        metadatasNum+=factory.getAll(currentProject,repType).size();
      }
    }
  }
  jObject.put(TOS_COUNT_JOBS.getKey(),jobsNum);
  jObject.put(TOS_COUNT_BUSINESS_MODELS.getKey(),businessModelsNum);
  jObject.put(TOS_COUNT_GENERATED_JOB_DOCS.getKey(),generatedJobDocsNum);
  jObject.put(TOS_COUNT_METADATAS.getKey(),metadatasNum);
  jObject.put(TOS_COUNT_CONTEXT_VARIABLES.getKey(),contextVarsNum);
  jObject.put(TOS_COUNT_COMPONENTS.getKey(),componentsNum);
  jObject.put(TOS_JOB_TOP20_COMPONENTS.getKey(),TokenInforUtil.convertTopComponents(numComponentMap,TOP_USED_COMPONENTS_MAX));
  return jObject;
}