nus-yam/ex-repair huggingface dataset:
Program: 65577
Project: 65577
Buggy source:
/** 
 * Return the xmladapter class for a given bound type class name.
 * @param boundType
 * @return
 */
public JavaClass getPackageLevelAdapterClass(String boundTypeName){
  return getPackageLevelAdaptersByClass().get(boundTypeName);
}

Fixed version (ground truth):
/** 
 * Return the xmladapter class for a given bound type class name.
 * @param boundType
 * @return
 */
public JavaClass getPackageLevelAdapterClass(String boundTypeName){
  if (hasPackageLevelAdaptersByClass()) {
    return getPackageLevelAdaptersByClass().get(boundTypeName);
  }
  return null;
}
Program: 65578
Project: 65578
Buggy source:
/** 
 * Convenience method that adds non-null, non-transient properties to a given  List<Property>.  The propertyName parameter is used to lookup the Property. If propertyNamesCopy is non-null, the Property will be removed from that  List.  Any additional properties that exist for propertyName (as in the  case of multiple mappings to the same field) will be added as well.
 */
private void addPropertyToList(List<Property> propertiesInOrder,String propertyName,ArrayList<String> propertyNamesCopy){
  Property next=getProperties().get(propertyName);
  if (next != null && !next.isTransient()) {
    if (propertyNamesCopy != null) {
      propertyNamesCopy.remove(propertyName);
    }
    propertiesInOrder.add(next);
    List<Property> addProps=getAdditionalProperties().get(propertyName);
    if (addProps != null) {
      for (      Property addProp : addProps) {
        if (!addProp.isTransient()) {
          propertiesInOrder.add(addProp);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Convenience method that adds non-null, non-transient properties to a given  List<Property>.  The propertyName parameter is used to lookup the Property. If propertyNamesCopy is non-null, the Property will be removed from that  List.  Any additional properties that exist for propertyName (as in the  case of multiple mappings to the same field) will be added as well.
 */
private void addPropertyToList(List<Property> propertiesInOrder,String propertyName,ArrayList<String> propertyNamesCopy){
  Property next=getProperties().get(propertyName);
  if (next != null && !next.isTransient()) {
    if (propertyNamesCopy != null) {
      propertyNamesCopy.remove(propertyName);
    }
    propertiesInOrder.add(next);
    if (hasAdditionalProperties()) {
      List<Property> addProps=getAdditionalProperties().get(propertyName);
      if (addProps != null) {
        for (        Property addProp : addProps) {
          if (!addProp.isTransient()) {
            propertiesInOrder.add(addProp);
          }
        }
      }
    }
  }
}
Program: 65579
Project: 65579
Buggy source:
/** 
 * Return a Map of property names to list of properties.  This Map will contain entries when one or more properties exist for a given field, as in the case of multiple mappings for a single field.
 */
public Map<String,List<Property>> getAdditionalProperties(){
  if (additionalProperties == null) {
    additionalProperties=new HashMap<String,List<Property>>();
  }
  return additionalProperties;
}

Fixed version (ground truth):
/** 
 * Return a Map of property names to list of properties.  This Map will contain entries when one or more properties exist for a given field, as in the case of multiple mappings for a single field.
 */
public Map<String,List<Property>> getAdditionalProperties(){
  if (!hasAdditionalProperties()) {
    additionalProperties=new HashMap<String,List<Property>>();
  }
  return additionalProperties;
}
Program: 65580
Project: 65580
Buggy source:
/** 
 * This constructor sets the Helper to be used throughout XML and Annotations processing.  Other fields are initialized here as well.
 * @param helper
 */
public TypeInfo(Helper helper){
  propertyNames=new ArrayList<String>();
  properties=new HashMap<String,Property>();
  originalProperties=new HashMap<String,Property>();
  propertyList=new ArrayList<Property>();
  packageLevelAdaptersByClass=new HashMap<String,JavaClass>();
  xmlNameTransformer=DEFAULT_NAME_TRANSFORMER;
  isSetXmlTransient=false;
  isPreBuilt=false;
  isPostBuilt=false;
}

Fixed version (ground truth):
/** 
 * This constructor sets the Helper to be used throughout XML and Annotations processing.  Other fields are initialized here as well.
 * @param helper
 */
public TypeInfo(Helper helper){
  propertyNames=new ArrayList<String>();
  properties=new HashMap<String,Property>();
  originalProperties=new HashMap<String,Property>();
  propertyList=new ArrayList<Property>();
  xmlNameTransformer=DEFAULT_NAME_TRANSFORMER;
  isSetXmlTransient=false;
  isPreBuilt=false;
  isPostBuilt=false;
}
Program: 65581
Project: 65581
Buggy source:
/** 
 * Return the Map of XmlAdapters for this TypeInfo.
 * @return
 */
public HashMap<String,JavaClass> getPackageLevelAdaptersByClass(){
  return packageLevelAdaptersByClass;
}

Fixed version (ground truth):
/** 
 * Return the Map of XmlAdapters for this TypeInfo.
 * @return
 */
public HashMap<String,JavaClass> getPackageLevelAdaptersByClass(){
  if (!hasPackageLevelAdaptersByClass()) {
    packageLevelAdaptersByClass=new HashMap<String,JavaClass>();
  }
  return packageLevelAdaptersByClass;
}
Program: 65582
Project: 65582
Buggy source:
/** 
 * This method checks for class and package level adapters after the type of a property has been set.
 * @param prop the property that needs to be updated 
 * @param owningInfo the typeInfo that represents the owner of this property.
 */
public void reapplyPackageAndClassAdapters(Property prop,TypeInfo owningInfo){
  if (prop.getXmlJavaTypeAdapter() != null) {
    return;
  }
  JavaClass type=prop.getActualType();
  TypeInfo targetInfo=aProcessor.getTypeInfo().get(type.getQualifiedName());
  if (targetInfo != null) {
    if (targetInfo.getXmlJavaTypeAdapter() != null) {
      prop.setXmlJavaTypeAdapter(targetInfo.getXmlJavaTypeAdapter());
    }
  }
  JavaClass packageLevelAdapter=owningInfo.getPackageLevelAdaptersByClass().get(type.getQualifiedName());
  if (packageLevelAdapter != null && prop.getXmlJavaTypeAdapter() == null) {
    org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter xja=new org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter();
    xja.setValue(packageLevelAdapter.getQualifiedName());
    xja.setType(type.getQualifiedName());
    prop.setXmlJavaTypeAdapter(xja);
  }
}

Fixed version (ground truth):
/** 
 * This method checks for class and package level adapters after the type of a property has been set.
 * @param prop the property that needs to be updated 
 * @param owningInfo the typeInfo that represents the owner of this property.
 */
public void reapplyPackageAndClassAdapters(Property prop,TypeInfo owningInfo){
  if (prop.getXmlJavaTypeAdapter() != null) {
    return;
  }
  JavaClass type=prop.getActualType();
  TypeInfo targetInfo=aProcessor.getTypeInfo().get(type.getQualifiedName());
  if (targetInfo != null) {
    if (targetInfo.getXmlJavaTypeAdapter() != null) {
      prop.setXmlJavaTypeAdapter(targetInfo.getXmlJavaTypeAdapter());
    }
  }
  if (owningInfo.hasPackageLevelAdaptersByClass()) {
    JavaClass packageLevelAdapter=owningInfo.getPackageLevelAdaptersByClass().get(type.getQualifiedName());
    if (packageLevelAdapter != null && prop.getXmlJavaTypeAdapter() == null) {
      org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter xja=new org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter();
      xja.setValue(packageLevelAdapter.getQualifiedName());
      xja.setType(type.getQualifiedName());
      prop.setXmlJavaTypeAdapter(xja);
    }
  }
}
Program: 65584
Project: 65584
Buggy source:
/** 
 * Wrap the type in a type wrapper to handle XML conversion.
 */
public static DatabaseTypeWrapper wrapType(DatabaseType databaseType){
  if (databaseType.isComplexDatabaseType()) {
    ComplexDatabaseType complexType=(ComplexDatabaseType)databaseType;
    if (complexType.isJDBCType()) {
      return new OracleArrayTypeWrapper(databaseType);
    }
 else     if (complexType.isRecord()) {
      return new PLSQLRecordWrapper(databaseType);
    }
 else     if (complexType.isCollection()) {
      return new PLSQLCollectionWrapper(databaseType);
    }
  }
 else   if (databaseType.isJDBCType()) {
    return new JDBCTypeWrapper(databaseType);
  }
 else {
    return new SimplePLSQLTypeWrapper(databaseType);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Wrap the type in a type wrapper to handle XML conversion.
 */
public static DatabaseTypeWrapper wrapType(DatabaseType databaseType){
  if (databaseType.isComplexDatabaseType()) {
    ComplexDatabaseType complexType=(ComplexDatabaseType)databaseType;
    if (complexType.isJDBCType()) {
      if (complexType.isCollection()) {
        return new OracleArrayTypeWrapper(databaseType);
      }
      return new OracleObjectTypeWrapper(databaseType);
    }
 else     if (complexType.isRecord()) {
      return new PLSQLRecordWrapper(databaseType);
    }
 else     if (complexType.isCollection()) {
      return new PLSQLCollectionWrapper(databaseType);
    }
  }
 else   if (databaseType.isJDBCType()) {
    return new JDBCTypeWrapper(databaseType);
  }
 else {
    return new SimplePLSQLTypeWrapper(databaseType);
  }
  return null;
}
Program: 65585
Project: 65585
Buggy source:
protected ClassDescriptor buildDatabaseTypeWrapperDescriptor(){
  XMLDescriptor descriptor=new XMLDescriptor();
  descriptor.setJavaClass(DatabaseTypeWrapper.class);
  descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("String_Node_Str"));
  descriptor.getInheritancePolicy().addClassIndicator(JDBCTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(SimplePLSQLTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(PLSQLRecordWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(PLSQLCollectionWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(OracleArrayTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  return descriptor;
}

Fixed version (ground truth):
protected ClassDescriptor buildDatabaseTypeWrapperDescriptor(){
  XMLDescriptor descriptor=new XMLDescriptor();
  descriptor.setJavaClass(DatabaseTypeWrapper.class);
  descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("String_Node_Str"));
  descriptor.getInheritancePolicy().addClassIndicator(JDBCTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(SimplePLSQLTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(PLSQLRecordWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(PLSQLCollectionWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(OracleArrayTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  descriptor.getInheritancePolicy().addClassIndicator(OracleObjectTypeWrapper.class,getPrimaryNamespaceXPath() + "String_Node_Str");
  return descriptor;
}
Program: 65588
Project: 65588
Buggy source:
/** 
 * Tests the injected   {@link IJPQLQueryFormatter} and make sure the generated string will bethe same as the given JPQL query.
 * @param jpqlStateObject
 * @param jpqlQuery
 */
protected void testFormatter(JPQLQueryStateObject jpqlStateObject,String jpqlQuery){
  if (queryFormatter != null) {
    if (queryFormatter instanceof DefaultActualJPQLQueryFormatter && ((DefaultActualJPQLQueryFormatter)queryFormatter).getIdentifierStyle() == IdentifierStyle.CAPITALIZE_EACH_WORD && ((DefaultActualJPQLQueryFormatter)queryFormatter).isUsingExactMatch()) {
      System.out.println();
    }
    boolean exactMatch=false;
    IdentifierStyle stye=((BaseJPQLQueryFormatter)queryFormatter).getIdentifierStyle();
    if (queryFormatter instanceof AbstractActualJPQLQueryFormatter) {
      AbstractActualJPQLQueryFormatter formatter=(AbstractActualJPQLQueryFormatter)queryFormatter;
      exactMatch=formatter.isUsingExactMatch();
    }
    jpqlQuery=JPQLQueryBuilder.toText(jpqlQuery,jpqlStateObject.getGrammar(),exactMatch,stye);
    assertEquals("String_Node_Str",jpqlQuery,queryFormatter.toString(jpqlStateObject));
  }
}

Fixed version (ground truth):
/** 
 * Tests the injected   {@link IJPQLQueryFormatter} and make sure the generated string will bethe same as the given JPQL query.
 * @param jpqlStateObject
 * @param jpqlQuery
 */
protected void testFormatter(JPQLQueryStateObject jpqlStateObject,String jpqlQuery){
  if (queryFormatter != null) {
    boolean exactMatch=false;
    IdentifierStyle stye=((BaseJPQLQueryFormatter)queryFormatter).getIdentifierStyle();
    if (queryFormatter instanceof AbstractActualJPQLQueryFormatter) {
      AbstractActualJPQLQueryFormatter formatter=(AbstractActualJPQLQueryFormatter)queryFormatter;
      exactMatch=formatter.isUsingExactMatch();
    }
    jpqlQuery=JPQLQueryBuilder.toText(jpqlQuery,jpqlStateObject.getGrammar(),exactMatch,stye);
    assertEquals("String_Node_Str",jpqlQuery,queryFormatter.toString(jpqlStateObject));
  }
}
Program: 65590
Project: 65590
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;
        }
      }
    }
    return adapter.marshal(objectValue);
  }
 catch (  Exception ex) {
    throw ConversionException.couldNotBeConverted(objectValue,valueType);
  }
}

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;
        }
      }
    }
    return adapter.marshal(objectValue);
  }
 catch (  Exception ex) {
    throw ConversionException.couldNotBeConverted(objectValue,valueType,ex);
  }
}
Program: 65593
Project: 65593
Buggy source:
public AbstractRecord buildRow(AbstractRecord record,Object object,org.eclipse.persistence.internal.sessions.AbstractSession session,XMLMarshaller marshaller,XPathFragment rootFragment,WriteType writeType){
  lazyInitialize();
  if (null == rootXPathNode.getNonAttributeChildren()) {
    return record;
  }
  XMLDescriptor xmlDescriptor=(XMLDescriptor)descriptor;
  NamespaceResolver namespaceResolver=xmlDescriptor.getNamespaceResolver();
  MarshalContext marshalContext=null;
  if (xmlDescriptor.isSequencedObject()) {
    SequencedObject sequencedObject=(SequencedObject)object;
    marshalContext=new SequencedMarshalContext(sequencedObject.getSettings());
  }
 else {
    marshalContext=ObjectMarshalContext.getInstance();
  }
  for (int x=0, size=marshalContext.getNonAttributeChildrenSize(rootXPathNode); x < size; x++) {
    XPathNode xPathNode=(XPathNode)marshalContext.getNonAttributeChild(x,rootXPathNode);
    xPathNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext.getMarshalContext(x),rootFragment);
  }
  return record;
}

Fixed version (ground truth):
public AbstractRecord buildRow(AbstractRecord record,Object object,org.eclipse.persistence.internal.sessions.AbstractSession session,XMLMarshaller marshaller,XPathFragment rootFragment,WriteType writeType){
  lazyInitialize();
  XPathNode textNode=rootXPathNode.getTextNode();
  List<XPathNode> nonAttributeChildren=rootXPathNode.getNonAttributeChildren();
  if (null == textNode && null == nonAttributeChildren) {
    return record;
  }
  XMLDescriptor xmlDescriptor=(XMLDescriptor)descriptor;
  NamespaceResolver namespaceResolver=xmlDescriptor.getNamespaceResolver();
  MarshalContext marshalContext=null;
  if (xmlDescriptor.isSequencedObject()) {
    SequencedObject sequencedObject=(SequencedObject)object;
    marshalContext=new SequencedMarshalContext(sequencedObject.getSettings());
  }
 else {
    marshalContext=ObjectMarshalContext.getInstance();
  }
  if (null == nonAttributeChildren) {
    textNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext,rootFragment);
  }
 else {
    for (int x=0, size=marshalContext.getNonAttributeChildrenSize(rootXPathNode); x < size; x++) {
      XPathNode xPathNode=(XPathNode)marshalContext.getNonAttributeChild(x,rootXPathNode);
      xPathNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext.getMarshalContext(x),rootFragment);
    }
  }
  return record;
}
Program: 65596
Project: 65596
Buggy source:
/** 
 * INTERNAL: Set the cached SQL call for the expression query. PERF: Allow caching of expression query SQL call to avoid regeneration.
 */
public void putCachedExpressionQuery(DatabaseQuery query){
  this.cachedExpressionQueries.put(query,query);
}

Fixed version (ground truth):
/** 
 * INTERNAL: Set the cached SQL call for the expression query. PERF: Allow caching of expression query SQL call to avoid regeneration.
 */
public void putCachedExpressionQuery(DatabaseQuery query){
  getCachedExpressionQueries().put(query,query);
}
Program: 65597
Project: 65597
Buggy source:
/** 
 * ADVANCED: Return the max size of the expression query cache for avoiding regenerated dynamic query SQL.
 */
public int getExpressionQueryCacheMaxSize(){
  return cachedExpressionQueries.getMaxSize();
}

Fixed version (ground truth):
/** 
 * ADVANCED: Return the max size of the expression query cache for avoiding regenerated dynamic query SQL.
 */
public int getExpressionQueryCacheMaxSize(){
  return getCachedExpressionQueries().getMaxSize();
}
Program: 65598
Project: 65598
Buggy source:
/** 
 * INTERNAL: Initialize the state of the descriptor query manager
 */
public DescriptorQueryManager(){
  this.queries=new LinkedHashMap(5);
  this.cachedUpdateCalls=new ConcurrentFixedCache(10);
  this.cachedExpressionQueries=new ConcurrentFixedCache(20);
  setDoesExistQuery(new DoesExistQuery());
  this.setQueryTimeout(DefaultTimeout);
}

Fixed version (ground truth):
/** 
 * INTERNAL: Initialize the state of the descriptor query manager
 */
public DescriptorQueryManager(){
  this.queries=new LinkedHashMap(5);
  setDoesExistQuery(new DoesExistQuery());
  this.setQueryTimeout(DefaultTimeout);
}
Program: 65599
Project: 65599
Buggy source:
/** 
 * INTERNAL: Return the cached SQL call for the expression query. PERF: Allow caching of expression query SQL call to avoid regeneration.
 */
public DatabaseQuery getCachedExpressionQuery(DatabaseQuery query){
  return (DatabaseQuery)this.cachedExpressionQueries.get(query);
}

Fixed version (ground truth):
/** 
 * INTERNAL: Return the cached SQL call for the expression query. PERF: Allow caching of expression query SQL call to avoid regeneration.
 */
public DatabaseQuery getCachedExpressionQuery(DatabaseQuery query){
  return (DatabaseQuery)getCachedExpressionQueries().get(query);
}
Program: 65600
Project: 65600
Buggy source:
/** 
 * INTERNAL: Cache a clone of the update SQL calls based on the updated fields. If the max size is reached, do not cache the call. The call's query must be dereferenced in order to allow the GC of a related session. PERF: Allow caching of the update SQL call to avoid regeneration.
 */
public void putCachedUpdateCalls(Vector updateFields,Vector updateCalls){
  Vector vectorToCache=updateCalls;
  if (!updateCalls.isEmpty()) {
    int updateCallsSize=updateCalls.size();
    vectorToCache=new NonSynchronizedVector(updateCallsSize);
    for (int i=0; i < updateCallsSize; i++) {
      DatasourceCall updateCall=(DatasourceCall)updateCalls.get(i);
      DatasourceCall clonedUpdateCall=(DatasourceCall)updateCall.clone();
      clonedUpdateCall.setQuery(null);
      vectorToCache.add(clonedUpdateCall);
    }
  }
  this.cachedUpdateCalls.put(updateFields,vectorToCache);
}

Fixed version (ground truth):
/** 
 * INTERNAL: Cache a clone of the update SQL calls based on the updated fields. If the max size is reached, do not cache the call. The call's query must be dereferenced in order to allow the GC of a related session. PERF: Allow caching of the update SQL call to avoid regeneration.
 */
public void putCachedUpdateCalls(Vector updateFields,Vector updateCalls){
  Vector vectorToCache=updateCalls;
  if (!updateCalls.isEmpty()) {
    int updateCallsSize=updateCalls.size();
    vectorToCache=new NonSynchronizedVector(updateCallsSize);
    for (int i=0; i < updateCallsSize; i++) {
      DatasourceCall updateCall=(DatasourceCall)updateCalls.get(i);
      DatasourceCall clonedUpdateCall=(DatasourceCall)updateCall.clone();
      clonedUpdateCall.setQuery(null);
      vectorToCache.add(clonedUpdateCall);
    }
  }
  getCachedUpdateCalls().put(updateFields,vectorToCache);
}
Program: 65601
Project: 65601
Buggy source:
/** 
 * INTERNAL: Return the cached update SQL call based on the updated fields. PERF: Allow caching of the update SQL call to avoid regeneration.
 */
public Vector getCachedUpdateCalls(Vector updateFields){
  return (Vector)this.cachedUpdateCalls.get(updateFields);
}

Fixed version (ground truth):
/** 
 * INTERNAL: Return the cached update SQL call based on the updated fields. PERF: Allow caching of the update SQL call to avoid regeneration.
 */
public Vector getCachedUpdateCalls(Vector updateFields){
  return (Vector)getCachedUpdateCalls().get(updateFields);
}
Program: 65602
Project: 65602
Buggy source:
/** 
 * ADVANCED: Return the size of the update call cache. The update call cache is used to cache the update SQL to avoid regeneration. Since every update with different fields produces different SQL, this cache allows caching of the update SQL based on the fields being updated. The default cache size is 10, the update call cache can be disabled through setting the size to 0.
 */
public int getUpdateCallCacheSize(){
  return this.cachedUpdateCalls.getMaxSize();
}

Fixed version (ground truth):
/** 
 * ADVANCED: Return the size of the update call cache. The update call cache is used to cache the update SQL to avoid regeneration. Since every update with different fields produces different SQL, this cache allows caching of the update SQL based on the fields being updated. The default cache size is 10, the update call cache can be disabled through setting the size to 0.
 */
public int getUpdateCallCacheSize(){
  return getCachedUpdateCalls().getMaxSize();
}
Program: 65603
Project: 65603
Buggy source:
/** 
 * ADVANCED: Set the size of the update call cache. The update call cache is used to cache the update SQL to avoid regeneration. Since every update with different fields produces different SQL, this cache allows caching of the update SQL based on the fields being updated. The default cache size is 10, the update call cache can be disabled through setting the size to 0.
 */
public void setUpdateCallCacheSize(int updateCallCacheSize){
  this.cachedUpdateCalls.setMaxSize(updateCallCacheSize);
}

Fixed version (ground truth):
/** 
 * ADVANCED: Set the size of the update call cache. The update call cache is used to cache the update SQL to avoid regeneration. Since every update with different fields produces different SQL, this cache allows caching of the update SQL based on the fields being updated. The default cache size is 10, the update call cache can be disabled through setting the size to 0.
 */
public void setUpdateCallCacheSize(int updateCallCacheSize){
  getCachedUpdateCalls().setMaxSize(updateCallCacheSize);
}
Program: 65604
Project: 65604
Buggy source:
/** 
 * Convenience method for determining if a given JavaClass should be processed as an ObjectFactory class.
 * @param javaClass
 * @return true if the JavaClass is annotated with @XmlRegistry or the mapof XmlRegistries contains a key equal to the JavaClass' qualified name
 */
private boolean isXmlRegistry(JavaClass javaClass){
  return (helper.isAnnotationPresent(javaClass,XmlRegistry.class) || xmlRegistries.get(javaClass.getQualifiedName()) != null);
}

Fixed version (ground truth):
/** 
 * Convenience method for determining if a given JavaClass should be processed as an ObjectFactory class.
 * @param javaClass
 * @return true if the JavaClass is annotated with @XmlRegistry or the mapof XmlRegistries contains a key equal to the JavaClass' qualified name
 */
private boolean isXmlRegistry(JavaClass javaClass){
  if (javaClass == null) {
    return false;
  }
  return (helper.isAnnotationPresent(javaClass,XmlRegistry.class) || xmlRegistries.get(javaClass.getQualifiedName()) != null);
}
Program: 65605
Project: 65605
Buggy source:
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHAR2ARRAY_TYPE,ddlDebug);
  }
}

Fixed version (ground truth):
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE,ddlDebug);
    runDdl(conn,DROP_A_CUSTOMER2_TYPE,ddlDebug);
    runDdl(conn,DROP_A_CONTACT2_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHAR2ARRAY_TYPE,ddlDebug);
  }
}
Program: 65607
Project: 65607
Buggy source:
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHARARRAY_TYPE,ddlDebug);
  }
}

Fixed version (ground truth):
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE,ddlDebug);
    runDdl(conn,DROP_A_CUSTOMER_TYPE,ddlDebug);
    runDdl(conn,DROP_A_CONTACT_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHARARRAY_TYPE,ddlDebug);
  }
}
Program: 65612
Project: 65612
Buggy source:
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHAR2ARRAY_TYPE,ddlDebug);
  }
}

Fixed version (ground truth):
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_PACKAGE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG2_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_A_PHONE2_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHAR2ARRAY_TYPE,ddlDebug);
  }
}
Program: 65614
Project: 65614
Buggy source:
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHARARRAY_TYPE,ddlDebug);
  }
}

Fixed version (ground truth):
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE_BODY,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_PACKAGE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_TAB1_TYPE,ddlDebug);
    runDdl(conn,DROP_COMPLEXPKG_SIMPLERECORD_TYPE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_A_PHONE_TYPE,ddlDebug);
    runDdl(conn,DROP_VARCHARARRAY_TYPE,ddlDebug);
  }
}
Program: 65617
Project: 65617
Buggy source:
public void testTypeArray() throws Exception {
  Type[] types=new Type[]{String.class};
  JAXBContext ctx=(JAXBContext)JAXBContextFactory.createContext(types,null,Thread.currentThread().getContextClassLoader());
  Map<Type,QName> typeMap=ctx.getTypeToSchemaType();
  assertEquals(1,typeMap.size());
  assertNotNull(typeMap.get(String.class));
  Map<TypeMappingInfo,QName> tmiMap=ctx.getTypeMappingInfoToSchemaType();
  assertEquals(0,tmiMap.size());
}

Fixed version (ground truth):
public void testTypeArray() throws Exception {
  Type[] types=new Type[]{String.class};
  JAXBContext ctx=(JAXBContext)JAXBContextFactory.createContext(types,null,Thread.currentThread().getContextClassLoader());
  ctx.refreshMetadata();
  Map<Type,QName> typeMap=ctx.getTypeToSchemaType();
  assertEquals(1,typeMap.size());
  assertNotNull(typeMap.get(String.class));
  Map<TypeMappingInfo,QName> tmiMap=ctx.getTypeMappingInfoToSchemaType();
  assertEquals(0,tmiMap.size());
}
Program: 65618
Project: 65618
Buggy source:
/** 
 * Generate a Schema for this JAXBContext
 * @param outputResolver Class that decides where the schema file (of the given namespace URI) will be written
 * @param additonalGlobalElements Map of additional global elements to be added to the generated XSD.Note that if any QName in this map conflicts with another global element (for example from a TypeMappingInfo object) then the element generated from this map will be the one that is present in the XSD.
 */
public void generateSchema(SchemaOutputResolver outputResolver,Map<QName,Type> additonalGlobalElements){
  JAXBContextState currentJAXBContextState=contextState;
  XMLContext xmlContext=currentJAXBContextState.getXMLContext();
  Generator generator=currentJAXBContextState.getGenerator();
  if (generator == null) {
    List<XMLDescriptor> descriptorsToProcess=new ArrayList<XMLDescriptor>();
    List<Session> sessions=xmlContext.getSessions();
    for (    Session session : sessions) {
      List<XMLDescriptor> descriptors=(List<XMLDescriptor>)(List)session.getProject().getOrderedDescriptors();
      for (      XMLDescriptor xDesc : descriptors) {
        descriptorsToProcess.add(xDesc);
      }
    }
    SchemaModelGenerator smGen=new SchemaModelGenerator();
    smGen.generateSchemas(descriptorsToProcess,null,new JAXBSchemaOutputResolver(outputResolver),additonalGlobalElements);
  }
 else {
    generator.generateSchemaFiles(outputResolver,additonalGlobalElements);
  }
}

Fixed version (ground truth):
/** 
 * Generate a Schema for this JAXBContext
 * @param outputResolver Class that decides where the schema file (of the given namespace URI) will be written
 * @param additonalGlobalElements Map of additional global elements to be added to the generated XSD.Note that if any QName in this map conflicts with another global element (for example from a TypeMappingInfo object) then the element generated from this map will be the one that is present in the XSD.
 */
public void generateSchema(SchemaOutputResolver outputResolver,Map<QName,Type> additonalGlobalElements){
  JAXBContextState currentJAXBContextState=contextState;
  if (isRefreshable()) {
    try {
      currentJAXBContextState=newContextState();
    }
 catch (    Exception e) {
      throw JAXBException.exceptionDuringSchemaGeneration(e);
    }
  }
  XMLContext xmlContext=currentJAXBContextState.getXMLContext();
  Generator generator=currentJAXBContextState.getGenerator();
  if (generator == null) {
    List<XMLDescriptor> descriptorsToProcess=new ArrayList<XMLDescriptor>();
    List<Session> sessions=xmlContext.getSessions();
    for (    Session session : sessions) {
      List<XMLDescriptor> descriptors=(List<XMLDescriptor>)(List)session.getProject().getOrderedDescriptors();
      for (      XMLDescriptor xDesc : descriptors) {
        descriptorsToProcess.add(xDesc);
      }
    }
    SchemaModelGenerator smGen=new SchemaModelGenerator();
    smGen.generateSchemas(descriptorsToProcess,null,new JAXBSchemaOutputResolver(outputResolver),additonalGlobalElements);
  }
 else {
    generator.generateSchemaFiles(outputResolver,additonalGlobalElements);
  }
}
Program: 65619
Project: 65619
Buggy source:
/** 
 * ADVANCED: <p>Refresh the underlying metadata based on the inputs that were used to create the JAXBContext.  This is particularly useful when using the virtual property mappings.  The refreshMetadata call could be made in the following way:</p> <pre>org.eclipse.persistence.jaxb.JAXBHelper.getJAXBContext(aJAXBContext).refreshMetadata();</pre> <b>Note:</b> <ul> <li>As instances of Binder maintain a cache, calling refreshMetadata will not affect instances of Binder.  To get the new metadata you must create a new instance of Binder after the refresh metadata call has been made.</li> </ul>
 * @throws javax.xml.bind.JAXBException
 */
public void refreshMetadata() throws javax.xml.bind.JAXBException {
  if (null == contextInput) {
    return;
  }
synchronized (this) {
    JAXBContextState newState=contextInput.createContextState();
    XMLContext xmlContext=getXMLContext();
    xmlContext.setXMLContextState(newState.getXMLContext().getXMLContextState());
    newState.setXMLContext(xmlContext);
    contextState=newState;
  }
}

Fixed version (ground truth):
/** 
 * ADVANCED: <p>Refresh the underlying metadata based on the inputs that were used to create the JAXBContext.  This is particularly useful when using the virtual property mappings.  The refreshMetadata call could be made in the following way:</p> <pre>org.eclipse.persistence.jaxb.JAXBHelper.getJAXBContext(aJAXBContext).refreshMetadata();</pre> <b>Note:</b> <ul> <li>As instances of Binder maintain a cache, calling refreshMetadata will not affect instances of Binder.  To get the new metadata you must create a new instance of Binder after the refresh metadata call has been made.</li> </ul>
 * @throws javax.xml.bind.JAXBException
 */
public void refreshMetadata() throws javax.xml.bind.JAXBException {
  JAXBContextState newState=newContextState();
  if (newState != null) {
    contextState=newState;
  }
}
Program: 65620
Project: 65620
Buggy source:
private void setTypeToTypeMappingInfo(Map<Type,TypeMappingInfo> typeToMappingInfo){
  this.typeToTypeMappingInfo=typeToMappingInfo;
  this.generator.setTypeToTypeMappingInfo(typeToMappingInfo);
}

Fixed version (ground truth):
private void setTypeToTypeMappingInfo(Map<Type,TypeMappingInfo> typeToMappingInfo){
  this.typeToTypeMappingInfo=typeToMappingInfo;
  if (this.generator != null) {
    this.generator.setTypeToTypeMappingInfo(typeToMappingInfo);
  }
}
Program: 65621
Project: 65621
Buggy source:
/** 
 * Create a JAXBContext on the array of TypeMappingInfo objects.  The JAXBContext will also be aware of classes reachable from the types in the array.  This is the preferred means of creating a Type aware JAXBContext.
 */
public static javax.xml.bind.JAXBContext createContext(TypeMappingInfo[] typesToBeBound,Map properties,ClassLoader classLoader) throws JAXBException {
  JAXBContextInput contextInput=new TypeMappingInfoInput(typesToBeBound,properties,classLoader);
  return new JAXBContext(contextInput);
}

Fixed version (ground truth):
/** 
 * Create a JAXBContext on the array of TypeMappingInfo objects.  The JAXBContext will also be aware of classes reachable from the types in the array.  This is the preferred means of creating a Type aware JAXBContext.
 */
public static javax.xml.bind.JAXBContext createContext(TypeMappingInfo[] typesToBeBound,Map properties,ClassLoader classLoader) throws JAXBException {
  JAXBContextInput contextInput=new TypeMappingInfoInput(typesToBeBound,properties,classLoader);
  JAXBContext context=new JAXBContext(contextInput);
  if (context.isRefreshable()) {
    context.postInitialize();
  }
  return context;
}
Program: 65622
Project: 65622
Buggy source:
protected List addExtraNamespacesToNamespaceResolver(XMLDescriptor desc,XMLRecord marshalRecord,AbstractSession session){
  if (((XMLLogin)session.getDatasourceLogin()).hasEqualNamespaceResolvers()) {
    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=marshalRecord.getNamespaceResolver();
  for (  Entry<String,String> entry : prefixesToNamespaces.entrySet()) {
    String prefix=marshalRecordNamespaceResolver.resolveNamespaceURI(entry.getValue());
    if (prefix == null || prefix.length() == 0) {
      prefix=entry.getKey();
      String uri=marshalRecordNamespaceResolver.resolveNamespacePrefix(prefix);
      if (uri == null || uri.length() == 0) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(entry.getKey(),entry.getValue()));
      }
    }
  }
  return returnList;
}

Fixed version (ground truth):
protected List addExtraNamespacesToNamespaceResolver(XMLDescriptor desc,XMLRecord marshalRecord,AbstractSession session,boolean allowOverride){
  if (((XMLLogin)session.getDatasourceLogin()).hasEqualNamespaceResolvers()) {
    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=marshalRecord.getNamespaceResolver();
  for (  Entry<String,String> entry : prefixesToNamespaces.entrySet()) {
    String prefix=marshalRecordNamespaceResolver.resolveNamespaceURI(entry.getValue());
    if (prefix == null || prefix.length() == 0) {
      prefix=entry.getKey();
      String uri=marshalRecordNamespaceResolver.resolveNamespacePrefix(prefix);
      if (allowOverride || uri == null || uri.length() == 0) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(entry.getKey(),entry.getValue()));
      }
    }
 else     if (allowOverride) {
      if (!prefix.equals(entry.getKey())) {
        marshalRecordNamespaceResolver.put(entry.getKey(),entry.getValue());
        returnList.add(new Namespace(entry.getKey(),entry.getValue()));
      }
    }
  }
  return returnList;
}
Program: 65623
Project: 65623
Buggy source:
public AbstractRecord buildIntoNestedRow(AbstractRecord row,Object originalObject,Object object,AbstractSession session,XMLDescriptor refDesc,XMLField xmlField,boolean wasXMLRoot){
  XMLRecord record=(XMLRecord)row;
  record.setSession(session);
  XMLMarshaller marshaller=record.getMarshaller();
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().beforeMarshal(object);
  }
  List extraNamespaces=null;
  if (isXmlDescriptor()) {
    XMLDescriptor xmlDescriptor=(XMLDescriptor)getDescriptor();
    extraNamespaces=addExtraNamespacesToNamespaceResolver(xmlDescriptor,record,session);
    writeExtraNamespaces(extraNamespaces,record);
    addXsiTypeAndClassIndicatorIfRequired(record,xmlDescriptor,refDesc,xmlField,originalObject,object,wasXMLRoot,false);
  }
  writeOutMappings(record,object,session);
  if (isXmlDescriptor()) {
    XMLDescriptor xmlDescriptor=(XMLDescriptor)getDescriptor();
    removeExtraNamespacesFromNamespaceResolver(record,extraNamespaces,session);
  }
  if (!getDescriptor().isAggregateDescriptor()) {
    addPrimaryKeyForNonDefaultTable(row);
  }
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().afterMarshal(object);
  }
  return row;
}

Fixed version (ground truth):
public AbstractRecord buildIntoNestedRow(AbstractRecord row,Object originalObject,Object object,AbstractSession session,XMLDescriptor refDesc,XMLField xmlField,boolean wasXMLRoot){
  XMLRecord record=(XMLRecord)row;
  record.setSession(session);
  XMLMarshaller marshaller=record.getMarshaller();
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().beforeMarshal(object);
  }
  List extraNamespaces=null;
  if (isXmlDescriptor()) {
    XMLDescriptor xmlDescriptor=(XMLDescriptor)getDescriptor();
    extraNamespaces=addExtraNamespacesToNamespaceResolver(xmlDescriptor,record,session,false);
    writeExtraNamespaces(extraNamespaces,record);
    addXsiTypeAndClassIndicatorIfRequired(record,xmlDescriptor,refDesc,xmlField,originalObject,object,wasXMLRoot,false);
  }
  writeOutMappings(record,object,session);
  if (isXmlDescriptor()) {
    XMLDescriptor xmlDescriptor=(XMLDescriptor)getDescriptor();
    removeExtraNamespacesFromNamespaceResolver(record,extraNamespaces,session);
  }
  if (!getDescriptor().isAggregateDescriptor()) {
    addPrimaryKeyForNonDefaultTable(row);
  }
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().afterMarshal(object);
  }
  return row;
}
Program: 65624
Project: 65624
Buggy source:
public Element createUnownedElement(Node parent,XMLField xmlField){
  XPathFragment lastFragment=xmlField.getXPathFragment();
  while (lastFragment.getNextFragment() != null) {
    lastFragment=lastFragment.getNextFragment();
  }
  String nodeName=lastFragment.getShortName();
  String namespace=resolveNamespacePrefix(lastFragment,getNamespaceResolverForField(xmlField));
  Element elem=parent.getOwnerDocument().createElementNS(namespace,nodeName);
  if (lastFragment.isGeneratedPrefix()) {
    elem.setAttributeNS(XMLConstants.XMLNS_URL,XMLConstants.XMLNS + XMLConstants.COLON + lastFragment.getPrefix(),lastFragment.getNamespaceURI());
  }
  return elem;
}

Fixed version (ground truth):
public Element createUnownedElement(Node parent,XMLField xmlField){
  XPathFragment lastFragment=xmlField.getXPathFragment();
  while (lastFragment.getNextFragment() != null) {
    lastFragment=lastFragment.getNextFragment();
  }
  String nodeName=lastFragment.getShortName();
  String namespace=resolveNamespacePrefix(lastFragment,getNamespaceResolverForField(xmlField));
  NamespaceResolver domResolver=new NamespaceResolver();
  domResolver.setDOM(parent);
  String existingPrefix=domResolver.resolveNamespaceURI(namespace);
  String elementName=lastFragment.getShortName();
  if (existingPrefix != null) {
    if (existingPrefix.length() > 0) {
      elementName=existingPrefix + "String_Node_Str" + lastFragment.getLocalName();
    }
 else {
      elementName=lastFragment.getLocalName();
    }
  }
  Element elem=parent.getOwnerDocument().createElementNS(namespace,elementName);
  if (lastFragment.isGeneratedPrefix() && existingPrefix == null) {
    elem.setAttributeNS(XMLConstants.XMLNS_URL,XMLConstants.XMLNS + XMLConstants.COLON + lastFragment.getPrefix(),lastFragment.getNamespaceURI());
  }
  return elem;
}
Program: 65625
Project: 65625
Buggy source:
/** 
 * Returns the namespace URI associated with a specified namespace prefix
 * @param prefix The prefix to lookup a namespace URI for
 * @return The namespace URI associated with the specified prefix
 */
public String resolveNamespacePrefix(String prefix){
  if (null == prefix || prefix.length() == 0) {
    return defaultNamespaceURI;
  }
  String uri=null;
  if (null != prefixesToNamespaces) {
    uri=prefixesToNamespaces.get(prefix);
  }
  if (null != uri) {
    return uri;
  }
 else   if (XMLConstants.XML_NAMESPACE_PREFIX.equals(prefix)) {
    return XMLConstants.XML_NAMESPACE_URL;
  }
 else   if (XMLConstants.XMLNS.equals(prefix)) {
    return XMLConstants.XMLNS_URL;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the namespace URI associated with a specified namespace prefix
 * @param prefix The prefix to lookup a namespace URI for
 * @return The namespace URI associated with the specified prefix
 */
public String resolveNamespacePrefix(String prefix){
  if (null == prefix || prefix.length() == 0) {
    return defaultNamespaceURI;
  }
  String uri=null;
  if (null != prefixesToNamespaces) {
    uri=prefixesToNamespaces.get(prefix);
  }
  if (null != uri) {
    return uri;
  }
 else   if (XMLConstants.XML_NAMESPACE_PREFIX.equals(prefix)) {
    return XMLConstants.XML_NAMESPACE_URL;
  }
 else   if (XMLConstants.XMLNS.equals(prefix)) {
    return XMLConstants.XMLNS_URL;
  }
  if (dom != null) {
    return XMLPlatformFactory.getInstance().getXMLPlatform().resolveNamespacePrefix(dom,prefix);
  }
  return null;
}
Program: 65626
Project: 65626
Buggy source:
private String resolveNamespaceURI(Node node,String uri){
  if (null == node) {
    return null;
  }
  if (uri.equals(node.getNamespaceURI())) {
    return node.getPrefix();
  }
  NamedNodeMap namedNodeMap=node.getAttributes();
  if (null != namedNodeMap) {
    int namedNodeMapSize=namedNodeMap.getLength();
    for (int x=0; x < namedNodeMapSize; x++) {
      Node attr=namedNodeMap.item(x);
      if (XMLConstants.XMLNS_URL.equals(attr.getNamespaceURI())) {
        if (uri.equals(attr.getNodeValue())) {
          return attr.getLocalName();
        }
      }
    }
  }
  return resolveNamespaceURI(node.getParentNode(),uri);
}

Fixed version (ground truth):
private String resolveNamespaceURI(Node node,String uri){
  if (null == node) {
    return null;
  }
  if (uri.equals(node.getNamespaceURI())) {
    return node.getPrefix();
  }
  NamedNodeMap namedNodeMap=node.getAttributes();
  if (null != namedNodeMap) {
    int namedNodeMapSize=namedNodeMap.getLength();
    for (int x=0; x < namedNodeMapSize; x++) {
      Node attr=namedNodeMap.item(x);
      if (XMLConstants.XMLNS_URL.equals(attr.getNamespaceURI())) {
        if (uri.equals(attr.getNodeValue())) {
          if (attr.getLocalName() != null && (!(attr.getLocalName().equals(XMLConstants.XMLNS)))) {
            return attr.getLocalName();
          }
 else {
            return "String_Node_Str";
          }
        }
      }
    }
  }
  return resolveNamespaceURI(node.getParentNode(),uri);
}