Program: 64419
Project: 64419
Buggy source:
protected List addExtraNamespacesToNamespaceResolver(Descriptor desc,org.eclipse.persistence.internal.oxm.record.XMLRecord marshalRecord,CoreAbstractSession session,boolean allowOverride,boolean ignoreEqualResolvers){
  if (marshalRecord.hasEqualNamespaceResolvers() && !ignoreEqualResolvers) {
    return null;
  }
  NamespaceResolver descriptorNamespaceResolver=desc.getNamespaceResolver();
  if (null == descriptorNamespaceResolver || !descriptorNamespaceResolver.hasPrefixesToNamespaces()) {
    return null;
  }
  Map<String,String> prefixesToNamespaces=descriptorNamespaceResolver.getPrefixesToNamespaces();
  if (prefixesToNamespaces.size() == 0) {
    return null;
  }
  List returnList=new ArrayList(prefixesToNamespaces.size());
  NamespaceResolver marshalRecordNamespaceResolver=(NamespaceResolver)marshalRecord.getNamespaceResolver();
  for (  Entry<String,String> entry : prefixesToNamespaces.entrySet()) {
    String prefix=marshalRecordNamespaceResolver.resolveNamespaceURI(entry.getValue());
    if (prefix == null || prefix.length() == 0) {
      prefix=entry.getKey();
      if (marshalRecord.hasCustomNamespaceMapper()) {
        String newPrefix=marshalRecord.getMarshaller().getNamespacePrefixMapper().getPreferredPrefix(entry.getValue(),prefix,true);
        if (newPrefix != null && !(newPrefix.length() == 0)) {
          prefix=newPrefix;
        }
      }
      String uri=marshalRecordNamespaceResolver.resolveNamespacePrefix(prefix);
      if (marshalRecord.hasCustomNamespaceMapper() || allowOverride || uri == null || uri.length() == 0) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(prefix,entry.getValue()));
      }
    }
 else     if (allowOverride) {
      if (!prefix.equals(entry.getKey()) && !(marshalRecord.hasCustomNamespaceMapper())) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(entry.getKey(),entry.getValue()));
      }
    }
  }
  return returnList;
}

Fixed version (ground truth):
protected List addExtraNamespacesToNamespaceResolver(Descriptor desc,org.eclipse.persistence.internal.oxm.record.XMLRecord marshalRecord,CoreAbstractSession session,boolean allowOverride,boolean ignoreEqualResolvers){
  if (marshalRecord.hasEqualNamespaceResolvers() && !ignoreEqualResolvers) {
    return null;
  }
  NamespaceResolver descriptorNamespaceResolver=((XMLDescriptor)desc).getNamespaceResolver();
  if (null == descriptorNamespaceResolver || !descriptorNamespaceResolver.hasPrefixesToNamespaces()) {
    return null;
  }
  Map<String,String> prefixesToNamespaces=descriptorNamespaceResolver.getPrefixesToNamespaces();
  if (prefixesToNamespaces.size() == 0) {
    return null;
  }
  List returnList=new ArrayList(prefixesToNamespaces.size());
  NamespaceResolver marshalRecordNamespaceResolver=(NamespaceResolver)marshalRecord.getNamespaceResolver();
  for (  Entry<String,String> entry : prefixesToNamespaces.entrySet()) {
    String prefix=marshalRecordNamespaceResolver.resolveNamespaceURI(entry.getValue());
    if (prefix == null || prefix.length() == 0) {
      prefix=entry.getKey();
      if (marshalRecord.hasCustomNamespaceMapper()) {
        String newPrefix=marshalRecord.getMarshaller().getNamespacePrefixMapper().getPreferredPrefix(entry.getValue(),prefix,true);
        if (newPrefix != null && !(newPrefix.length() == 0)) {
          prefix=newPrefix;
        }
      }
      String uri=marshalRecordNamespaceResolver.resolveNamespacePrefix(prefix);
      if (marshalRecord.hasCustomNamespaceMapper() || allowOverride || uri == null || uri.length() == 0) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(prefix,entry.getValue()));
      }
    }
 else     if (allowOverride) {
      if (!prefix.equals(entry.getKey()) && !(marshalRecord.hasCustomNamespaceMapper())) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(entry.getKey(),entry.getValue()));
      }
    }
  }
  return returnList;
}