Program: 64484
Project: 64484
Buggy source:
protected Descriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,Mapping mapping,UnmarshalKeepAsElementPolicy policy){
  Descriptor returnDescriptor=null;
  if (atts != null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    String schemaType=null;
    if (unmarshalRecord.isNamespaceAware()) {
      schemaType=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    }
 else {
      schemaType=atts.getValue(XMLConstants.EMPTY_STRING,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    }
    if (schemaType != null) {
      schemaType=schemaType.trim();
      if (schemaType.length() > 0) {
        XPathFragment frag=new XPathFragment(schemaType,unmarshalRecord.getNamespaceSeparator(),unmarshalRecord.isNamespaceAware());
        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);
          }
          if (!unmarshalRecord.isNamespaceAware()) {
            qname=new QName(XMLConstants.SCHEMA_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 Descriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,Mapping mapping,UnmarshalKeepAsElementPolicy policy){
  Descriptor returnDescriptor=null;
  if (atts != null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    String schemaType=null;
    if (unmarshalRecord.isNamespaceAware()) {
      schemaType=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    }
 else {
      schemaType=atts.getValue(XMLConstants.EMPTY_STRING,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    }
    if (schemaType != null) {
      schemaType=schemaType.trim();
      if (schemaType.length() > 0) {
        XPathFragment frag=new XPathFragment(schemaType,unmarshalRecord.getNamespaceSeparator(),unmarshalRecord.isNamespaceAware());
        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);
          }
          if (!unmarshalRecord.isNamespaceAware()) {
            qname=new QName(XMLConstants.SCHEMA_URL,frag.getLocalName());
            unmarshalRecord.setTypeQName(qname);
          }
        }
        returnDescriptor=xmlContext.getDescriptorByGlobalType(frag);
        if (returnDescriptor == null) {
          if (policy == null || (!policy.isKeepUnknownAsElement() && !policy.isKeepAllAsElement())) {
            Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(qname);
            if (theClass == null) {
              throw XMLMarshalException.unknownXsiTypeValue(schemaType,mapping);
            }
          }
        }
      }
    }
  }
  return returnDescriptor;
}