Program: 66239
Project: 66239
Buggy source:
public void testSetRollbackOnly(){
  EntityManager em=createEntityManager();
  beginTransaction(em);
  Employee emp=null;
  Employee emp2=null;
  try {
    emp=new Employee();
    emp.setFirstName("String_Node_Str");
    emp.setLastName("String_Node_Str");
    em.persist(emp);
    emp2=new Employee();
    emp2.setFirstName("String_Node_Str");
    emp2.setLastName("String_Node_Str");
    em.persist(emp2);
    commitTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  clearCache();
  em=createEntityManager();
  beginTransaction(em);
  List result=em.createQuery("String_Node_Str" + emp.getId() + "String_Node_Str"+ emp2.getId()).getResultList();
  emp=(Employee)result.get(0);
  emp.toString();
  emp2=(Employee)result.get(1);
  String newName="String_Node_Str" + System.currentTimeMillis();
  emp2.setFirstName(newName);
  em.flush();
  emp2.setLastName("String_Node_Str");
  emp2.setVersion(0);
  try {
    em.flush();
  }
 catch (  Exception ex) {
    em.clear();
    try {
      String eName=(String)em.createQuery("String_Node_Str" + emp2.getId()).getSingleResult();
      assertTrue("String_Node_Str",eName.equals(newName));
    }
 catch (    Exception ignore) {
    }
  }
  try {
    if (isOnServer()) {
      assertTrue("String_Node_Str",!isTransactionActive(em));
    }
 else {
      assertTrue("String_Node_Str",em.getTransaction().getRollbackOnly());
    }
  }
  finally {
    try {
      commitTransaction(em);
    }
 catch (    RollbackException ex) {
      return;
    }
catch (    RuntimeException ex) {
      if (ex.getCause() instanceof javax.transaction.RollbackException) {
        return;
      }
      if (ex.getCause() instanceof javax.persistence.RollbackException) {
        return;
      }
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
  }
  fail("String_Node_Str");
}

Fixed version (ground truth):
public void testSetRollbackOnly(){
  EntityManager em=createEntityManager();
  beginTransaction(em);
  Employee emp=null;
  Employee emp2=null;
  try {
    emp=new Employee();
    emp.setFirstName("String_Node_Str");
    emp.setLastName("String_Node_Str");
    em.persist(emp);
    emp2=new Employee();
    emp2.setFirstName("String_Node_Str");
    emp2.setLastName("String_Node_Str");
    em.persist(emp2);
    commitTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  clearCache();
  em=createEntityManager();
  beginTransaction(em);
  List result=em.createQuery("String_Node_Str" + emp.getId() + "String_Node_Str"+ emp2.getId()).getResultList();
  emp=(Employee)result.get(0);
  emp.toString();
  emp2=(Employee)result.get(1);
  String newName="String_Node_Str" + System.currentTimeMillis();
  emp2.setFirstName(newName);
  em.flush();
  emp2.setLastName("String_Node_Str");
  emp2.setVersion(0);
  try {
    em.flush();
  }
 catch (  Exception ex) {
    if (!isOnServer()) {
      em.clear();
      try {
        String eName=(String)em.createQuery("String_Node_Str" + emp2.getId()).getSingleResult();
        assertTrue("String_Node_Str",eName.equals(newName));
      }
 catch (      Exception ignore) {
      }
    }
  }
  try {
    if (isOnServer()) {
      assertTrue("String_Node_Str",!isTransactionActive(em));
    }
 else {
      assertTrue("String_Node_Str",em.getTransaction().getRollbackOnly());
    }
  }
  finally {
    try {
      commitTransaction(em);
    }
 catch (    RollbackException ex) {
      return;
    }
catch (    RuntimeException ex) {
      if (ex.getCause() instanceof javax.transaction.RollbackException) {
        return;
      }
      if (ex.getCause() instanceof javax.persistence.RollbackException) {
        return;
      }
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
  }
  fail("String_Node_Str");
}