Program: 136844
Project: 136844
Buggy source:
public void write(ItemRecord[] records,IProgressMonitor monitor){
  if (monitor == null) {
    monitor=new NullProgressMonitor();
  }
  final ItemRecord[] fRecords=records;
  final IProgressMonitor fMonitor=monitor;
  need2MergeModelElementMap.clear();
  allDeletedItems.clear();
  RepositoryWorkUnit<Object> workUnit=new RepositoryWorkUnit<Object>("String_Node_Str"){
    @Override protected void run(){
      try {
        for (        ItemRecord record : fRecords) {
          if (fMonitor.isCanceled()) {
            break;
          }
          Map<IPath,IPath> toImportMap=mapping(record);
          fMonitor.subTask("String_Node_Str" + record.getName());
          if (record.isValid()) {
            log.info("String_Node_Str" + record.getFile().getAbsolutePath());
            IRepositoryViewObject object=record.getConflictObject();
            boolean isDelete=true;
            ModelElement modEle=record.getElement();
            if (object != null) {
              if (isIndicatorDefinition(modEle)) {
                if (isDQRule(modEle)) {
                  if (isParserRule(modEle)) {
                    mergeParserRule(record,(TDQBusinessRuleItem)object.getProperty().getItem());
                    isDelete=false;
                  }
 else                   if (isWhereRule(modEle)) {
                  }
                }
 else                 if (isMatchRuleDefinition(modEle)) {
                }
 else {
                  TDQIndicatorDefinitionItem indItem=(TDQIndicatorDefinitionItem)object.getProperty().getItem();
                  mergeSystemIndicator(record,indItem);
                  if (record.getElement() instanceof UDIndicatorDefinition) {
                    need2MergeModelElementMap.put(indItem,record.getElement());
                  }
                  isDelete=false;
                }
              }
 else               if (isPattern(modEle)) {
                TDQPatternItem patternItem=(TDQPatternItem)object.getProperty().getItem();
                mergePattern(record,patternItem);
                need2MergeModelElementMap.put(patternItem,record.getElement());
                isDelete=false;
              }
 else {
                EObjectHelper.removeDependencys(PropertyHelper.getModelElement(object.getProperty()));
                ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
              }
            }
            if (isDelete) {
              for (              IPath resPath : toImportMap.keySet()) {
                IPath desPath=toImportMap.get(resPath);
                ResourceSet resourceSet=ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().resourceSet;
synchronized (resourceSet) {
                  write(resPath,desPath);
                  allCopiedFiles.add(desPath.toFile());
                }
                allDeletedItems.add(desPath);
              }
            }
          }
 else {
            for (            String error : record.getErrors()) {
              log.error(error);
            }
          }
          fMonitor.worked(1);
        }
        finish(fRecords,fMonitor);
      }
 catch (      Exception e) {
        log.error(e,e);
      }
    }
  }
;
  workUnit.setAvoidUnloadResources(Boolean.TRUE);
  ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
  RepositoryWorkUnit<Object> workUnitFinish=new RepositoryWorkUnit<Object>("String_Node_Str"){
    @Override protected void run() throws LoginException, PersistenceException {
      try {
        postFinish();
      }
 catch (      IOException e) {
        log.error(e,e);
      }
    }
  }
;
  workUnitFinish.setAvoidUnloadResources(Boolean.TRUE);
  ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnitFinish);
}

Fixed version (ground truth):
public void write(ItemRecord[] records,IProgressMonitor monitor){
  if (monitor == null) {
    monitor=new NullProgressMonitor();
  }
  final ItemRecord[] fRecords=records;
  final IProgressMonitor fMonitor=monitor;
  need2MergeModelElementMap.clear();
  allDeletedItems.clear();
  RepositoryWorkUnit<Object> workUnit=new RepositoryWorkUnit<Object>("String_Node_Str"){
    @Override protected void run(){
      try {
        for (        ItemRecord record : fRecords) {
          if (fMonitor.isCanceled()) {
            break;
          }
          Map<IPath,IPath> toImportMap=mapping(record);
          fMonitor.subTask("String_Node_Str" + record.getName());
          if (record.isValid()) {
            log.info("String_Node_Str" + record.getFile().getAbsolutePath());
            IRepositoryViewObject object=record.getConflictObject();
            boolean isDelete=true;
            ModelElement modEle=record.getElement();
            if (object != null) {
              if (isIndicatorDefinition(modEle)) {
                if (isDQRule(modEle)) {
                  if (isParserRule(modEle)) {
                    mergeParserRule(record,(TDQBusinessRuleItem)object.getProperty().getItem());
                    isDelete=false;
                  }
 else                   if (isWhereRule(modEle)) {
                  }
                }
 else                 if (isMatchRuleDefinition(modEle)) {
                }
 else {
                  TDQIndicatorDefinitionItem indItem=(TDQIndicatorDefinitionItem)object.getProperty().getItem();
                  mergeSystemIndicator(record,indItem);
                  if (record.getElement() instanceof UDIndicatorDefinition) {
                    need2MergeModelElementMap.put(indItem,record.getElement());
                  }
                  isDelete=false;
                }
              }
 else               if (isPattern(modEle)) {
                TDQPatternItem patternItem=(TDQPatternItem)object.getProperty().getItem();
                mergePattern(record,patternItem);
                need2MergeModelElementMap.put(patternItem,record.getElement());
                isDelete=false;
              }
 else {
                EObjectHelper.removeDependencys(PropertyHelper.getModelElement(object.getProperty()));
                ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
              }
            }
            if (isDelete) {
              updateFiles.clear();
              updateFilesCoverd.clear();
              for (              IPath resPath : toImportMap.keySet()) {
                IPath desPath=toImportMap.get(resPath);
                ResourceSet resourceSet=ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().resourceSet;
synchronized (resourceSet) {
                  write(resPath,desPath);
                  allCopiedFiles.add(desPath.toFile());
                }
                allDeletedItems.add(desPath);
              }
              for (              File file : updateFiles) {
                update(file,false);
              }
              for (              File file : updateFilesCoverd) {
                update(file,true);
              }
            }
          }
 else {
            for (            String error : record.getErrors()) {
              log.error(error);
            }
          }
          fMonitor.worked(1);
        }
        finish(fRecords,fMonitor);
      }
 catch (      Exception e) {
        log.error(e,e);
      }
    }
  }
;
  workUnit.setAvoidUnloadResources(Boolean.TRUE);
  ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
  RepositoryWorkUnit<Object> workUnitFinish=new RepositoryWorkUnit<Object>("String_Node_Str"){
    @Override protected void run() throws LoginException, PersistenceException {
      try {
        postFinish();
      }
 catch (      IOException e) {
        log.error(e,e);
      }
    }
  }
;
  workUnitFinish.setAvoidUnloadResources(Boolean.TRUE);
  ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnitFinish);
}