Program: 65760
Project: 65760
Buggy source:
/** 
 * INTERNAL:
 */
private void storeXMLDescriptorByQName(XMLDescriptor xmlDescriptor){
  QName descriptorQName;
  String defaultRootName;
  List tableNames=xmlDescriptor.getTableNames();
  for (int i=0; i < tableNames.size(); i++) {
    defaultRootName=(String)tableNames.get(i);
    if (null != defaultRootName) {
      int index=defaultRootName.indexOf(':');
      String defaultRootLocalName=defaultRootName.substring(index + 1);
      if (defaultRootLocalName != null && !(defaultRootLocalName.equals(XMLConstants.EMPTY_STRING))) {
        if (index > -1) {
          String defaultRootPrefix=defaultRootName.substring(0,index);
          String defaultRootNamespaceURI=xmlDescriptor.getNamespaceResolver().resolveNamespacePrefix(defaultRootPrefix);
          descriptorQName=new QName(defaultRootNamespaceURI,defaultRootLocalName);
        }
 else {
          if (xmlDescriptor.getNamespaceResolver() != null) {
            descriptorQName=new QName(xmlDescriptor.getNamespaceResolver().getDefaultNamespaceURI(),defaultRootLocalName);
          }
 else {
            descriptorQName=new QName(defaultRootLocalName);
          }
        }
        if (!xmlDescriptor.hasInheritance() || xmlDescriptor.getInheritancePolicy().isRootParentDescriptor()) {
          descriptorsByQName.put(descriptorQName,xmlDescriptor);
        }
 else {
          storeXMLDescriptorByQName((XMLDescriptor)xmlDescriptor.getInheritancePolicy().getParentDescriptor());
          XMLDescriptor existingDescriptor=(XMLDescriptor)descriptorsByQName.get(descriptorQName);
          if (existingDescriptor == null) {
            descriptorsByQName.put(descriptorQName,xmlDescriptor);
          }
        }
      }
    }
  }
  XMLSchemaReference xmlSchemaReference=xmlDescriptor.getSchemaReference();
  if (null != xmlSchemaReference) {
    String schemaContext=xmlSchemaReference.getSchemaContext();
    if ((xmlSchemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE) || (xmlSchemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE)) {
      if ((null != schemaContext) && (schemaContext.lastIndexOf('/') == 0)) {
        schemaContext=schemaContext.substring(1,schemaContext.length());
        XPathFragment typeFragment=new XPathFragment(schemaContext);
        if (null != xmlDescriptor.getNamespaceResolver()) {
          typeFragment.setNamespaceURI(xmlDescriptor.getNamespaceResolver().resolveNamespacePrefix(typeFragment.getPrefix()));
        }
        this.descriptorsByGlobalType.put(typeFragment,xmlDescriptor);
      }
 else {
        QName qname=xmlSchemaReference.getSchemaContextAsQName();
        if (qname != null) {
          if (xmlDescriptor.isWrapper() && xmlDescriptor.getJavaClassName().contains("String_Node_Str")) {
            return;
          }
          XPathFragment typeFragment=new XPathFragment();
          typeFragment.setLocalName(qname.getLocalPart());
          typeFragment.setNamespaceURI(qname.getNamespaceURI());
          this.descriptorsByGlobalType.put(typeFragment,xmlDescriptor);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
private void storeXMLDescriptorByQName(XMLDescriptor xmlDescriptor){
  XPathQName descriptorQName;
  String defaultRootName;
  List tableNames=xmlDescriptor.getTableNames();
  for (int i=0; i < tableNames.size(); i++) {
    defaultRootName=(String)tableNames.get(i);
    if (null != defaultRootName) {
      int index=defaultRootName.indexOf(':');
      String defaultRootLocalName=defaultRootName.substring(index + 1);
      if (defaultRootLocalName != null && !(defaultRootLocalName.equals(XMLConstants.EMPTY_STRING))) {
        if (index > -1) {
          String defaultRootPrefix=defaultRootName.substring(0,index);
          String defaultRootNamespaceURI=xmlDescriptor.getNamespaceResolver().resolveNamespacePrefix(defaultRootPrefix);
          descriptorQName=new XPathQName(defaultRootNamespaceURI,defaultRootLocalName,true);
        }
 else {
          if (xmlDescriptor.getNamespaceResolver() != null) {
            descriptorQName=new XPathQName(xmlDescriptor.getNamespaceResolver().getDefaultNamespaceURI(),defaultRootLocalName,true);
          }
 else {
            descriptorQName=new XPathQName(defaultRootLocalName,true);
          }
        }
        if (!xmlDescriptor.hasInheritance() || xmlDescriptor.getInheritancePolicy().isRootParentDescriptor()) {
          addDescriptorByQName(descriptorQName,xmlDescriptor);
        }
 else {
          storeXMLDescriptorByQName((XMLDescriptor)xmlDescriptor.getInheritancePolicy().getParentDescriptor());
          XMLDescriptor existingDescriptor=(XMLDescriptor)getDescriptor(descriptorQName);
          if (existingDescriptor == null) {
            addDescriptorByQName(descriptorQName,xmlDescriptor);
          }
        }
      }
    }
  }
  XMLSchemaReference xmlSchemaReference=xmlDescriptor.getSchemaReference();
  if (null != xmlSchemaReference) {
    String schemaContext=xmlSchemaReference.getSchemaContext();
    if ((xmlSchemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE) || (xmlSchemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE)) {
      if ((null != schemaContext) && (schemaContext.lastIndexOf('/') == 0)) {
        schemaContext=schemaContext.substring(1,schemaContext.length());
        XPathFragment typeFragment=new XPathFragment(schemaContext);
        if (null != xmlDescriptor.getNamespaceResolver()) {
          typeFragment.setNamespaceURI(xmlDescriptor.getNamespaceResolver().resolveNamespacePrefix(typeFragment.getPrefix()));
        }
        this.descriptorsByGlobalType.put(typeFragment,xmlDescriptor);
      }
 else {
        QName qname=xmlSchemaReference.getSchemaContextAsQName();
        if (qname != null) {
          if (xmlDescriptor.isWrapper() && xmlDescriptor.getJavaClassName().contains("String_Node_Str")) {
            return;
          }
          XPathFragment typeFragment=new XPathFragment();
          typeFragment.setLocalName(qname.getLocalPart());
          typeFragment.setNamespaceURI(qname.getNamespaceURI());
          this.descriptorsByGlobalType.put(typeFragment,xmlDescriptor);
        }
      }
    }
  }
}