nus-yam/ex-repair huggingface dataset:
Program: 63901
Project: 63901
Buggy source:
private ArrayList<Property> removeSuperclassProperties(JavaClass cls,ArrayList<Property> properties){
  ArrayList<Property> revisedProperties=new ArrayList<Property>();
  revisedProperties.addAll(properties);
  JavaClass superClass=cls.getSuperclass();
  if (null != superClass) {
    TypeInfo superClassInfo=typeInfo.get(superClass.getQualifiedName());
    if (superClassInfo != null && !superClassInfo.isTransient()) {
      for (      Property prop : properties) {
        for (        Property superProp : superClassInfo.getProperties().values()) {
          if (superProp.getGetMethodName() != null && superProp.getGetMethodName().equals(prop.getGetMethodName())) {
            revisedProperties.remove(prop);
          }
        }
      }
    }
  }
  return revisedProperties;
}

Fixed version (ground truth):
private ArrayList<Property> removeSuperclassProperties(JavaClass cls,ArrayList<Property> properties){
  ArrayList<Property> revisedProperties=new ArrayList<Property>();
  revisedProperties.addAll(properties);
  JavaClass superClass=cls.getSuperclass();
  if (null != superClass) {
    TypeInfo superClassInfo=typeInfo.get(superClass.getQualifiedName());
    if (superClassInfo != null && !superClassInfo.isTransient()) {
      for (      Property prop : properties) {
        for (        Property superProp : superClassInfo.getProperties().values()) {
          if (superProp.getGetMethodName() != null && superProp.getGetMethodName().equals(prop.getGetMethodName()) && !superProp.isTransient()) {
            revisedProperties.remove(prop);
          }
        }
      }
    }
  }
  return revisedProperties;
}
Program: 63905
Project: 63905
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Object collection){
  String value=unmarshalRecord.getCharacters().toString();
  unmarshalRecord.resetStringBuffer();
  Field xmlField=(Field)xmlCompositeDirectCollectionMapping.getField();
  if (xmlField.usesSingleNode()) {
    StringTokenizer stringTokenizer=new StringTokenizer(value);
    while (stringTokenizer.hasMoreTokens()) {
      addUnmarshalValue(unmarshalRecord,stringTokenizer.nextToken(),collection);
    }
  }
 else {
    if (xmlField.getLastXPathFragment().nameIsText()) {
      if (!unmarshalRecord.getXMLReader().isInCollection() && unmarshalRecord.isNil()) {
        unmarshalRecord.setAttributeValueNull(this);
      }
 else {
        addUnmarshalValue(unmarshalRecord,value,collection);
      }
    }
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Object collection){
  Field xmlField=(Field)xmlCompositeDirectCollectionMapping.getField();
  Object value=unmarshalRecord.getCharacters().toString();
  if (((String)value).length() == 0 && !xmlField.usesSingleNode()) {
    if (xmlCompositeDirectCollectionMapping.getNullValue() != null) {
      value=xmlCompositeDirectCollectionMapping.getNullValue();
    }
  }
  unmarshalRecord.resetStringBuffer();
  if (xmlField.usesSingleNode() && value instanceof String) {
    StringTokenizer stringTokenizer=new StringTokenizer((String)value);
    while (stringTokenizer.hasMoreTokens()) {
      addUnmarshalValue(unmarshalRecord,stringTokenizer.nextToken(),collection);
    }
  }
 else {
    if (xmlField.getLastXPathFragment().nameIsText()) {
      if (!unmarshalRecord.getXMLReader().isInCollection() && unmarshalRecord.isNil()) {
        unmarshalRecord.setAttributeValueNull(this);
      }
 else {
        addUnmarshalValue(unmarshalRecord,value,collection);
      }
    }
  }
}
Program: 63907
Project: 63907
Buggy source:
/** 
 * Make adjustments to an unmarshalled entity based on what is found in the weaved fields
 * @param entity
 * @return
 */
protected Object wrap(Object entity){
  if (!doesExist(null,entity)) {
    return entity;
  }
  ClassDescriptor descriptor=getJAXBDescriptorForClass(entity.getClass());
  if (entity instanceof FetchGroupTracker) {
    FetchGroup fetchGroup=new FetchGroup();
    for (    DatabaseMapping mapping : descriptor.getMappings()) {
      if (!(mapping instanceof XMLInverseReferenceMapping)) {
        fetchGroup.addAttribute(mapping.getAttributeName());
      }
    }
    (new FetchGroupManager()).setObjectFetchGroup(entity,fetchGroup,null);
    ((FetchGroupTracker)entity)._persistence_setSession(JpaHelper.getDatabaseSession(getEmf()));
  }
 else   if (descriptor.hasRelationships()) {
    for (    DatabaseMapping mapping : descriptor.getMappings()) {
      if (mapping instanceof XMLInverseReferenceMapping) {
        throw new JPARSConfigurationException(LoggingLocalization.buildMessage("String_Node_Str",new Object[]{}));
      }
    }
  }
  return entity;
}

Fixed version (ground truth):
/** 
 * Make adjustments to an unmarshalled entity based on what is found in the weaved fields
 * @param entity
 * @return
 */
protected Object wrap(Object entity){
  if ((entity != null) && (PersistenceWeavedRest.class.isAssignableFrom(entity.getClass()))) {
    if (!doesExist(null,entity)) {
      return entity;
    }
    ClassDescriptor descriptor=getJAXBDescriptorForClass(entity.getClass());
    if (entity instanceof FetchGroupTracker) {
      FetchGroup fetchGroup=new FetchGroup();
      for (      DatabaseMapping mapping : descriptor.getMappings()) {
        if (!(mapping instanceof XMLInverseReferenceMapping)) {
          fetchGroup.addAttribute(mapping.getAttributeName());
        }
      }
      (new FetchGroupManager()).setObjectFetchGroup(entity,fetchGroup,null);
      ((FetchGroupTracker)entity)._persistence_setSession(JpaHelper.getDatabaseSession(getEmf()));
    }
 else     if (descriptor.hasRelationships()) {
      for (      DatabaseMapping mapping : descriptor.getMappings()) {
        if (mapping instanceof XMLInverseReferenceMapping) {
          throw new JPARSConfigurationException(LoggingLocalization.buildMessage("String_Node_Str",new Object[]{}));
        }
      }
    }
  }
  return entity;
}
Program: 63909
Project: 63909
Buggy source:
/** 
 * Create a javaType to be used by JAXB to map a particular class. For static classes, JAXB annotations, xml and defaults will be used to map the class. For Dynamic classes we create properties for each JPA mapping on the class thing we create is a 
 * @param classDescriptor
 * @param objectFactory
 * @return
 */
private JavaType createJAXBType(ClassDescriptor classDescriptor,ObjectFactory objectFactory){
  JavaType javaType=new JavaType();
  String alias=classDescriptor.getAlias();
  if (alias == null || alias.isEmpty()) {
    alias=classDescriptor.getJavaClass().getSimpleName();
  }
  javaType.setName(alias);
  javaType.setJavaAttributes(new JavaAttributes());
  boolean isDynamic=DynamicEntity.class.isAssignableFrom(classDescriptor.getJavaClass());
  for (  DatabaseMapping ormMapping : classDescriptor.getMappings()) {
    JAXBElement<XmlElement> element=createJAXBProperty(ormMapping,objectFactory,javaType,isDynamic);
    if (element != null) {
      javaType.getJavaAttributes().getJavaAttribute().add(element);
    }
  }
  javaType.setXmlRootElement(new org.eclipse.persistence.jaxb.xmlmodel.XmlRootElement());
  if (classDescriptor.isAggregateDescriptor()) {
    return javaType;
  }
  String name=RestAdapterClassWriter.constructClassNameForReferenceAdapter(classDescriptor.getJavaClassName());
  XmlJavaTypeAdapter adapter=new XmlJavaTypeAdapter();
  adapter.setValue(name);
  adapter.setValueType(classDescriptor.getJavaClassName());
  adapter.setType(classDescriptor.getJavaClassName());
  javaType.setXmlJavaTypeAdapter(adapter);
  return javaType;
}

Fixed version (ground truth):
/** 
 * Create a javaType to be used by JAXB to map a particular class. For static classes, JAXB annotations, xml and defaults will be used to map the class. For Dynamic classes we create properties for each JPA mapping on the class thing we create is a 
 * @param classDescriptor
 * @param objectFactory
 * @return
 */
private JavaType createJAXBType(ClassDescriptor classDescriptor,ObjectFactory objectFactory){
  JavaType javaType=new JavaType();
  String alias=classDescriptor.getAlias();
  if (alias == null || alias.isEmpty()) {
    alias=classDescriptor.getJavaClass().getSimpleName();
  }
  javaType.setName(alias);
  javaType.setJavaAttributes(new JavaAttributes());
  boolean isDynamic=DynamicEntity.class.isAssignableFrom(classDescriptor.getJavaClass());
  for (  DatabaseMapping ormMapping : classDescriptor.getMappings()) {
    JAXBElement<XmlElement> element=createJAXBProperty(ormMapping,objectFactory,javaType,isDynamic);
    if (element != null) {
      javaType.getJavaAttributes().getJavaAttribute().add(element);
    }
  }
  if (classDescriptor.isAggregateDescriptor()) {
    return javaType;
  }
  String name=RestAdapterClassWriter.constructClassNameForReferenceAdapter(classDescriptor.getJavaClassName());
  XmlJavaTypeAdapter adapter=new XmlJavaTypeAdapter();
  adapter.setValue(name);
  adapter.setValueType(classDescriptor.getJavaClassName());
  adapter.setType(classDescriptor.getJavaClassName());
  javaType.setXmlJavaTypeAdapter(adapter);
  return javaType;
}
Program: 63910
Project: 63910
Buggy source:
protected XMLDescriptor buildDeleteDescriptor(){
  XMLDescriptor descriptor=new XMLDescriptor();
  descriptor.setJavaClass(DeleteOperation.class);
  descriptor.setDefaultRootElement("String_Node_Str");
  XMLDirectMapping name=new XMLDirectMapping();
  name.setAttributeName("String_Node_Str");
  name.setXPath("String_Node_Str");
  descriptor.addMapping(name);
  XMLDirectMapping descriptorName=new XMLDirectMapping();
  descriptorName.setAttributeName("String_Node_Str");
  descriptorName.setXPath("String_Node_Str");
  descriptor.addMapping(descriptorName);
  XMLCompositeCollectionMapping parameters=new XMLCompositeCollectionMapping();
  parameters.setAttributeName("String_Node_Str");
  parameters.setReferenceClass(Parameter.class);
  parameters.setXPath("String_Node_Str");
  descriptor.addMapping(parameters);
  return descriptor;
}

Fixed version (ground truth):
protected XMLDescriptor buildDeleteDescriptor(){
  XMLDescriptor descriptor=new XMLDescriptor();
  descriptor.setJavaClass(DeleteOperation.class);
  descriptor.setDefaultRootElement("String_Node_Str");
  XMLDirectMapping name=new XMLDirectMapping();
  name.setAttributeName("String_Node_Str");
  name.setXPath("String_Node_Str");
  descriptor.addMapping(name);
  XMLDirectMapping descriptorName=new XMLDirectMapping();
  descriptorName.setAttributeName("String_Node_Str");
  descriptorName.setXPath("String_Node_Str");
  descriptor.addMapping(descriptorName);
  XMLDirectMapping findByPKQuery=new XMLDirectMapping();
  findByPKQuery.setAttributeName("String_Node_Str");
  findByPKQuery.setXPath("String_Node_Str");
  descriptor.addMapping(findByPKQuery);
  XMLCompositeCollectionMapping parameters=new XMLCompositeCollectionMapping();
  parameters.setAttributeName("String_Node_Str");
  parameters.setReferenceClass(Parameter.class);
  parameters.setXPath("String_Node_Str");
  descriptor.addMapping(parameters);
  return descriptor;
}
Program: 63914
Project: 63914
Buggy source:
public void testVersionIncrementPostFlushChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.flush();
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
}

Fixed version (ground truth):
public void testVersionIncrementPostFlushChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  counter.getSqlStatements().clear();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.flush();
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
  assertEquals("String_Node_Str",2,countNumberOfUpdateStatements(counter));
}
Program: 63915
Project: 63915
Buggy source:
public static TestSuite suite(){
  TestSuite suite=new TestSuite("String_Node_Str");
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  return suite;
}

Fixed version (ground truth):
public static TestSuite suite(){
  TestSuite suite=new TestSuite("String_Node_Str");
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  suite.addTest(new OptimisticLockForceIncrementTestSuite("String_Node_Str"));
  return suite;
}
Program: 63916
Project: 63916
Buggy source:
public void testVersionIncrementCommitNoChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
}

Fixed version (ground truth):
public void testVersionIncrementCommitNoChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  counter.getSqlStatements().clear();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str",1,countNumberOfUpdateStatements(counter));
}
Program: 63917
Project: 63917
Buggy source:
public void testVersionIncrementFlushCommitNoChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.flush();
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
}

Fixed version (ground truth):
public void testVersionIncrementFlushCommitNoChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  counter.getSqlStatements().clear();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.flush();
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str",1,countNumberOfUpdateStatements(counter));
}
Program: 63918
Project: 63918
Buggy source:
public void testVersionIncrementPreCommitChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
}

Fixed version (ground truth):
public void testVersionIncrementPreCommitChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  counter.getSqlStatements().clear();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
  assertEquals("String_Node_Str",1,countNumberOfUpdateStatements(counter));
}
Program: 63919
Project: 63919
Buggy source:
public void testVersionIncrementNoChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.flush();
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
}

Fixed version (ground truth):
public void testVersionIncrementNoChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  counter.getSqlStatements().clear();
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  em.flush();
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str",1,countNumberOfUpdateStatements(counter));
}
Program: 63920
Project: 63920
Buggy source:
public void testVersionIncrementPreFlushChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.flush();
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
}

Fixed version (ground truth):
public void testVersionIncrementPreFlushChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  counter.getSqlStatements().clear();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.flush();
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
  assertEquals("String_Node_Str",1,countNumberOfUpdateStatements(counter));
}
Program: 63921
Project: 63921
Buggy source:
public void testVersionIncrementPreAndPostFlushChanges(){
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.flush();
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
}

Fixed version (ground truth):
public void testVersionIncrementPreAndPostFlushChanges(){
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=getEntityManagerFactory().createEntityManager();
  em.getTransaction().begin();
  List<Address> addresses=em.createQuery("String_Node_Str").getResultList();
  counter.getSqlStatements().clear();
  assertNotNull("String_Node_Str",addresses);
  assertNotSame("String_Node_Str",addresses.size(),0);
  Address entity=addresses.get(0);
  assertNotNull("String_Node_Str",entity);
  int startVersion=entity.getVersion();
  em.lock(entity,LockModeType.OPTIMISTIC_FORCE_INCREMENT);
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.flush();
  entity.setCity("String_Node_Str");
  entity.setProvince("String_Node_Str");
  entity.setCountry("String_Node_Str");
  em.getTransaction().commit();
  int expectedVersion=(startVersion + 1);
  int actualVersion=entity.getVersion();
  em.close();
  assertEquals("String_Node_Str",expectedVersion,actualVersion);
  assertEquals("String_Node_Str","String_Node_Str",entity.getCity());
  assertEquals("String_Node_Str",2,countNumberOfUpdateStatements(counter));
}
Program: 63924
Project: 63924
Buggy source:
protected ProjectConfig buildOXProjectConfig(){
  ProjectConfig oxProjectConfig=null;
  boolean useProjectXML=false;
  if (builderHelper.hasTables() || hasBuildSqlOperations()) {
    useProjectXML=true;
  }
 else   if (builderHelper.hasComplexProcedureArgs()) {
    useProjectXML=true;
  }
  if (!useProjectXML) {
    if (orProject.getQueries().size() > 0) {
      useProjectXML=true;
    }
 else     if (orProject.getDescriptors().size() > 0) {
      Collection<ClassDescriptor> descriptors=orProject.getDescriptors().values();
      for (      ClassDescriptor desc : descriptors) {
        if (desc.isObjectRelationalDataTypeDescriptor()) {
          useProjectXML=true;
          break;
        }
      }
    }
  }
  if (useProjectXML) {
    oxProjectConfig=new ProjectXMLConfig();
    String pathPrefix=packager.getOxProjectPathPrefix();
    oxProjectConfig.setProjectString(pathPrefix == null ? DBWS_OX_XML : pathPrefix + DBWS_OX_XML);
  }
 else {
    oxProjectConfig=new ProjectClassConfig();
    oxProjectConfig.setProjectString(SimpleXMLFormatProject.class.getName());
  }
  return oxProjectConfig;
}

Fixed version (ground truth):
protected ProjectConfig buildOXProjectConfig(){
  ProjectConfig oxProjectConfig=null;
  boolean useProjectXML=false;
  if (builderHelper.hasTables() || hasBuildSqlOperations()) {
    useProjectXML=true;
  }
  if (!useProjectXML) {
    if (orProject.getQueries().size() > 0) {
      useProjectXML=true;
    }
 else     if (orProject.getDescriptors().size() > 0) {
      Collection<ClassDescriptor> descriptors=orProject.getDescriptors().values();
      for (      ClassDescriptor desc : descriptors) {
        if (desc.isObjectRelationalDataTypeDescriptor()) {
          useProjectXML=true;
          break;
        }
      }
    }
  }
  if (useProjectXML) {
    oxProjectConfig=new ProjectXMLConfig();
    String pathPrefix=packager.getOxProjectPathPrefix();
    oxProjectConfig.setProjectString(pathPrefix == null ? DBWS_OX_XML : pathPrefix + DBWS_OX_XML);
  }
 else {
    oxProjectConfig=new ProjectClassConfig();
    oxProjectConfig.setProjectString(SimpleXMLFormatProject.class.getName());
  }
  return oxProjectConfig;
}
Program: 63925
Project: 63925
Buggy source:
protected ProjectConfig buildORProjectConfig(){
  ProjectConfig orProjectConfig=null;
  boolean useProjectXML=false;
  if (builderHelper.hasTables() || hasBuildSqlOperations()) {
    useProjectXML=true;
  }
 else   if (builderHelper.hasComplexProcedureArgs()) {
    useProjectXML=true;
  }
  if (!useProjectXML) {
    if (orProject.getQueries().size() > 0) {
      useProjectXML=true;
    }
 else     if (orProject.getDescriptors().size() > 0) {
      Collection<ClassDescriptor> descriptors=orProject.getDescriptors().values();
      for (      ClassDescriptor desc : descriptors) {
        if (desc.isObjectRelationalDataTypeDescriptor()) {
          useProjectXML=true;
          break;
        }
      }
    }
  }
  if (useProjectXML) {
    orProjectConfig=new ProjectXMLConfig();
    String pathPrefix=packager.getOrProjectPathPrefix();
    orProjectConfig.setProjectString(pathPrefix == null ? DBWS_OR_XML : pathPrefix + DBWS_OR_XML);
  }
 else {
    orProjectConfig=new ProjectClassConfig();
    orProjectConfig.setProjectString(Project.class.getName());
  }
  return orProjectConfig;
}

Fixed version (ground truth):
protected ProjectConfig buildORProjectConfig(){
  ProjectConfig orProjectConfig=null;
  boolean useProjectXML=false;
  if (builderHelper.hasTables() || hasBuildSqlOperations()) {
    useProjectXML=true;
  }
  if (!useProjectXML) {
    if (orProject.getQueries().size() > 0) {
      useProjectXML=true;
    }
 else     if (orProject.getDescriptors().size() > 0) {
      Collection<ClassDescriptor> descriptors=orProject.getDescriptors().values();
      for (      ClassDescriptor desc : descriptors) {
        if (desc.isObjectRelationalDataTypeDescriptor()) {
          useProjectXML=true;
          break;
        }
      }
    }
  }
  if (useProjectXML) {
    orProjectConfig=new ProjectXMLConfig();
    String pathPrefix=packager.getOrProjectPathPrefix();
    orProjectConfig.setProjectString(pathPrefix == null ? DBWS_OR_XML : pathPrefix + DBWS_OR_XML);
  }
 else {
    orProjectConfig=new ProjectClassConfig();
    orProjectConfig.setProjectString(Project.class.getName());
  }
  return orProjectConfig;
}
Program: 63926
Project: 63926
Buggy source:
public boolean hasTables(){
  if (dbTables.size() == 0) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Indicates if one or more database tables were discovered.
 */
public boolean hasTables(){
  return dbTables.size() != 0;
}
Program: 63929
Project: 63929
Buggy source:
protected IndexedAttributeList buildAttributeList(Element elem) throws SAXException {
  IndexedAttributeList attributes=new IndexedAttributeList();
  NamedNodeMap attrs=elem.getAttributes();
  for (int i=0, length=attrs.getLength(); i < length; i++) {
    Attr next=(Attr)attrs.item(i);
    String attrPrefix=next.getPrefix();
    if (attrPrefix != null && attrPrefix.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
      contentHandler.startPrefixMapping(next.getLocalName(),next.getValue());
      handleXMLNSPrefixedAttribute(elem,next);
    }
 else     if (attrPrefix == null) {
      String name=next.getLocalName();
      if (name == null) {
        name=next.getNodeName();
      }
      if (name != null && name.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
        contentHandler.startPrefixMapping(Constants.EMPTY_STRING,next.getValue());
      }
    }
    if (next.getNamespaceURI() != null && next.getNamespaceURI().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI) && next.getLocalName().equals("String_Node_Str")) {
      handleXsiTypeAttribute(next);
    }
    attributes.addAttribute(next);
  }
  return attributes;
}

Fixed version (ground truth):
protected IndexedAttributeList buildAttributeList(Element elem) throws SAXException {
  IndexedAttributeList attributes=new IndexedAttributeList();
  NamedNodeMap attrs=elem.getAttributes();
  for (int i=0, length=attrs.getLength(); i < length; i++) {
    Attr next=(Attr)attrs.item(i);
    String attrPrefix=next.getPrefix();
    if (attrPrefix != null && attrPrefix.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
      contentHandler.startPrefixMapping(next.getLocalName(),next.getValue());
      handleNewNamespaceDeclaration(elem,next.getLocalName(),next.getValue());
    }
 else     if (attrPrefix == null) {
      String name=next.getLocalName();
      if (name == null) {
        name=next.getNodeName();
      }
      if (name != null && name.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
        contentHandler.startPrefixMapping(Constants.EMPTY_STRING,next.getValue());
        handleNewNamespaceDeclaration(elem,Constants.EMPTY_STRING,next.getValue());
      }
    }
    if (next.getNamespaceURI() != null && next.getNamespaceURI().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI) && next.getLocalName().equals("String_Node_Str")) {
      handleXsiTypeAttribute(next);
    }
    attributes.addAttribute(next);
  }
  return attributes;
}
Program: 63930
Project: 63930
Buggy source:
/** 
 * Handle prefixed attribute - may need to declare the namespace  URI locally.
 */
protected void handlePrefixedAttribute(Element elem) throws SAXException {
  String prefix=elem.getPrefix();
  if (prefix == null) {
    prefix=Constants.EMPTY_STRING;
  }
  String uri=resolveNamespacePrefix(prefix);
  if (prefix == Constants.EMPTY_STRING && uri == null) {
    return;
  }
  if (uri == null || !uri.equals(elem.getNamespaceURI())) {
    NamespaceResolver tmpresolver=getTempResolver(elem);
    tmpresolver.put(prefix,elem.getNamespaceURI());
    if (!nsresolverList.contains(tmpresolver)) {
      nsresolverList.add(tmpresolver);
    }
    getContentHandler().startPrefixMapping(prefix,elem.getNamespaceURI());
  }
}

Fixed version (ground truth):
/** 
 * Handle prefixed attribute - may need to declare the namespace  URI locally.
 */
@Override protected void handlePrefixedAttribute(Element elem) throws SAXException {
  String prefix=elem.getPrefix();
  if (prefix == null) {
    prefix=Constants.EMPTY_STRING;
  }
  String uri=resolveNamespacePrefix(prefix);
  if ((uri == null && elem.getNamespaceURI() != null) || (uri != null && !uri.equals(elem.getNamespaceURI()))) {
    NamespaceResolver tmpresolver=getTempResolver(elem);
    tmpresolver.put(prefix,elem.getNamespaceURI());
    if (!nsresolverList.contains(tmpresolver)) {
      nsresolverList.add(tmpresolver);
    }
    String namespaceURI=elem.getNamespaceURI();
    if (null == namespaceURI) {
      namespaceURI=Constants.EMPTY_STRING;
    }
    getContentHandler().startPrefixMapping(prefix,namespaceURI);
  }
  NamedNodeMap attributes=elem.getAttributes();
  if (attributes != null) {
    for (int x=0; x < attributes.getLength(); x++) {
      Node attribute=attributes.item(x);
      if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getPrefix())) {
        NamespaceResolver tmpresolver=getTempResolver(elem);
        tmpresolver.put(attribute.getLocalName(),attribute.getNodeValue());
        if (!nsresolverList.contains(tmpresolver)) {
          nsresolverList.add(tmpresolver);
        }
      }
 else       if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getNodeName())) {
        NamespaceResolver tmpresolver=getTempResolver(elem);
        String namespace=attribute.getNodeValue();
        if (null == namespace) {
          namespace=Constants.EMPTY_STRING;
        }
        tmpresolver.put(Constants.EMPTY_STRING,namespace);
        if (!nsresolverList.contains(tmpresolver)) {
          nsresolverList.add(tmpresolver);
        }
      }
    }
  }
}
Program: 63931
Project: 63931
Buggy source:
/** 
 * Convenience method that iterates over each namespace resolver  in the resolver list until it locates a uri for 'prefix' or the final resolver is reached w/o success.
 * @param prefix
 * @return true if a URI exists in one of the resolvers in the list, false otherwise
 */
protected String resolveNamespacePrefix(String prefix){
  String uri=null;
  if (null == prefix) {
    for (int i=nsresolverList.size() - 1; i >= 0; i--) {
      NamespaceResolver next=nsresolverList.get(i);
      uri=next.getDefaultNamespaceURI();
      if ((uri != null) && uri.length() > 0) {
        break;
      }
    }
  }
 else {
    for (int i=nsresolverList.size() - 1; i >= 0; i--) {
      NamespaceResolver next=nsresolverList.get(i);
      uri=next.resolveNamespacePrefix(prefix);
      if ((uri != null) && uri.length() > 0) {
        break;
      }
    }
  }
  return uri;
}

Fixed version (ground truth):
/** 
 * Convenience method that iterates over each namespace resolver  in the resolver list until it locates a uri for 'prefix' or the final resolver is reached w/o success.
 * @param prefix
 * @return true if a URI exists in one of the resolvers in the list, false otherwise
 */
protected String resolveNamespacePrefix(String prefix){
  String uri=null;
  if (null == prefix || prefix.length() == 0) {
    for (int i=nsresolverList.size() - 1; i >= 0; i--) {
      NamespaceResolver next=nsresolverList.get(i);
      uri=next.getDefaultNamespaceURI();
      if ((uri != null) && uri.length() > 0) {
        break;
      }
    }
  }
 else {
    for (int i=nsresolverList.size() - 1; i >= 0; i--) {
      NamespaceResolver next=nsresolverList.get(i);
      uri=next.resolveNamespacePrefix(prefix);
      if ((uri != null) && uri.length() > 0) {
        break;
      }
    }
  }
  return uri;
}
Program: 63932
Project: 63932
Buggy source:
/** 
 * If there is a temporary namespace resolver for a given element, each entry contains a prefix that requires an endPrefixMapping event to be triggered
 */
protected void endPrefixMappings(Element elem) throws SAXException {
  NamespaceResolver tmpresolver=getTempResolver(elem);
  if (tmpresolver != null) {
    Enumeration<String> prefixes=tmpresolver.getPrefixes();
    while (prefixes.hasMoreElements()) {
      getContentHandler().endPrefixMapping(prefixes.nextElement());
    }
  }
}

Fixed version (ground truth):
/** 
 * If there is a temporary namespace resolver for a given element, each entry contains a prefix that requires an endPrefixMapping event to be triggered
 */
protected void endPrefixMappings(Element elem) throws SAXException {
  NamespaceResolver tmpresolver=getTempResolver(elem);
  if (tmpresolver != null) {
    ContentHandler contentHandler=getContentHandler();
    String defaultNamespace=tmpresolver.getDefaultNamespaceURI();
    if (null != defaultNamespace) {
      contentHandler.endPrefixMapping(Constants.EMPTY_STRING);
    }
    if (tmpresolver.hasPrefixesToNamespaces()) {
      for (      Entry<String,String> entry : tmpresolver.getPrefixesToNamespaces().entrySet()) {
        contentHandler.endPrefixMapping(entry.getKey());
      }
    }
  }
}
Program: 63933
Project: 63933
Buggy source:
public void node(Node node,NamespaceResolver namespaceResolver,String uri,String name){
  if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
    Attr attr=(Attr)node;
    String resolverPfx=null;
    if (namespaceResolver != null) {
      resolverPfx=namespaceResolver.resolveNamespaceURI(attr.getNamespaceURI());
    }
    if (resolverPfx != null) {
      attribute(attr.getNamespaceURI(),Constants.EMPTY_STRING,resolverPfx + Constants.COLON + attr.getLocalName(),attr.getNodeValue());
    }
 else {
      attribute(attr.getNamespaceURI(),Constants.EMPTY_STRING,attr.getName(),attr.getNodeValue());
      if (attr.getNamespaceURI() != null) {
        attribute(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI,Constants.EMPTY_STRING,javax.xml.XMLConstants.XMLNS_ATTRIBUTE + Constants.COLON + attr.getPrefix(),attr.getNamespaceURI());
      }
    }
  }
 else   if (node.getNodeType() == Node.TEXT_NODE) {
    characters(node.getNodeValue());
  }
 else {
    transformChildren(node,this.document,this.node,uri,name);
  }
}

Fixed version (ground truth):
public void node(Node node,NamespaceResolver namespaceResolver,String uri,String name){
  if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
    Attr attr=(Attr)node;
    String resolverPfx=null;
    if (namespaceResolver != null) {
      resolverPfx=namespaceResolver.resolveNamespaceURI(attr.getNamespaceURI());
    }
    if (resolverPfx != null) {
      attribute(attr.getNamespaceURI(),Constants.EMPTY_STRING,resolverPfx + Constants.COLON + attr.getLocalName(),attr.getNodeValue());
    }
 else {
      attribute(attr.getNamespaceURI(),Constants.EMPTY_STRING,attr.getName(),attr.getNodeValue());
      if (attr.getNamespaceURI() != null) {
        attribute(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI,Constants.EMPTY_STRING,javax.xml.XMLConstants.XMLNS_ATTRIBUTE + Constants.COLON + attr.getPrefix(),attr.getNamespaceURI());
      }
    }
  }
 else   if (node.getNodeType() == Node.TEXT_NODE) {
    characters(node.getNodeValue());
  }
 else {
    NodeRecordContentHandler mrcHdlr=new NodeRecordContentHandler(this,namespaceResolver);
    XMLFragmentReader xfRdr=new XMLFragmentReader(namespaceResolver);
    xfRdr.setContentHandler(mrcHdlr);
    xfRdr.setLexicalHandler(mrcHdlr);
    try {
      xfRdr.parse(node,uri,name);
    }
 catch (    SAXException sex) {
    }
  }
}
Program: 63935
Project: 63935
Buggy source:
private NodeList selectNodes(Node contextNode,XPathFragment xPathFragment,XMLNamespaceResolver xmlNamespaceResolver,AbstractNullPolicy nullPolicy){
  NodeList resultNodes=getNodes(contextNode,xPathFragment,xmlNamespaceResolver,nullPolicy);
  if (xPathFragment.getNextFragment() != null) {
    Node resultNode;
    XMLNodeList result=new XMLNodeList();
    int numberOfResultNodes=resultNodes.getLength();
    for (int x=0; x < numberOfResultNodes; x++) {
      resultNode=resultNodes.item(x);
      result.addAll(selectNodes(resultNode,xPathFragment.getNextFragment(),xmlNamespaceResolver,nullPolicy));
    }
    return result;
  }
  return resultNodes;
}

Fixed version (ground truth):
private NodeList selectNodes(Node contextNode,XPathFragment xPathFragment,XMLNamespaceResolver xmlNamespaceResolver,AbstractNullPolicy nullPolicy,boolean omitText){
  NodeList resultNodes=getNodes(contextNode,xPathFragment,xmlNamespaceResolver,nullPolicy);
  if (xPathFragment.getNextFragment() != null && !(omitText && xPathFragment.getNextFragment().nameIsText())) {
    Node resultNode;
    XMLNodeList result=new XMLNodeList();
    int numberOfResultNodes=resultNodes.getLength();
    for (int x=0; x < numberOfResultNodes; x++) {
      resultNode=resultNodes.item(x);
      result.addAll(selectNodes(resultNode,xPathFragment.getNextFragment(),xmlNamespaceResolver,nullPolicy,omitText));
    }
    return result;
  }
  return resultNodes;
}
Program: 63937
Project: 63937
Buggy source:
@Override public QName buildQNameFromString(String stringValue,AbstractUnmarshalRecord record){
  int index=stringValue.lastIndexOf(Constants.COLON);
  if (index > -1) {
    String prefix=stringValue.substring(0,index);
    String localName=stringValue.substring(index + 1);
    String namespaceURI=record.resolveNamespacePrefix(prefix);
    return new QName(namespaceURI,localName,prefix);
  }
 else {
    String namespaceURI=record.resolveNamespacePrefix(Constants.EMPTY_STRING);
    if (namespaceURI == null) {
      namespaceURI=record.resolveNamespacePrefix(null);
    }
    return new QName(namespaceURI,stringValue);
  }
}

Fixed version (ground truth):
@Override public QName buildQNameFromString(String stringValue,AbstractUnmarshalRecord record){
  stringValue=stringValue.trim();
  int index=stringValue.lastIndexOf(Constants.COLON);
  if (index > -1) {
    String prefix=stringValue.substring(0,index);
    String localName=stringValue.substring(index + 1);
    if (record.isNamespaceAware()) {
      String namespaceURI=record.resolveNamespacePrefix(prefix);
      return new QName(namespaceURI,localName,prefix);
    }
 else {
      return new QName(null,localName,prefix);
    }
  }
 else {
    String namespaceURI=record.resolveNamespacePrefix(Constants.EMPTY_STRING);
    if (namespaceURI == null) {
      namespaceURI=record.resolveNamespacePrefix(null);
    }
    return new QName(namespaceURI,stringValue);
  }
}
Program: 63938
Project: 63938
Buggy source:
/** 
 * INTERNAL:
 * @since 2.4
 */
@Override public Object convertValueBasedOnSchemaType(Field xmlField,Object value,ConversionManager conversionManager,AbstractUnmarshalRecord record){
  if (xmlField.getSchemaType() != null) {
    if (Constants.QNAME_QNAME.equals(xmlField.getSchemaType())) {
      String stringValue=(String)value;
      int indexOpen=stringValue.indexOf('{');
      int indexClose=stringValue.indexOf('}');
      String uri=null;
      String localName=null;
      if (indexOpen > -1 && indexClose > -1) {
        uri=stringValue.substring(indexOpen + 1,indexClose);
        localName=stringValue.substring(indexClose + 1);
      }
 else {
        localName=stringValue;
      }
      if (uri != null) {
        return new QName(uri,localName);
      }
 else {
        return new QName(localName);
      }
    }
 else {
      Class fieldType=xmlField.getType();
      if (fieldType == null) {
        fieldType=xmlField.getJavaClass(xmlField.getSchemaType());
      }
      return conversionManager.convertObject(value,fieldType,xmlField.getSchemaType());
    }
  }
  return value;
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 * @since 2.4
 */
@Override public Object convertValueBasedOnSchemaType(Field xmlField,Object value,ConversionManager conversionManager,AbstractUnmarshalRecord record){
  if (xmlField.getSchemaType() != null) {
    if (Constants.QNAME_QNAME.equals(xmlField.getSchemaType())) {
      String stringValue=(String)value;
      int indexOpen=stringValue.indexOf('{');
      int indexClose=stringValue.indexOf('}');
      String uri=null;
      String localName=null;
      if (indexOpen > -1 && indexClose > -1) {
        uri=stringValue.substring(indexOpen + 1,indexClose);
        localName=stringValue.substring(indexClose + 1);
      }
 else {
        QName obj=(QName)xmlField.convertValueBasedOnSchemaType(stringValue,conversionManager,record);
        localName=obj.getLocalPart();
        uri=obj.getNamespaceURI();
      }
      if (uri != null) {
        return new QName(uri,localName);
      }
 else {
        return new QName(localName);
      }
    }
 else {
      Class fieldType=xmlField.getType();
      if (fieldType == null) {
        fieldType=xmlField.getJavaClass(xmlField.getSchemaType());
      }
      return conversionManager.convertObject(value,fieldType,xmlField.getSchemaType());
    }
  }
  return value;
}