Program: 119138
Project: 119138
Buggy source:
@Override public ProcessType saveXmlFile(boolean checkJoblet) throws IOException {
  init();
  TalendFileFactory fileFact=TalendFileFactory.eINSTANCE;
  ProcessType processType=createProcessType(fileFact);
  processType.setParameters(fileFact.createParametersType());
  saveProcessElementParameters(processType);
  saveRoutinesDependencies(processType);
  saveAdditionalProperties();
  EList nList=processType.getNode();
  EList cList=processType.getConnection();
  MetadataEmfFactory factory=new MetadataEmfFactory();
  JobletUtil jutil=new JobletUtil();
  for (  Element element : elem) {
    if (element instanceof SubjobContainer) {
      saveSubjob(fileFact,processType,(SubjobContainer)element);
      for (      NodeContainer container : ((SubjobContainer)element).getNodeContainers()) {
        if (container.getNode().isJoblet()) {
          if (checkJoblet) {
            JobletContainer jobletCon=(JobletContainer)container;
            boolean needUpdate=false;
            IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
            if (service != null) {
              needUpdate=service.checkModify(jobletCon);
            }
            saveJobletNode(jobletCon,needUpdate);
          }
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
 else {
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
      }
    }
    if (element instanceof JobletContainer) {
      if (checkJoblet) {
        JobletContainer jobletCon=(JobletContainer)element;
        boolean needUpdate=false;
        IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null) {
          needUpdate=service.checkModify(jobletCon);
        }
        saveJobletNode(jobletCon,needUpdate);
      }
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof NodeContainer) {
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof Note) {
      saveNote(fileFact,processType,(Note)element);
    }
  }
  processType.setDefaultContext(contextManager.getDefaultContext().getName());
  if (!getScreenshots().isEmpty()) {
    for (    String key : getScreenshots().keySet()) {
      processType.getScreenshots().put(key,getScreenshots().get(key));
    }
    if (property != null && (property.getItem() != null) && (property.getItem() instanceof ProcessItem)) {
      ProcessItem pi=(ProcessItem)property.getItem();
      ProcessType pt=pi.getProcess();
      if (pt != null) {
        EMap delegateScreenshots=pt.getScreenshots();
        for (        Object objkey : delegateScreenshots.keySet()) {
          if (!PROCESS_SCREENSHOT_KEY.equals(objkey)) {
            processType.getScreenshots().put(objkey,delegateScreenshots.get(objkey));
          }
        }
      }
    }
  }
  contextManager.saveToEmf(processType.getContext());
  EmfHelper.removeProxy(processType);
  return processType;
}

Fixed version (ground truth):
@Override public ProcessType saveXmlFile(boolean checkJoblet) throws IOException {
  init();
  TalendFileFactory fileFact=TalendFileFactory.eINSTANCE;
  ProcessType processType=createProcessType(fileFact);
  processType.setParameters(fileFact.createParametersType());
  saveProcessElementParameters(processType);
  saveRoutinesDependencies(processType);
  saveAdditionalProperties();
  EList nList=processType.getNode();
  EList cList=processType.getConnection();
  MetadataEmfFactory factory=new MetadataEmfFactory();
  JobletUtil jutil=new JobletUtil();
  for (  Element element : elem) {
    if (element instanceof SubjobContainer) {
      saveSubjob(fileFact,processType,(SubjobContainer)element);
      for (      NodeContainer container : ((SubjobContainer)element).getNodeContainers()) {
        if (container.getNode().isJoblet()) {
          if (checkJoblet) {
            JobletContainer jobletCon=(JobletContainer)container;
            boolean needUpdate=false;
            IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
            if (service != null) {
              needUpdate=service.checkModify(jobletCon);
            }
            saveJobletNode(jobletCon,needUpdate);
          }
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
 else {
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
      }
    }
    if (element instanceof JobletContainer) {
      if (checkJoblet) {
        JobletContainer jobletCon=(JobletContainer)element;
        boolean needUpdate=false;
        IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null) {
          needUpdate=service.checkModify(jobletCon);
        }
        saveJobletNode(jobletCon,needUpdate);
      }
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof NodeContainer) {
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof Note) {
      saveNote(fileFact,processType,(Note)element);
    }
  }
  processType.setDefaultContext(contextManager.getDefaultContext().getName());
  if (!getScreenshots().isEmpty()) {
    for (    String key : getScreenshots().keySet()) {
      processType.getScreenshots().put(key,getScreenshots().get(key));
    }
  }
  contextManager.saveToEmf(processType.getContext());
  EmfHelper.removeProxy(processType);
  return processType;
}