Program: 136674
Project: 136674
Buggy source:
/** 
 * Save item with dependencies.
 * @param element
 * @throws PersistenceException
 */
protected ReturnCode saveWithDependencies(Item item,ModelElement element) throws PersistenceException {
  ReturnCode rc=new ReturnCode();
  removeDependencies(item);
  addDependencies(element);
  addResourceContent(element.eResource(),element);
  Map<EObject,Collection<Setting>> find=EcoreUtil.ExternalCrossReferencer.find(element.eResource());
  Set<EObject> needSaves=new HashSet<EObject>();
  for (  EObject object : find.keySet()) {
    Resource re=object.eResource();
    if (re == null) {
      continue;
    }
    DQRepositoryNode node=RepositoryNodeHelper.recursiveFind((ModelElement)object);
    if (node != null && !node.getProject().isMainProject()) {
      continue;
    }
    if (!re.getURI().segment(1).equals(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel())) {
      continue;
    }
    EcoreUtil.resolveAll(re);
    needSaves.add(object);
  }
  if (item instanceof TDQItem) {
    setTDQItemFileName(element,item);
  }
  ProxyRepositoryFactory.getInstance().save(item);
  AbstractResourceChangesService resChangeService=TDQServiceRegister.getInstance().getResourceChangeService(AbstractResourceChangesService.class);
  if (resChangeService != null) {
    for (    EObject toSave : needSaves) {
      DQRepositoryNode node=RepositoryNodeHelper.recursiveFind((ModelElement)toSave);
      if (node != null && !node.getProject().isMainProject()) {
        continue;
      }
      if (!toSave.eResource().getURI().segment(1).equals(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel())) {
        continue;
      }
      resChangeService.saveResourceByEMFShared(toSave.eResource());
    }
  }
  return rc;
}

Fixed version (ground truth):
/** 
 * Save item with dependencies.
 * @param element
 * @throws PersistenceException
 */
protected ReturnCode saveWithDependencies(Item item,ModelElement element) throws PersistenceException {
  ReturnCode rc=new ReturnCode();
  removeDependencies(item);
  addDependencies(element);
  addResourceContent(element.eResource(),element);
  Map<EObject,Collection<Setting>> find=EcoreUtil.ExternalCrossReferencer.find(element.eResource());
  Set<EObject> needSaves=new HashSet<EObject>();
  for (  EObject object : find.keySet()) {
    Resource re=object.eResource();
    if (re == null) {
      continue;
    }
    DQRepositoryNode node=RepositoryNodeHelper.recursiveFind((ModelElement)object);
    if (node != null && !node.getProject().isMainProject()) {
      continue;
    }
    if (!re.getURI().segment(1).equals(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel())) {
      continue;
    }
    EcoreUtil.resolveAll(re);
    needSaves.add(object);
  }
  if (item instanceof TDQItem) {
    setTDQItemFileName(element,item);
  }
  ProxyRepositoryFactory.getInstance().save(item);
  AbstractResourceChangesService resChangeService=TDQServiceRegister.getInstance().getResourceChangeService(AbstractResourceChangesService.class);
  if (resChangeService != null) {
    for (    EObject toSave : needSaves) {
      DQRepositoryNode node=RepositoryNodeHelper.recursiveFind((ModelElement)toSave);
      if (node != null && !node.getProject().isMainProject()) {
        continue;
      }
      toSave=EObjectHelper.resolveObject(toSave);
      if (!toSave.eResource().getURI().segment(1).equals(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel())) {
        continue;
      }
      resChangeService.saveResourceByEMFShared(toSave.eResource());
    }
  }
  return rc;
}