Program: 118093
Project: 118093
Buggy source:
/** 
 * DOC nrousseau Comment method "collectJobDetails".
 * @param all
 * @param jobDetails
 * @throws JSONException
 */
private void collectJobDetails(List<IRepositoryViewObject> allRvo,JSONObject jobDetails) throws JSONException {
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  IWorkbenchWindow ww=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  IEditorReference[] reference=new IEditorReference[0];
  if (ww != null) {
    IWorkbenchPage page=ww.getActivePage();
    reference=page.getEditorReferences();
  }
  List<IProcess2> processes=RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
  Set<String> idsOpened=new HashSet<String>();
  for (  IProcess2 process : processes) {
    idsOpened.add(process.getId());
  }
  JSONObject components=new JSONObject();
  int contextVarsNum=0;
  int nbComponentsUsed=0;
  for (  IRepositoryViewObject rvo : allRvo) {
    Item item=rvo.getProperty().getItem();
    if (item instanceof ProcessItem) {
      ProcessType processType=((ProcessItem)item).getProcess();
      for (      NodeType node : (List<NodeType>)processType.getNode()) {
        String componentName=node.getComponentName();
        int nbComp=0;
        if (components.has(componentName)) {
          nbComp=components.getInt(componentName);
        }
        components.put(componentName,nbComp + 1);
        nbComponentsUsed++;
      }
      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();
    }
  }
  jobDetails.put("String_Node_Str",components);
  jobDetails.put("String_Node_Str",contextVarsNum);
  jobDetails.put("String_Node_Str",nbComponentsUsed);
}

Fixed version (ground truth):
/** 
 * DOC nrousseau Comment method "collectJobDetails".
 * @param all
 * @param jobDetails
 * @throws JSONException
 */
private void collectJobDetails(List<IRepositoryViewObject> allRvo,JSONObject jobDetails) throws JSONException {
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  IWorkbenchWindow ww=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  IEditorReference[] reference=new IEditorReference[0];
  if (ww != null) {
    IWorkbenchPage page=ww.getActivePage();
    reference=page.getEditorReferences();
  }
  List<IProcess2> processes=RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
  Set<String> idsOpened=new HashSet<String>();
  for (  IProcess2 process : processes) {
    idsOpened.add(process.getId());
  }
  JSONArray components=new JSONArray();
  int contextVarsNum=0;
  int nbComponentsUsed=0;
  for (  IRepositoryViewObject rvo : allRvo) {
    Item item=rvo.getProperty().getItem();
    if (item instanceof ProcessItem) {
      ProcessType processType=((ProcessItem)item).getProcess();
      for (      NodeType node : (List<NodeType>)processType.getNode()) {
        JSONObject component_names=null;
        String componentName=node.getComponentName();
        int nbComp=0;
        for (int i=0; i < components.length(); i++) {
          JSONObject temp=components.getJSONObject(i);
          if (temp.get("String_Node_Str").equals(componentName)) {
            nbComp=temp.getInt("String_Node_Str");
            component_names=temp;
            break;
          }
        }
        if (component_names == null) {
          component_names=new JSONObject();
          components.put(component_names);
        }
        component_names.put("String_Node_Str",componentName);
        component_names.put("String_Node_Str",nbComp + 1);
        nbComponentsUsed++;
      }
      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();
    }
  }
  jobDetails.put("String_Node_Str",components);
  jobDetails.put("String_Node_Str",contextVarsNum);
  jobDetails.put("String_Node_Str",nbComponentsUsed);
}