Program: 68463
Project: 68463
Buggy source:
public void testREADLock(){
  if (isOnServer()) {
    return;
  }
  EntityManager em=createEntityManager();
  beginTransaction(em);
  Employee employee=null;
  try {
    employee=new Employee();
    employee.setFirstName("String_Node_Str");
    employee.setLastName("String_Node_Str");
    em.persist(employee);
    commitTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  EntityManager em2=createEntityManager();
  Exception optimisticLockException=null;
  beginTransaction(em);
  try {
    employee=em.find(Employee.class,employee.getId());
    em.lock(employee,LockModeType.READ);
    em2.getTransaction().begin();
    try {
      Employee employee2=em2.find(Employee.class,employee.getId());
      employee2.setFirstName("String_Node_Str");
      em2.getTransaction().commit();
      em2.close();
    }
 catch (    RuntimeException ex) {
      em2.getTransaction().rollback();
      em2.close();
      throw ex;
    }
    try {
      em.flush();
    }
 catch (    PersistenceException exception) {
      if (exception instanceof OptimisticLockException) {
        optimisticLockException=exception;
      }
 else {
        throw exception;
      }
    }
    rollbackTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  beginTransaction(em);
  try {
    employee=em.find(Employee.class,employee.getId());
    em.remove(employee);
    commitTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  if (optimisticLockException == null) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
public void testREADLock(){
  if (isOnServer()) {
    return;
  }
  EntityManager em=createEntityManager();
  beginTransaction(em);
  Employee employee=null;
  try {
    employee=new Employee();
    employee.setFirstName("String_Node_Str");
    employee.setLastName("String_Node_Str");
    em.persist(employee);
    commitTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  EntityManager em2=createEntityManager();
  Exception optimisticLockException=null;
  beginTransaction(em);
  try {
    employee=em.find(Employee.class,employee.getId());
    em.lock(employee,LockModeType.READ);
    em2.getTransaction().begin();
    try {
      Employee employee2=em2.find(Employee.class,employee.getId());
      employee2.setFirstName("String_Node_Str");
      em2.getTransaction().commit();
      em2.close();
    }
 catch (    RuntimeException ex) {
      em2.getTransaction().rollback();
      em2.close();
      throw ex;
    }
    try {
      em.flush();
    }
 catch (    PersistenceException exception) {
      if (exception.getCause() instanceof OptimisticLockException) {
        optimisticLockException=exception;
      }
 else {
        throw exception;
      }
    }
    rollbackTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  beginTransaction(em);
  try {
    employee=em.find(Employee.class,employee.getId());
    em.remove(employee);
    commitTransaction(em);
  }
 catch (  RuntimeException ex) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw ex;
  }
  if (optimisticLockException == null) {
    fail("String_Node_Str");
  }
}