Program: 65984
Project: 65984
Buggy source:
private SDOProperty processRef(GlobalRef globalRef){
  boolean isElement=globalRef.isElement();
  SDOProperty p=null;
  SDOProperty refProp=getExistingGlobalProperty(globalRef.getUri(),globalRef.getLocalName(),isElement);
  if (refProp != null && refProp.isFinalized()) {
    p=(SDOProperty)globalRef.getProperty();
    p.setValueProperty(refProp.isValueProperty());
    p.setNullable(refProp.isNullable());
    p.setName(refProp.getName());
    p.setXsdLocalName(refProp.getXsdLocalName());
    p.setNamespaceQualified(refProp.isNamespaceQualified());
    p.setAliasNames(refProp.getAliasNames());
    p.setDefault(refProp.getDefault());
    p.setSubstitutable(refProp.isSubstitutable());
    p.setSubstitutableElements(refProp.getSubstitutableElements());
    if (p.getType() == null) {
      p.setType(refProp.getType());
      if (refProp.getType().isDataType()) {
        p.setContainment(false);
      }
    }
    p.setOpposite(refProp.getOpposite());
    p.setReadOnly(refProp.isReadOnly());
    p.setXsd(refProp.isXsd());
    p.setAppInfoElements(refProp.getAppInfoElements());
    int index=((SDOProperty)globalRef.getProperty()).getIndexInDeclaredProperties();
    p.buildMapping(globalRef.getUri(),index);
    p.setFinalized(true);
  }
 else {
    if (isImportProcessor) {
      p=new SDOProperty(aHelperContext);
      p.setGlobal(true);
      p.setUri(globalRef.getUri());
      p.setName(globalRef.getLocalName());
      QName qname=new QName(globalRef.getUri(),globalRef.getLocalName());
      if (isElement) {
        p.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY,Boolean.TRUE);
        getGeneratedGlobalElements().put(qname,p);
      }
 else {
        getGeneratedGlobalAttributes().put(qname,p);
      }
    }
 else {
      throw SDOException.referencedPropertyNotFound(globalRef.getUri(),globalRef.getLocalName());
    }
  }
  return p;
}

Fixed version (ground truth):
private SDOProperty processRef(GlobalRef globalRef){
  boolean isElement=globalRef.isElement();
  SDOProperty p=null;
  SDOProperty refProp=getExistingGlobalProperty(globalRef.getUri(),globalRef.getLocalName(),isElement);
  if (refProp != null && refProp.isFinalized()) {
    p=(SDOProperty)globalRef.getProperty();
    p.setValueProperty(refProp.isValueProperty());
    p.setNullable(refProp.isNullable());
    p.setName(refProp.getName());
    p.setXsdLocalName(refProp.getXsdLocalName());
    p.setNamespaceQualified(refProp.isNamespaceQualified());
    if (refProp.hasAliasNames()) {
      p.setAliasNames(refProp.getAliasNames());
    }
    p.setDefault(refProp.getDefault());
    p.setSubstitutable(refProp.isSubstitutable());
    p.setSubstitutableElements(refProp.getSubstitutableElements());
    if (p.getType() == null) {
      p.setType(refProp.getType());
      if (refProp.getType().isDataType()) {
        p.setContainment(false);
      }
    }
    p.setOpposite(refProp.getOpposite());
    p.setReadOnly(refProp.isReadOnly());
    p.setXsd(refProp.isXsd());
    p.setAppInfoElements(refProp.getAppInfoElements());
    int index=((SDOProperty)globalRef.getProperty()).getIndexInDeclaredProperties();
    p.buildMapping(globalRef.getUri(),index);
    p.setFinalized(true);
  }
 else {
    if (isImportProcessor) {
      p=new SDOProperty(aHelperContext);
      p.setGlobal(true);
      p.setUri(globalRef.getUri());
      p.setName(globalRef.getLocalName());
      QName qname=new QName(globalRef.getUri(),globalRef.getLocalName());
      if (isElement) {
        p.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY,Boolean.TRUE);
        getGeneratedGlobalElements().put(qname,p);
      }
 else {
        getGeneratedGlobalAttributes().put(qname,p);
      }
    }
 else {
      throw SDOException.referencedPropertyNotFound(globalRef.getUri(),globalRef.getLocalName());
    }
  }
  return p;
}