Program: 65679
Project: 65679
Buggy source:
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,DatabaseMapping mapping,UnmarshalKeepAsElementPolicy policy){
  XMLDescriptor returnDescriptor=null;
  if (atts != null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    String schemaType=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if (schemaType != null) {
      schemaType=schemaType.trim();
      if (schemaType.length() > 0) {
        XPathFragment frag=new XPathFragment();
        frag.setXPath(schemaType);
        QName qname=null;
        if (frag.hasNamespace()) {
          String prefix=frag.getPrefix();
          String url=unmarshalRecord.resolveNamespacePrefix(prefix);
          frag.setNamespaceURI(url);
          qname=new QName(url,frag.getLocalName());
          unmarshalRecord.setTypeQName(qname);
        }
 else {
          String url=unmarshalRecord.resolveNamespacePrefix(XMLConstants.EMPTY_STRING);
          if (null != url) {
            frag.setNamespaceURI(url);
            qname=new QName(url,frag.getLocalName());
            unmarshalRecord.setTypeQName(qname);
          }
        }
        returnDescriptor=xmlContext.getDescriptorByGlobalType(frag);
        if (returnDescriptor == null) {
          if (policy == null || (policy != null && policy != UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT && policy != UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) {
            Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(qname);
            if (theClass == null) {
              throw XMLMarshalException.unknownXsiTypeValue(schemaType,mapping);
            }
          }
        }
      }
    }
  }
  return returnDescriptor;
}

Fixed version (ground truth):
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,DatabaseMapping mapping,UnmarshalKeepAsElementPolicy policy){
  XMLDescriptor returnDescriptor=null;
  if (atts != null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    String schemaType=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if (schemaType != null) {
      schemaType=schemaType.trim();
      if (schemaType.length() > 0) {
        XPathFragment frag=new XPathFragment();
        frag.setNamespaceAware(unmarshalRecord.isNamespaceAware());
        frag.setXPath(schemaType);
        QName qname=null;
        if (frag.hasNamespace()) {
          String prefix=frag.getPrefix();
          String url=unmarshalRecord.resolveNamespacePrefix(prefix);
          frag.setNamespaceURI(url);
          qname=new QName(url,frag.getLocalName());
          unmarshalRecord.setTypeQName(qname);
        }
 else {
          String url=unmarshalRecord.resolveNamespacePrefix(XMLConstants.EMPTY_STRING);
          if (null != url) {
            frag.setNamespaceURI(url);
            qname=new QName(url,frag.getLocalName());
            unmarshalRecord.setTypeQName(qname);
          }
        }
        returnDescriptor=xmlContext.getDescriptorByGlobalType(frag);
        if (returnDescriptor == null) {
          if (policy == null || (policy != null && policy != UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT && policy != UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) {
            Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(qname);
            if (theClass == null) {
              throw XMLMarshalException.unknownXsiTypeValue(schemaType,mapping);
            }
          }
        }
      }
    }
  }
  return returnDescriptor;
}