Program: 68305
Project: 68305
Buggy source:
private XPathFragment buildRootFragment(Object object,XMLDescriptor descriptor,boolean isXMLRoot,MarshalRecord marshalRecord){
  XPathFragment rootFragment=null;
  if (isXMLRoot) {
    rootFragment=((XMLRoot)object).getRootFragment();
    String xmlRootUri=((XMLRoot)object).getNamespaceURI();
    String xmlRootLocalName=((XMLRoot)object).getLocalName();
    if (xmlRootUri != null) {
      if (descriptor != null) {
        String xmlRootPrefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(xmlRootUri);
        if (xmlRootPrefix == null) {
          xmlRootPrefix=marshalRecord.getNamespaceResolver().generatePrefix();
          marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
        }
        rootFragment.setXPath(xmlRootPrefix + "String_Node_Str" + xmlRootLocalName);
      }
 else {
        String xmlRootPrefix="String_Node_Str";
        marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
        rootFragment.setXPath(xmlRootPrefix + "String_Node_Str" + xmlRootLocalName);
      }
    }
  }
 else {
    String rootName=descriptor.getDefaultRootElement();
    if (null != rootName) {
      rootFragment=new XPathFragment(rootName);
      NamespaceResolver descriptorNamespaceResolver=descriptor.getNamespaceResolver();
      if (rootFragment.getPrefix() != null && (rootFragment.getNamespaceURI() == null)) {
        String uri=null;
        if (null == descriptorNamespaceResolver) {
          throw XMLMarshalException.namespaceResolverNotSpecified(null);
        }
        uri=descriptor.getNamespaceResolver().resolveNamespacePrefix(rootFragment.getPrefix());
        if (uri == null) {
          throw XMLMarshalException.namespaceNotFound(rootFragment.getPrefix());
        }
        rootFragment.setNamespaceURI(uri);
      }
 else {
        if (descriptorNamespaceResolver != null) {
          rootFragment.setNamespaceURI(descriptorNamespaceResolver.getDefaultNamespaceURI());
        }
      }
    }
  }
  return rootFragment;
}

Fixed version (ground truth):
private XPathFragment buildRootFragment(Object object,XMLDescriptor descriptor,boolean isXMLRoot,MarshalRecord marshalRecord){
  XPathFragment rootFragment=null;
  if (isXMLRoot) {
    rootFragment=((XMLRoot)object).getRootFragment();
    String xmlRootUri=((XMLRoot)object).getNamespaceURI();
    String xmlRootLocalName=((XMLRoot)object).getLocalName();
    if (xmlRootUri != null) {
      if (descriptor != null) {
        String xmlRootPrefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(xmlRootUri);
        if (xmlRootPrefix == null && !(xmlRootUri.equals(marshalRecord.getNamespaceResolver().getDefaultNamespaceURI()))) {
          xmlRootPrefix=marshalRecord.getNamespaceResolver().generatePrefix();
          marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
        }
        if (xmlRootPrefix == null) {
          rootFragment.setXPath(xmlRootLocalName);
        }
 else {
          rootFragment.setXPath(xmlRootPrefix + "String_Node_Str" + xmlRootLocalName);
        }
      }
 else {
        String xmlRootPrefix="String_Node_Str";
        marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
        rootFragment.setXPath(xmlRootPrefix + "String_Node_Str" + xmlRootLocalName);
      }
    }
  }
 else {
    String rootName=descriptor.getDefaultRootElement();
    if (null != rootName) {
      rootFragment=new XPathFragment(rootName);
      NamespaceResolver descriptorNamespaceResolver=descriptor.getNamespaceResolver();
      if (rootFragment.getPrefix() != null && (rootFragment.getNamespaceURI() == null)) {
        String uri=null;
        if (null == descriptorNamespaceResolver) {
          throw XMLMarshalException.namespaceResolverNotSpecified(null);
        }
        uri=descriptor.getNamespaceResolver().resolveNamespacePrefix(rootFragment.getPrefix());
        if (uri == null) {
          throw XMLMarshalException.namespaceNotFound(rootFragment.getPrefix());
        }
        rootFragment.setNamespaceURI(uri);
      }
 else {
        if (descriptorNamespaceResolver != null) {
          rootFragment.setNamespaceURI(descriptorNamespaceResolver.getDefaultNamespaceURI());
        }
      }
    }
  }
  return rootFragment;
}