nus-yam/ex-repair huggingface dataset:
Program: 64885
Project: 64885
Buggy source:
protected void writeExtraNamespaces(List extraNamespaces,XMLRecord xmlRecord,AbstractSession session){
  if (extraNamespaces == null) {
    return;
  }
  for (int i=0, extraNamespacesSize=extraNamespaces.size(); i < extraNamespacesSize; i++) {
    Namespace next=(Namespace)extraNamespaces.get(i);
    String prefix=next.getPrefix();
    if (((MarshalRecord)xmlRecord).hasCustomNamespaceMapper()) {
      prefix=((MarshalRecord)xmlRecord).getNamespaceResolver().resolveNamespaceURI(next.getNamespaceURI());
    }
    ((MarshalRecord)xmlRecord).attribute(XMLConstants.XMLNS_URL,prefix,XMLConstants.XMLNS + XMLConstants.COLON + prefix,next.getNamespaceURI());
  }
}

Fixed version (ground truth):
protected void writeExtraNamespaces(List extraNamespaces,XMLRecord xmlRecord,AbstractSession session){
  if (extraNamespaces == null) {
    return;
  }
  for (int i=0, extraNamespacesSize=extraNamespaces.size(); i < extraNamespacesSize; i++) {
    Namespace next=(Namespace)extraNamespaces.get(i);
    String prefix=next.getPrefix();
    if (((MarshalRecord)xmlRecord).hasCustomNamespaceMapper()) {
      prefix=((MarshalRecord)xmlRecord).getNamespaceResolver().resolveNamespaceURI(next.getNamespaceURI());
    }
    ((MarshalRecord)xmlRecord).namespaceDeclaration(prefix,next.getNamespaceURI());
  }
}
Program: 64887
Project: 64887
Buggy source:
public void attribute(String namespaceURI,String localName,String name,String value){
  try {
    if (XMLConstants.XMLNS_URL.equals(namespaceURI)) {
      if (XMLConstants.XMLNS.equals(localName)) {
        xmlStreamWriter.writeDefaultNamespace(value);
      }
 else {
        xmlStreamWriter.writeNamespace(localName,value);
      }
    }
 else {
      if (namespaceURI == null || namespaceURI.length() == 0) {
        xmlStreamWriter.writeAttribute(localName,value);
      }
 else {
        xmlStreamWriter.writeAttribute(xmlStreamWriter.getNamespaceContext().getPrefix(namespaceURI),namespaceURI,localName,value);
      }
    }
  }
 catch (  XMLStreamException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void attribute(String namespaceURI,String localName,String name,String value){
  try {
    if (namespaceURI == null || namespaceURI.length() == 0) {
      xmlStreamWriter.writeAttribute(localName,value);
    }
 else {
      xmlStreamWriter.writeAttribute(xmlStreamWriter.getNamespaceContext().getPrefix(namespaceURI),namespaceURI,localName,value);
    }
  }
 catch (  XMLStreamException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 64888
Project: 64888
Buggy source:
public static TestSuite getClientServerTestSuite(){
  TestSuite suite=new TestSuite();
  suite.setName("String_Node_Str");
  suite.addTest(new ClientServerTest());
  suite.addTest(new ConcurrencyManagerTest());
  suite.addTest(new ClientServerConcurrentWriteTest());
  suite.addTest(new ClientServerSequenceDeadlockTest());
  suite.addTest(new ClientServerSequenceDeadlockTest2());
  suite.addTest(new ClientLoginTest());
  suite.addTest(new PreBeginTransactionFailureTest());
  suite.addTest(new NPEIsThrownWhenWeTryToWriteNullToANullableField());
  suite.addTest(new DonotAliaseTheTableWhenWeHaveSubSelectExpression());
  suite.addTest(new ConcurrentIdentityMapKeyEnumerationTest());
  suite.addTest(new ConcurrentReadOnUpdateWithEarlyTransTest());
  suite.addTest(new UnitOfWorkConcurrentRevertTest());
  suite.addTest(new LockOnCloneTest());
  suite.addTest(new LockOnCloneDeadlockAvoidanceTest());
  suite.addTest(new ConcurrentNewObjectTest());
  suite.addTest(new ConcurrentReadOnInsertTest());
  suite.addTest(new ConcurrentRefreshOnUpdateTest());
  suite.addTest(new ConcurrentRefreshOnCloneTest());
  suite.addTest(new NewObjectIdentityTest());
  suite.addTest(new CommunicationFailureTest());
  suite.addTest(new ClientServerUpdateDeadlockTest());
  suite.addTest(new UnitOfWorkDeleteOrderTest());
  return suite;
}

Fixed version (ground truth):
public static TestSuite getClientServerTestSuite(){
  TestSuite suite=new TestSuite();
  suite.setName("String_Node_Str");
  suite.addTest(new ClientServerTest());
  suite.addTest(new ConcurrencyManagerTest());
  suite.addTest(new ClientServerConcurrentWriteTest());
  suite.addTest(new ClientServerSequenceDeadlockTest());
  suite.addTest(new ClientServerSequenceDeadlockTest2());
  suite.addTest(new ClientLoginTest());
  suite.addTest(new PreBeginTransactionFailureTest());
  suite.addTest(new NPEIsThrownWhenWeTryToWriteNullToANullableField());
  suite.addTest(new DonotAliaseTheTableWhenWeHaveSubSelectExpression());
  suite.addTest(new ConcurrentIdentityMapKeyEnumerationTest());
  suite.addTest(new ConcurrentReadOnUpdateWithEarlyTransTest());
  suite.addTest(new UnitOfWorkConcurrentRevertTest());
  suite.addTest(new LockOnCloneTest());
  suite.addTest(new LockOnCloneDeadlockAvoidanceTest());
  suite.addTest(new ConcurrentNewObjectTest());
  suite.addTest(new ConcurrentReadOnInsertTest());
  suite.addTest(new ConcurrentRefreshOnUpdateTest());
  suite.addTest(new ConcurrentRefreshOnCloneTest());
  suite.addTest(new NewObjectIdentityTest());
  suite.addTest(new CommunicationFailureTest());
  suite.addTest(new ClientServerUpdateDeadlockTest());
  suite.addTest(new UnitOfWorkDeleteOrderTest());
  suite.addTest(new ConnectionPoolSizingTest());
  return suite;
}
Program: 64889
Project: 64889
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this);
  XMLField xmlField=(XMLField)xmlDirectMapping.getField();
  if (!xmlField.getLastXPathFragment().nameIsText) {
    return;
  }
  Object value;
  if (unmarshalRecord.getCharacters().length() == 0) {
    value=this.getMapping().getNullValue();
  }
 else {
    value=unmarshalRecord.getCharacters().toString();
  }
  unmarshalRecord.resetStringBuffer();
  AbstractSession session=unmarshalRecord.getSession();
  XMLConversionManager xmlConversionManager=(XMLConversionManager)session.getDatasourcePlatform().getConversionManager();
  if (unmarshalRecord.getTypeQName() != null) {
    Class typeClass=xmlField.getJavaClass(unmarshalRecord.getTypeQName());
    value=xmlConversionManager.convertObject(value,typeClass,unmarshalRecord.getTypeQName());
  }
 else {
    value=unmarshalRecord.getXMLReader().convertValueBasedOnSchemaType(xmlField,value,xmlConversionManager,unmarshalRecord);
  }
  Object convertedValue=xmlDirectMapping.getAttributeValue(value,unmarshalRecord.getSession(),unmarshalRecord);
  unmarshalRecord.setAttributeValue(convertedValue,xmlDirectMapping);
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this);
  XMLField xmlField=(XMLField)xmlDirectMapping.getField();
  if (!xmlField.getLastXPathFragment().nameIsText) {
    return;
  }
  Object value;
  CharSequence unmarshalRecordCharacters=unmarshalRecord.getCharacters();
  if (unmarshalRecordCharacters.length() == 0) {
    value=xmlDirectMapping.getNullValue();
  }
 else {
    value=unmarshalRecordCharacters.toString();
  }
  unmarshalRecord.resetStringBuffer();
  AbstractSession session=unmarshalRecord.getSession();
  XMLConversionManager xmlConversionManager=(XMLConversionManager)session.getDatasourcePlatform().getConversionManager();
  QName typeQName=unmarshalRecord.getTypeQName();
  if (typeQName != null) {
    Class typeClass=xmlField.getJavaClass(typeQName);
    value=xmlConversionManager.convertObject(value,typeClass,typeQName);
  }
 else {
    value=unmarshalRecord.getXMLReader().convertValueBasedOnSchemaType(xmlField,value,xmlConversionManager,unmarshalRecord);
  }
  Object convertedValue=xmlDirectMapping.getAttributeValue(value,session,unmarshalRecord);
  unmarshalRecord.setAttributeValue(convertedValue,xmlDirectMapping);
}
Program: 64890
Project: 64890
Buggy source:
public void setAttributeValueInObject(Object object,Object value) throws DescriptorException {
  if (isWriteOnly()) {
    return;
  }
  try {
    if (value == XMLRecord.noEntry) {
      return;
    }
    if (value != null && value.getClass() == ClassConstants.STRING) {
      if (isCollapsingStringValues) {
        value=XMLConversionManager.getDefaultXMLManager().collapseStringValue((String)value);
      }
 else       if (isNormalizingStringValues) {
        value=XMLConversionManager.getDefaultXMLManager().normalizeStringValue((String)value);
      }
    }
    this.attributeAccessor.setAttributeValueInObject(object,value);
  }
 catch (  DescriptorException exception) {
    exception.setMapping(this);
    throw exception;
  }
}

Fixed version (ground truth):
public void setAttributeValueInObject(Object object,Object value) throws DescriptorException {
  if (isWriteOnly()) {
    return;
  }
  try {
    if (value == XMLRecord.noEntry) {
      return;
    }
    if (value != null && value instanceof String) {
      if (isCollapsingStringValues) {
        value=XMLConversionManager.getDefaultXMLManager().collapseStringValue((String)value);
      }
 else       if (isNormalizingStringValues) {
        value=XMLConversionManager.getDefaultXMLManager().normalizeStringValue((String)value);
      }
    }
    this.attributeAccessor.setAttributeValueInObject(object,value);
  }
 catch (  DescriptorException exception) {
    exception.setMapping(this);
    throw exception;
  }
}
Program: 64892
Project: 64892
Buggy source:
public void addTests(){
  addSRGTests();
  addAdvancedSybaseExpressionFunctionTest();
  addAdvancedDB2ExpressionFunctionTest();
  addInCollectionTest();
  addTest(new LiteralExpressionTest());
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addRegexpTest();
}

Fixed version (ground truth):
public void addTests(){
  addSRGTests();
  addAdvancedSybaseExpressionFunctionTest();
  addAdvancedDB2ExpressionFunctionTest();
  addInCollectionTest();
  addTest(new LiteralExpressionTest());
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",true));
  addTest(new LiteralSQLExpressionWithQuestionMarkTest("String_Node_Str",false));
  addRegexpTest();
  addTest(new LowerCaseForCaseInsensitiveTest(LowerCaseForCaseInsensitiveTest.EqualsIgnoreCase));
  addTest(new LowerCaseForCaseInsensitiveTest(LowerCaseForCaseInsensitiveTest.LikeIgnoreCase));
  addTest(new LowerCaseForCaseInsensitiveTest(LowerCaseForCaseInsensitiveTest.ContainsSubstringIgnoringCase));
}
Program: 64893
Project: 64893
Buggy source:
/** 
 * PUBLIC: Return an expression that compares if the receiver's value is equal to the other value, ignoring case. This is equivalent to the Java "equalsIgnoreCase" method. <p>Example: <pre><blockquote> EclipseLink: employee.get("firstName").equalsIgnoreCase("Bob") Java: employee.getFirstName().equalsIgnoreCase("Bob") SQL: UPPER(F_NAME) = 'BOB' </blockquote></pre>
 */
public Expression equalsIgnoreCase(Expression theValue){
  return toUpperCase().equal(theValue.toUpperCase());
}

Fixed version (ground truth):
/** 
 * PUBLIC: Return an expression that compares if the receiver's value is equal to the other value, ignoring case. This is equivalent to the Java "equalsIgnoreCase" method. <p>Example: <pre><blockquote> EclipseLink: employee.get("firstName").equalsIgnoreCase("Bob") Java: employee.getFirstName().equalsIgnoreCase("Bob") SQL: UPPER(F_NAME) = 'BOB' </blockquote></pre>
 */
public Expression equalsIgnoreCase(Expression theValue){
  if (shouldUseUpperCaseForIgnoreCase) {
    return toUpperCase().equal(theValue.toUpperCase());
  }
 else {
    return toLowerCase().equal(theValue.toLowerCase());
  }
}
Program: 64894
Project: 64894
Buggy source:
/** 
 * PUBLIC: Return an expression that compares if the receivers value contains the substring, ignoring case. <p>Example: <blockquote><pre> EclipseLink: employee.get("firstName").containsSubstringIgnoringCase("Bob") Java: employee.getFirstName().toUpperCase().indexOf("BOB") != -1 SQL: F_NAME LIKE '%BOB%' </blockquote></pre>
 */
public Expression containsSubstringIgnoringCase(Expression expression){
  return toUpperCase().containsSubstring(expression.toUpperCase());
}

Fixed version (ground truth):
/** 
 * PUBLIC: Return an expression that compares if the receivers value contains the substring, ignoring case. <p>Example: <blockquote><pre> EclipseLink: employee.get("firstName").containsSubstringIgnoringCase("Bob") Java: employee.getFirstName().toUpperCase().indexOf("BOB") != -1 SQL: UPPER(F_NAME) LIKE '%BOB%' </blockquote></pre>
 */
public Expression containsSubstringIgnoringCase(Expression expression){
  if (shouldUseUpperCaseForIgnoreCase) {
    return toUpperCase().containsSubstring(expression.toUpperCase());
  }
 else {
    return toLowerCase().containsSubstring(expression.toLowerCase());
  }
}
Program: 64895
Project: 64895
Buggy source:
/** 
 * PUBLIC: Return an expression that compares if the receivers value is like the other value, ignoring case. This is a case in-sensitive like.
 */
public Expression likeIgnoreCase(Expression theValue){
  return toUpperCase().like(theValue.toUpperCase());
}

Fixed version (ground truth):
/** 
 * PUBLIC: Return an expression that compares if the receivers value is like the other value, ignoring case. This is a case in-sensitive like.
 */
public Expression likeIgnoreCase(Expression theValue){
  if (shouldUseUpperCaseForIgnoreCase) {
    return toUpperCase().like(theValue.toUpperCase());
  }
 else {
    return toLowerCase().like(theValue.toLowerCase());
  }
}
Program: 64896
Project: 64896
Buggy source:
public java.util.Date convertStringToDate(String sourceString,QName schemaType){
  XMLGregorianCalendar xmlGregorianCalender=convertStringToXMLGregorianCalendar(sourceString,schemaType);
  Calendar cal=toCalendar(xmlGregorianCalender);
  Date returnDate=cal.getTime();
  return returnDate;
}

Fixed version (ground truth):
public java.util.Date convertStringToDate(String sourceString,QName schemaType){
  XMLGregorianCalendar xmlGregorianCalender=convertStringToXMLGregorianCalendar(sourceString,schemaType);
  if (xmlGregorianCalender == null) {
    return null;
  }
  Calendar cal=toCalendar(xmlGregorianCalender);
  Date returnDate=cal.getTime();
  return returnDate;
}
Program: 64897
Project: 64897
Buggy source:
public Calendar convertStringToCalendar(String sourceString,QName schemaTypeQName){
  XMLGregorianCalendar xmlGregorianCalender=convertStringToXMLGregorianCalendar(sourceString,schemaTypeQName);
  return toCalendar(xmlGregorianCalender);
}

Fixed version (ground truth):
public Calendar convertStringToCalendar(String sourceString,QName schemaTypeQName){
  XMLGregorianCalendar xmlGregorianCalender=convertStringToXMLGregorianCalendar(sourceString,schemaTypeQName);
  if (xmlGregorianCalender == null) {
    return null;
  }
  return toCalendar(xmlGregorianCalender);
}
Program: 64899
Project: 64899
Buggy source:
/** 
 * Return a Duration created with a given date string.
 * @param dateString
 * @return
 */
public Duration convertStringToDuration(String sourceString){
  return getDatatypeFactory().newDuration(sourceString);
}

Fixed version (ground truth):
/** 
 * Return a Duration created with a given date string.
 * @param dateString
 * @return
 */
public Duration convertStringToDuration(String sourceString){
  if (sourceString == null || sourceString.length() == 0) {
    return null;
  }
  return getDatatypeFactory().newDuration(sourceString);
}
Program: 64900
Project: 64900
Buggy source:
/** 
 * Return a populated XMLRoot object.
 */
@Override public Object getCurrentObject(){
  String val=null;
  if (characters != null) {
    val=characters.toString();
  }
  XMLRoot xmlRoot=new XMLRoot();
  xmlRoot.setObject(((XMLConversionManager)session.getDatasourcePlatform().getConversionManager()).convertObject(val,targetClass));
  xmlRoot.setLocalName(getLocalName());
  xmlRoot.setNamespaceURI(getRootElementNamespaceUri());
  return xmlRoot;
}

Fixed version (ground truth):
/** 
 * Return a populated XMLRoot object.
 */
@Override public Object getCurrentObject(){
  XMLRoot xmlRoot=new XMLRoot();
  xmlRoot.setLocalName(getLocalName());
  xmlRoot.setNamespaceURI(getRootElementNamespaceUri());
  if (currentObject == null) {
    String val=null;
    if (characters != null) {
      val=characters.toString();
    }
    xmlRoot.setObject(((XMLConversionManager)session.getDatasourcePlatform().getConversionManager()).convertObject(val,targetClass));
  }
 else {
    xmlRoot.setObject(currentObject);
  }
  return xmlRoot;
}
Program: 64906
Project: 64906
Buggy source:
/** 
 * Return an XMLGregorianCalander created with a given date string
 * @param dateString
 * @return
 */
public XMLGregorianCalendar convertStringToXMLGregorianCalendar(String sourceString){
  XMLGregorianCalendar calToReturn=null;
  try {
    calToReturn=getDatatypeFactory().newXMLGregorianCalendar(sourceString);
  }
 catch (  IllegalArgumentException e1) {
    try {
      int length=sourceString.length();
      String retryString=null;
      if (length >= 6 && (sourceString.charAt(4) == '-') && (sourceString.charAt(5) == '-')) {
        retryString=new StringBuilder(sourceString.substring(0,4)).append(length > 6 ? sourceString.substring(6) : "String_Node_Str").toString();
      }
 else       if (length >= 4) {
        retryString=new StringBuilder(sourceString.substring(0,4)).append("String_Node_Str").append(length > 4 ? sourceString.substring(4) : "String_Node_Str").toString();
      }
      if (retryString != null) {
        calToReturn=getDatatypeFactory().newXMLGregorianCalendar(retryString);
      }
 else {
        throw e1;
      }
    }
 catch (    IllegalArgumentException e2) {
      throw e1;
    }
  }
  return calToReturn;
}

Fixed version (ground truth):
/** 
 * Return an XMLGregorianCalander created with a given date string
 * @param dateString
 * @return
 */
public XMLGregorianCalendar convertStringToXMLGregorianCalendar(String sourceString){
  String trimmedSourceString=sourceString.trim();
  XMLGregorianCalendar calToReturn=null;
  try {
    calToReturn=getDatatypeFactory().newXMLGregorianCalendar(trimmedSourceString);
  }
 catch (  IllegalArgumentException e1) {
    try {
      int length=trimmedSourceString.length();
      String retryString=null;
      if (length >= 6 && (trimmedSourceString.charAt(4) == '-') && (trimmedSourceString.charAt(5) == '-')) {
        retryString=new StringBuilder(trimmedSourceString.substring(0,4)).append(length > 6 ? trimmedSourceString.substring(6) : "String_Node_Str").toString();
      }
 else       if (length >= 4) {
        retryString=new StringBuilder(trimmedSourceString.substring(0,4)).append("String_Node_Str").append(length > 4 ? trimmedSourceString.substring(4) : "String_Node_Str").toString();
      }
      if (retryString != null) {
        calToReturn=getDatatypeFactory().newXMLGregorianCalendar(retryString);
      }
 else {
        throw e1;
      }
    }
 catch (    IllegalArgumentException e2) {
      throw e1;
    }
  }
  return calToReturn;
}
Program: 64907
Project: 64907
Buggy source:
/** 
 * Return the local helper context with the given identifier, or create one if it does not already exist.
 */
public static HelperContext getHelperContext(String identifier,ClassLoader classLoader){
  ConcurrentMap<String,HelperContext> contextMap=getContextMap();
  HelperContext helperContext=contextMap.get(identifier);
  if (null == helperContext) {
    helperContext=new SDOHelperContext(identifier,classLoader);
    HelperContext existingContext=contextMap.putIfAbsent(identifier,helperContext);
    if (existingContext != null) {
      helperContext=existingContext;
    }
  }
  return helperContext;
}

Fixed version (ground truth):
/** 
 * Return the local helper context with the given identifier, or create one if it does not already exist.
 */
public static HelperContext getHelperContext(String identifier,ClassLoader classLoader){
  ConcurrentMap<String,String> aliasEntries=getAliasMap();
  if (aliasEntries.containsKey(identifier)) {
    identifier=aliasEntries.get(identifier);
  }
  HelperContext helperContext=getUserSetHelperContext(identifier,classLoader);
  if (helperContext != null) {
    return helperContext;
  }
  ConcurrentMap<String,HelperContext> contextMap=getContextMap();
  helperContext=contextMap.get(identifier);
  if (null == helperContext) {
    helperContext=new SDOHelperContext(identifier,classLoader);
    HelperContext existingContext=contextMap.putIfAbsent(identifier,helperContext);
    if (existingContext != null) {
      helperContext=existingContext;
    }
  }
  return helperContext;
}
Program: 64909
Project: 64909
Buggy source:
protected Node objectToXMLNode(Object object,Node rootNode,AbstractSession session,XMLDescriptor descriptor,boolean isXMLRoot) throws XMLMarshalException {
  DocumentPreservationPolicy docPresPolicy=xmlContext.getDocumentPreservationPolicy(session);
  if (docPresPolicy != null && docPresPolicy.shouldPreserveDocument()) {
    XMLRecord xmlRow=null;
    if (!isXMLRoot) {
      xmlRow=(XMLRecord)((XMLObjectBuilder)descriptor.getObjectBuilder()).createRecordFor(object,xmlContext.getDocumentPreservationPolicy(session));
      xmlRow.setMarshaller(this);
      if (getAttachmentMarshaller() != null) {
        xmlRow.setXOPPackage(getAttachmentMarshaller().isXOPPackage());
      }
      if (xmlRow.getDOM().getNodeType() == Node.ELEMENT_NODE) {
        addDescriptorNamespacesToXMLRecord(descriptor,xmlRow);
      }
    }
    Document doc=objectToXML(object,rootNode,descriptor,xmlRow,isXMLRoot,docPresPolicy);
    if ((xmlRow != null) && (xmlRow.getDOM().getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)) {
      return xmlRow.getDOM();
    }
 else {
      return doc;
    }
  }
  MarshalRecord marshalRecord=new NodeRecord();
  marshalRecord.setMarshaller(this);
  marshalRecord.getNamespaceResolver().setDOM(rootNode);
  marshal(object,marshalRecord,session,descriptor,isXMLRoot);
  return marshalRecord.getDocument();
}

Fixed version (ground truth):
protected Node objectToXMLNode(Object object,Node rootNode,AbstractSession session,XMLDescriptor descriptor,boolean isXMLRoot) throws XMLMarshalException {
  DocumentPreservationPolicy docPresPolicy=xmlContext.getDocumentPreservationPolicy(session);
  if (docPresPolicy != null && docPresPolicy.shouldPreserveDocument()) {
    XMLRecord xmlRow=null;
    if (!isXMLRoot) {
      xmlRow=(XMLRecord)((XMLObjectBuilder)descriptor.getObjectBuilder()).createRecordFor(object,xmlContext.getDocumentPreservationPolicy(session));
      xmlRow.setMarshaller(this);
      if (this.attachmentMarshaller != null) {
        xmlRow.setXOPPackage(this.attachmentMarshaller.isXOPPackage());
      }
      if (xmlRow.getDOM().getNodeType() == Node.ELEMENT_NODE) {
        addDescriptorNamespacesToXMLRecord(descriptor,xmlRow);
      }
    }
    Document doc=objectToXML(object,rootNode,descriptor,xmlRow,isXMLRoot,docPresPolicy);
    if ((xmlRow != null) && (xmlRow.getDOM().getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)) {
      return xmlRow.getDOM();
    }
 else {
      return doc;
    }
  }
  MarshalRecord marshalRecord=new NodeRecord();
  marshalRecord.setMarshaller(this);
  marshalRecord.getNamespaceResolver().setDOM(rootNode);
  marshal(object,marshalRecord,session,descriptor,isXMLRoot);
  return marshalRecord.getDocument();
}
Program: 64912
Project: 64912
Buggy source:
/** 
 * This event is called when annotation processing is completed, and provides a chance to deference anything that is no longer needed (to reduce the memory footprint of this object).
 */
void postInitialize(){
  typeInfoClasses=null;
  packageToPackageInfoMappings=null;
  typeInfo=null;
  typeQNames=null;
  elementDeclarations=null;
  xmlRootElements=null;
  localElements=null;
  factoryMethods=null;
  xmlRegistries=null;
  objectFactoryClassNames=null;
  classesToProcessPropertyTypes=null;
  javaClassToTypeMappingInfos=null;
  typeMappingInfoToGeneratedClasses=null;
  typeMappingInfoToAdapterClasses=null;
  namespaceResolver=null;
  helper=null;
  logger=null;
  referencedByTransformer=null;
}

Fixed version (ground truth):
/** 
 * This event is called when annotation processing is completed, and provides a chance to deference anything that is no longer needed (to reduce the memory footprint of this object).
 */
void postInitialize(){
  typeInfoClasses=null;
  packageToPackageInfoMappings=null;
  typeInfo=null;
  typeQNames=null;
  elementDeclarations=null;
  xmlRootElements=null;
  localElements=null;
  factoryMethods=null;
  xmlRegistries=null;
  objectFactoryClassNames=null;
  classesToProcessPropertyTypes=null;
  javaClassToTypeMappingInfos=null;
  typeMappingInfoToGeneratedClasses=null;
  typeMappingInfoToAdapterClasses=null;
  helper=null;
  logger=null;
  referencedByTransformer=null;
}
Program: 64916
Project: 64916
Buggy source:
public boolean startElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts){
  XMLField xmlField=(XMLField)xmlCompositeDirectCollectionMapping.getField();
  XPathFragment lastXPathFragment=xmlField.getLastXPathFragment();
  if (lastXPathFragment.nameIsText()) {
    String type=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if (null != type) {
      String namespaceURI=null;
      int colonIndex=type.indexOf(XMLConstants.COLON);
      if (colonIndex > -1) {
        String prefix=type.substring(0,colonIndex);
        namespaceURI=unmarshalRecord.resolveNamespacePrefix(prefix);
        type=type.substring(colonIndex + 1);
      }
      unmarshalRecord.setTypeQName(new QName(namespaceURI,type));
    }
    if (xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil() && unmarshalRecord.isNil()) {
      getContainerPolicy().addInto(null,unmarshalRecord.getContainerInstance(this),unmarshalRecord.getSession());
    }
  }
 else   if (lastXPathFragment.isAttribute()) {
    if (!xmlField.usesSingleNode()) {
      String namespaceURI=lastXPathFragment.getNamespaceURI();
      if (namespaceURI == null) {
        namespaceURI=XMLConstants.EMPTY_STRING;
      }
      String value=atts.getValue(namespaceURI,lastXPathFragment.getLocalName());
      Object collection=unmarshalRecord.getContainerInstance(this);
      addUnmarshalValue(unmarshalRecord,value,collection);
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean startElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts){
  XMLField xmlField=(XMLField)xmlCompositeDirectCollectionMapping.getField();
  XPathFragment lastXPathFragment=xmlField.getLastXPathFragment();
  if (lastXPathFragment.nameIsText()) {
    String type=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if (null != type) {
      String namespaceURI=null;
      int colonIndex=type.indexOf(XMLConstants.COLON);
      if (colonIndex > -1) {
        String prefix=type.substring(0,colonIndex);
        namespaceURI=unmarshalRecord.resolveNamespacePrefix(prefix);
        type=type.substring(colonIndex + 1);
      }
      unmarshalRecord.setTypeQName(new QName(namespaceURI,type));
    }
    if (unmarshalRecord.isNil() && xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil()) {
      getContainerPolicy().addInto(null,unmarshalRecord.getContainerInstance(this),unmarshalRecord.getSession());
    }
  }
 else   if (lastXPathFragment.isAttribute()) {
    if (!xmlField.usesSingleNode()) {
      String namespaceURI=lastXPathFragment.getNamespaceURI();
      if (namespaceURI == null) {
        namespaceURI=XMLConstants.EMPTY_STRING;
      }
      String value=atts.getValue(namespaceURI,lastXPathFragment.getLocalName());
      Object collection=unmarshalRecord.getContainerInstance(this);
      addUnmarshalValue(unmarshalRecord,value,collection);
    }
  }
  return true;
}
Program: 64918
Project: 64918
Buggy source:
protected Object getControlObject(){
  int level1Size=2;
  int level2Size=3;
  int level3Size=4;
  int counter=0;
  int[][][] my3DArray=new int[level1Size][level2Size][level3Size];
  for (int x=0; x < level1Size; x++) {
    for (int y=0; y < level2Size; y++) {
      for (int z=0; z < level3Size; z++) {
        my3DArray[x][y][z]=counter++;
      }
    }
  }
  QName qname=new QName("String_Node_Str","String_Node_Str");
  JAXBElement jaxbElement=new JAXBElement(qname,Object.class,my3DArray);
  return jaxbElement;
}

Fixed version (ground truth):
protected Object getControlObject(){
  int level1Size=2;
  int level2Size=3;
  int level3Size=4;
  int counter=0;
  Integer[][][] my3DArray=new Integer[level1Size][level2Size][level3Size];
  for (int x=0; x < level1Size; x++) {
    for (int y=0; y < level2Size; y++) {
      for (int z=0; z < level3Size; z++) {
        my3DArray[x][y][z]=counter++;
      }
    }
  }
  QName qname=new QName("String_Node_Str","String_Node_Str");
  JAXBElement jaxbElement=new JAXBElement(qname,Object.class,my3DArray);
  return jaxbElement;
}
Program: 64919
Project: 64919
Buggy source:
@Override public Object getItem(){
  if (null == adaptedValue) {
    return null;
  }
  Object array=Array.newInstance(containerClass(),adaptedValue.size());
  int x=0;
  for (  Object value : adaptedValue) {
    Array.set(array,x,value);
    x++;
  }
  return array;
}

Fixed version (ground truth):
@Override public Object getItem(){
  if (null == adaptedValue) {
    return null;
  }
  int len=adaptedValue.size();
  Object array=Array.newInstance(containerClass(),len);
  for (int i=0; i < len; i++) {
    Array.set(array,i,((ArrayList)adaptedValue).get(i));
  }
  return array;
}
Program: 64923
Project: 64923
Buggy source:
public JavaClass getSuperclass(){
  if (this.superClassOverride != null) {
    return this.superClassOverride;
  }
  return javaModelImpl.getClass(jClass.getSuperclass());
}

Fixed version (ground truth):
public JavaClass getSuperclass(){
  if (this.superClassOverride != null) {
    return this.superClassOverride;
  }
  if (jClass.isInterface()) {
    Class[] superInterfaces=jClass.getInterfaces();
    if (superInterfaces != null) {
      if (superInterfaces.length == 1) {
        return javaModelImpl.getClass(superInterfaces[0]);
      }
 else {
        Class parent=null;
        for (        Class next : superInterfaces) {
          if (!(next.getName().startsWith("String_Node_Str") || next.getName().startsWith("String_Node_Str"))) {
            if (parent == null) {
              parent=next;
            }
 else {
              throw JAXBException.invalidInterface(jClass.getName());
            }
          }
        }
        return javaModelImpl.getClass(parent);
      }
    }
  }
  return javaModelImpl.getClass(jClass.getSuperclass());
}
Program: 64925
Project: 64925
Buggy source:
/** 
 * INTERNAL:
 */
public void setUnmarshaller(XMLUnmarshaller unmarshaller){
  super.setUnmarshaller(unmarshaller);
  if (xPathFragment != null) {
    xPathFragment.setNamespaceAware(isNamespaceAware());
  }
  if (unmarshaller.getValueWrapper() != null) {
    textWrapperFragment=new XPathFragment(unmarshaller.getValueWrapper());
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void setUnmarshaller(XMLUnmarshaller unmarshaller){
  super.setUnmarshaller(unmarshaller);
  if (xPathFragment != null) {
    xPathFragment.setNamespaceAware(isNamespaceAware());
  }
}
Program: 64926
Project: 64926
Buggy source:
public XPathFragment getTextWrapperFragment(){
  if (unmarshaller.getMediaType() == MediaType.APPLICATION_JSON) {
    return textWrapperFragment;
  }
  return null;
}

Fixed version (ground truth):
public XPathFragment getTextWrapperFragment(){
  if (unmarshaller.getMediaType() == MediaType.APPLICATION_JSON) {
    if (textWrapperFragment == null) {
      textWrapperFragment=new XPathFragment();
      textWrapperFragment.setLocalName(unmarshaller.getValueWrapper());
      textWrapperFragment.setNamespaceAware(isNamespaceAware());
      textWrapperFragment.setNamespaceSeparator(getNamespaceSeparator());
    }
    return textWrapperFragment;
  }
  return null;
}
Program: 64927
Project: 64927
Buggy source:
public UnmarshalRecord getChildUnmarshalRecord(TreeObjectBuilder treeObjectBuilder){
  if (childRecord != null && !childRecord.isSelfRecord) {
    childRecord.initialize(treeObjectBuilder);
    childRecord.setParentRecord(this);
    return childRecord;
  }
 else {
    childRecord=(UnmarshalRecord)treeObjectBuilder.createRecord(session);
    childRecord.setUnmarshaller(unmarshaller);
    childRecord.session=this.session;
    childRecord.setXMLReader(this.xmlReader);
    childRecord.setFragmentBuilder(fragmentBuilder);
    childRecord.setUnmarshalNamespaceResolver(this.getUnmarshalNamespaceResolver());
    childRecord.setParentRecord(this);
  }
  return childRecord;
}

Fixed version (ground truth):
public UnmarshalRecord getChildUnmarshalRecord(TreeObjectBuilder treeObjectBuilder){
  if (childRecord != null && !childRecord.isSelfRecord) {
    childRecord.initialize(treeObjectBuilder);
    childRecord.setParentRecord(this);
    return childRecord;
  }
 else {
    childRecord=(UnmarshalRecord)treeObjectBuilder.createRecord(session);
    childRecord.setUnmarshaller(unmarshaller);
    childRecord.session=this.session;
    childRecord.setTextWrapperFragment(textWrapperFragment);
    childRecord.setXMLReader(this.xmlReader);
    childRecord.setFragmentBuilder(fragmentBuilder);
    childRecord.setUnmarshalNamespaceResolver(this.getUnmarshalNamespaceResolver());
    childRecord.setParentRecord(this);
  }
  return childRecord;
}
Program: 64930
Project: 64930
Buggy source:
private Object modifyObjectIfNeeded(Object obj){
  if (obj instanceof Collection) {
    Collection objectList=(Collection)obj;
    List newList=new ArrayList(objectList.size());
    for (    Object o : objectList) {
      newList.add(modifySingleObjectIfNeeded(o));
    }
    return newList;
  }
 else {
    return modifySingleObjectIfNeeded(obj);
  }
}

Fixed version (ground truth):
private Object modifyObjectIfNeeded(Object obj){
  if (obj instanceof Collection) {
    Collection objectList=(Collection)obj;
    List newList=new ArrayList(objectList.size());
    for (    Object o : objectList) {
      newList.add(modifySingleObjectIfNeeded(o));
    }
    return newList;
  }
 else   if (obj.getClass().isArray()) {
    int arraySize=Array.getLength(obj);
    List newList=new ArrayList(arraySize);
    for (int x=0; x < arraySize; x++) {
      newList.add(modifySingleObjectIfNeeded(Array.get(obj,x)));
    }
    return newList;
  }
 else {
    return modifySingleObjectIfNeeded(obj);
  }
}
Program: 64931
Project: 64931
Buggy source:
/** 
 * A convenience method to get the domain class (i.e. <i>Customer</i>) from  the parameter/return type (i.e. <i>Customer</i>, <i>List&lt;Customer></i>, <i>JAXBElement&lt;Customer></i>, <i>JAXBElement&lt;? extends Customer></i>,  <i>List&lt;JAXBElement&lt;Customer>></i>, or  <i>List&lt;JAXBElement&lt;? extends Customer>></i>).
 * @param genericType - The parameter/return type of the JAX-RS operation.
 * @return The corresponding domain class.
 */
protected Class<?> getDomainClass(Type genericType){
  if (genericType instanceof Class && genericType != JAXBElement.class) {
    Class<?> clazz=(Class<?>)genericType;
    if (clazz.isArray()) {
      return clazz.getComponentType();
    }
    return clazz;
  }
 else   if (genericType instanceof ParameterizedType) {
    Type type=((ParameterizedType)genericType).getActualTypeArguments()[0];
    if (type instanceof ParameterizedType) {
      Type rawType=((ParameterizedType)type).getRawType();
      if (rawType == JAXBElement.class) {
        return getDomainClass(type);
      }
    }
 else     if (type instanceof WildcardType) {
      Type[] upperTypes=((WildcardType)type).getUpperBounds();
      if (upperTypes.length > 0) {
        Type upperType=upperTypes[0];
        if (upperType instanceof Class) {
          return (Class<?>)upperType;
        }
      }
    }
 else     if (JAXBElement.class == type) {
      return Object.class;
    }
    return (Class<?>)type;
  }
 else {
    return Object.class;
  }
}

Fixed version (ground truth):
/** 
 * A convenience method to get the domain class (i.e. <i>Customer</i>) from  the parameter/return type (i.e. <i>Customer</i>, <i>List&lt;Customer></i>, <i>JAXBElement&lt;Customer></i>, <i>JAXBElement&lt;? extends Customer></i>,  <i>List&lt;JAXBElement&lt;Customer>></i>, or  <i>List&lt;JAXBElement&lt;? extends Customer>></i>).
 * @param genericType - The parameter/return type of the JAX-RS operation.
 * @return The corresponding domain class.
 */
protected Class<?> getDomainClass(Type genericType){
  if (genericType instanceof Class && genericType != JAXBElement.class) {
    Class<?> clazz=(Class<?>)genericType;
    if (clazz.isArray()) {
      return getDomainClass(clazz.getComponentType());
    }
    return clazz;
  }
 else   if (genericType instanceof ParameterizedType) {
    Type type=((ParameterizedType)genericType).getActualTypeArguments()[0];
    if (type instanceof ParameterizedType) {
      Type rawType=((ParameterizedType)type).getRawType();
      if (rawType == JAXBElement.class) {
        return getDomainClass(type);
      }
    }
 else     if (type instanceof WildcardType) {
      Type[] upperTypes=((WildcardType)type).getUpperBounds();
      if (upperTypes.length > 0) {
        Type upperType=upperTypes[0];
        if (upperType instanceof Class) {
          return (Class<?>)upperType;
        }
      }
    }
 else     if (JAXBElement.class == type) {
      return Object.class;
    }
    return (Class<?>)type;
  }
 else {
    return Object.class;
  }
}
Program: 64932
Project: 64932
Buggy source:
/** 
 * Wraps the XmlAdapter marshal method.
 */
public Object convertObjectValueToDataValue(Object objectValue,Session session,XMLMarshaller marshaller){
  try {
    XmlAdapter adapter=this.xmlAdapter;
    if (marshaller != null) {
      HashMap adapters=(HashMap)marshaller.getProperty(JAXBMarshaller.XML_JAVATYPE_ADAPTERS);
      if (adapters != null) {
        XmlAdapter runtimeAdapter=(XmlAdapter)adapters.get(this.xmlAdapterClass);
        if (runtimeAdapter != null) {
          adapter=runtimeAdapter;
        }
      }
    }
    Object dataValue=adapter.marshal(objectValue);
    if (nestedConverter != null) {
      dataValue=nestedConverter.convertObjectValueToDataValue(dataValue,session);
    }
    return dataValue;
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    throw ConversionException.couldNotBeConverted(objectValue,valueType,ex);
  }
}

Fixed version (ground truth):
/** 
 * Wraps the XmlAdapter marshal method.
 */
public Object convertObjectValueToDataValue(Object objectValue,Session session,XMLMarshaller marshaller){
  try {
    XmlAdapter adapter=this.xmlAdapter;
    if (marshaller != null) {
      HashMap adapters=(HashMap)marshaller.getProperty(JAXBMarshaller.XML_JAVATYPE_ADAPTERS);
      if (adapters != null) {
        XmlAdapter runtimeAdapter=(XmlAdapter)adapters.get(this.xmlAdapterClass);
        if (runtimeAdapter != null) {
          adapter=runtimeAdapter;
        }
      }
    }
    Object dataValue=adapter.marshal(objectValue);
    if (nestedConverter != null) {
      dataValue=nestedConverter.convertObjectValueToDataValue(dataValue,session);
    }
    return dataValue;
  }
 catch (  Exception ex) {
    throw ConversionException.couldNotBeConverted(objectValue,valueType,ex);
  }
}
Program: 64933
Project: 64933
Buggy source:
public void setNestedConverter(Converter nestedConverter){
  this.nestedConverter=nestedConverter;
}

Fixed version (ground truth):
/** 
 * Set a nested converter to be used in conjunction with the adapter. On marshal,  the nested converter is invoked after the adapter. On umarshal it is invoked before. Primarily used to support enumerations with adapters. 
 */
public void setNestedConverter(Converter nestedConverter){
  this.nestedConverter=nestedConverter;
}
Program: 64934
Project: 64934
Buggy source:
public Converter getNestedConverter(){
  return nestedConverter;
}

Fixed version (ground truth):
/** 
 * Get the nested converter to that is used in conjunction with the adapter.
 */
public Converter getNestedConverter(){
  return nestedConverter;
}
Program: 64935
Project: 64935
Buggy source:
public void setSession(AbstractSession session){
  this.session=session;
  if (session != null) {
    this.equalNamespaceResolvers=((XMLLogin)session.getDatasourceLogin()).hasEqualNamespaceResolvers();
  }
}

Fixed version (ground truth):
public void setSession(AbstractSession session){
  this.session=session;
  if (session != null && session.getDatasourceLogin() instanceof XMLLogin) {
    this.equalNamespaceResolvers=((XMLLogin)session.getDatasourceLogin()).hasEqualNamespaceResolvers();
  }
}
Program: 64936
Project: 64936
Buggy source:
public void addContainerValue(ContainerValue containerValue){
  if (null == this.containerValues) {
    this.containerValues=new ArrayList();
  }
  containerValue.setIndex(counter++);
  this.containerValues.add(containerValue);
}

Fixed version (ground truth):
public void addContainerValue(ContainerValue containerValue){
  if (null == this.containerValues) {
    this.containerValues=new ArrayList();
  }
  containerValue.setIndex(counter++);
  this.containerValues.add(containerValue);
  if (containerValue.isDefaultEmptyContainer()) {
    addDefaultEmptyContainerValue(containerValue);
  }
}
Program: 64937
Project: 64937
Buggy source:
public Object getContainerInstance(ContainerValue c,boolean createContainerIfNecessary){
  Object containerInstance=containerInstances[c.getIndex()];
  if (containerInstance == null) {
    DatabaseMapping mapping=c.getMapping();
    if (c.getReuseContainer() && !(mapping.isReadOnly())) {
      containerInstance=mapping.getAttributeValueFromObject(currentObject);
    }
    if (null == containerInstance && createContainerIfNecessary) {
      containerInstance=c.getContainerInstance();
    }
    containerInstances[c.getIndex()]=containerInstance;
  }
  return containerInstance;
}

Fixed version (ground truth):
public Object getContainerInstance(ContainerValue c,boolean createContainerIfNecessary){
  Object containerInstance=containerInstances[c.getIndex()];
  if (containerInstance == null) {
    DatabaseMapping mapping=c.getMapping();
    if (c.getReuseContainer() && !(mapping.isReadOnly())) {
      containerInstance=mapping.getAttributeValueFromObject(currentObject);
    }
    if (null == containerInstance && createContainerIfNecessary) {
      containerInstance=c.getContainerInstance();
    }
    containerInstances[c.getIndex()]=containerInstance;
    populatedContainerValues.add(c);
    if (defaultEmptyContainerValues != null) {
      defaultEmptyContainerValues.remove(c);
    }
  }
  return containerInstance;
}
Program: 64940
Project: 64940
Buggy source:
protected UnmarshalRecord initialize(TreeObjectBuilder treeObjectBuilder){
  this.isBufferCDATA=false;
  this.treeObjectBuilder=treeObjectBuilder;
  if (null != treeObjectBuilder) {
    this.xPathNode=treeObjectBuilder.getRootXPathNode();
    if (null != treeObjectBuilder.getNullCapableValues()) {
      this.nullCapableValues=new ArrayList<NullCapableValue>(treeObjectBuilder.getNullCapableValues());
    }
  }
  isSelfRecord=false;
  return this;
}

Fixed version (ground truth):
protected UnmarshalRecord initialize(TreeObjectBuilder treeObjectBuilder){
  this.isBufferCDATA=false;
  this.treeObjectBuilder=treeObjectBuilder;
  if (null != treeObjectBuilder) {
    this.xPathNode=treeObjectBuilder.getRootXPathNode();
    if (null != treeObjectBuilder.getNullCapableValues()) {
      this.nullCapableValues=new ArrayList<NullCapableValue>(treeObjectBuilder.getNullCapableValues());
    }
    if (null != treeObjectBuilder.getDefaultEmptyContainerValues()) {
      this.defaultEmptyContainerValues=new ArrayList<ContainerValue>(treeObjectBuilder.getDefaultEmptyContainerValues());
    }
  }
  isSelfRecord=false;
  return this;
}
Program: 64944
Project: 64944
Buggy source:
public boolean marshal(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlBinaryDataCollectionMapping.isReadOnly()) {
    return false;
  }
  Object collection=xmlBinaryDataCollectionMapping.getAttributeAccessor().getAttributeValueFromObject(object);
  if (null == collection) {
    AbstractNullPolicy wrapperNP=xmlBinaryDataCollectionMapping.getWrapperNullPolicy();
    if (wrapperNP != null && wrapperNP.getMarshalNullRepresentation().equals(XMLNullRepresentationType.XSI_NIL)) {
      marshalRecord.nilSimple(namespaceResolver);
      return true;
    }
 else {
      return false;
    }
  }
  ContainerPolicy cp=getContainerPolicy();
  Object iterator=cp.iteratorFor(collection);
  if (!cp.hasNext(iterator)) {
    return marshalRecord.emptyCollection(xPathFragment,namespaceResolver,xmlBinaryDataCollectionMapping.getWrapperNullPolicy() != null);
  }
  XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
  marshalRecord.closeStartGroupingElements(groupingFragment);
  marshalRecord.startCollection();
  while (cp.hasNext(iterator)) {
    Object objectValue=cp.next(iterator,session);
    marshalSingleValue(xPathFragment,marshalRecord,object,objectValue,session,namespaceResolver,ObjectMarshalContext.getInstance());
  }
  marshalRecord.endCollection();
  return true;
}

Fixed version (ground truth):
public boolean marshal(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlBinaryDataCollectionMapping.isReadOnly()) {
    return false;
  }
  Object collection=xmlBinaryDataCollectionMapping.getAttributeAccessor().getAttributeValueFromObject(object);
  if (null == collection) {
    AbstractNullPolicy wrapperNP=xmlBinaryDataCollectionMapping.getWrapperNullPolicy();
    if (wrapperNP != null && wrapperNP.getMarshalNullRepresentation() == XMLNullRepresentationType.XSI_NIL) {
      marshalRecord.nilSimple(namespaceResolver);
      return true;
    }
 else {
      return false;
    }
  }
  ContainerPolicy cp=getContainerPolicy();
  Object iterator=cp.iteratorFor(collection);
  if (!cp.hasNext(iterator)) {
    return marshalRecord.emptyCollection(xPathFragment,namespaceResolver,xmlBinaryDataCollectionMapping.getWrapperNullPolicy() != null);
  }
  XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
  marshalRecord.closeStartGroupingElements(groupingFragment);
  marshalRecord.startCollection();
  while (cp.hasNext(iterator)) {
    Object objectValue=cp.next(iterator,session);
    marshalSingleValue(xPathFragment,marshalRecord,object,objectValue,session,namespaceResolver,ObjectMarshalContext.getInstance());
  }
  marshalRecord.endCollection();
  return true;
}