Program: 137702
Project: 137702
Buggy source:
public IFile duplicate(String newLabel) throws BusinessException {
  if (modelElement != null) {
    ModelElement newObject=(ModelElement)EMFSharedResources.getInstance().copyEObject(modelElement);
    newObject.setName(newLabel);
    if (newObject instanceof AbstractMetadataObject) {
      AbstractMetadataObject amObj=(AbstractMetadataObject)newObject;
      amObj.setLabel(newLabel);
    }
    if (modelElement instanceof DatabaseConnection) {
      DatabaseConnection dbcon=(DatabaseConnection)modelElement;
      EList<Package> dataPackages=dbcon.getDataPackage();
      if (dataPackages != null) {
        for (        Package oldDataPackage : dataPackages) {
          EList<Package> newDataPackages=((DatabaseConnection)newObject).getDataPackage();
          newDataPackages.add(oldDataPackage);
        }
      }
    }
    IFolder folder=extractFolder(modelElement);
    if (folder != null) {
      newObject=update(modelElement,newObject);
      AElementPersistance elementWriter=ElementWriterFactory.getInstance().create(modelElement);
      if (elementWriter != null) {
        elementWriter.create(newObject,folder);
        for (        Dependency dependency : modelElement.getClientDependency()) {
          for (          ModelElement supplyier : dependency.getSupplier()) {
            TypedReturnCode<Dependency> rc=DependenciesHandler.getInstance().setUsageDependencyOn(newObject,supplyier);
            EMFSharedResources.getInstance().saveResource(rc.getObject().eResource());
          }
        }
        URI uri;
        if (newObject.eIsProxy()) {
          uri=((InternalEObject)newObject).eProxyURI();
        }
 else {
          uri=newObject.eResource().getURI();
        }
        return ResourceManager.getRoot().getFile(new Path(uri.toPlatformString(false)));
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public IFile duplicate(String newLabel) throws BusinessException {
  if (modelElement != null) {
    ModelElement newObject=(ModelElement)EMFSharedResources.getInstance().copyEObject(modelElement);
    newObject.setName(newLabel);
    if (newObject instanceof AbstractMetadataObject) {
      AbstractMetadataObject amObj=(AbstractMetadataObject)newObject;
      amObj.setLabel(newLabel);
    }
    if (modelElement instanceof DatabaseConnection) {
      DatabaseConnection dbcon=(DatabaseConnection)modelElement;
      EList<Package> dataPackages=dbcon.getDataPackage();
      if (dataPackages != null) {
        for (        Package oldDataPackage : dataPackages) {
          EList<Package> newDataPackages=((DatabaseConnection)newObject).getDataPackage();
          Package copyEObject=(Package)EMFSharedResources.getInstance().copyEObject(oldDataPackage);
          newDataPackages.add(copyEObject);
        }
      }
    }
    IFolder folder=extractFolder(modelElement);
    if (folder != null) {
      newObject=update(modelElement,newObject);
      AElementPersistance elementWriter=ElementWriterFactory.getInstance().create(modelElement);
      if (elementWriter != null) {
        elementWriter.create(newObject,folder);
        for (        Dependency dependency : modelElement.getClientDependency()) {
          for (          ModelElement supplyier : dependency.getSupplier()) {
            TypedReturnCode<Dependency> rc=DependenciesHandler.getInstance().setUsageDependencyOn(newObject,supplyier);
            EMFSharedResources.getInstance().saveResource(rc.getObject().eResource());
          }
        }
        URI uri;
        if (newObject.eIsProxy()) {
          uri=((InternalEObject)newObject).eProxyURI();
        }
 else {
          uri=newObject.eResource().getURI();
        }
        return ResourceManager.getRoot().getFile(new Path(uri.toPlatformString(false)));
      }
    }
  }
  return null;
}