Program: 66941
Project: 66941
Buggy source:
public void testPESSIMISTIC_READ_TIMEOUTLock(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isOnServer() && isSelectForUpateSupported() && !session.getPlatform().isMySQL()) {
    EntityManager em=createEntityManager();
    List result=em.createQuery("String_Node_Str").getResultList();
    Employee employee=(Employee)result.get(0);
    Exception lockTimeOutException=null;
    try {
      beginTransaction(em);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ);
      EntityManager em2=createEntityManager();
      try {
        beginTransaction(em2);
        HashMap<String,Object> properties=new HashMap<String,Object>();
        properties.put(QueryHints.PESSIMISTIC_LOCK_TIMEOUT,5);
        Employee employee2=em2.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ,properties);
        employee2.setFirstName("String_Node_Str");
        commitTransaction(em2);
      }
 catch (      PersistenceException ex) {
        if (isTransactionActive(em2)) {
          rollbackTransaction(em2);
        }
        if (ex instanceof javax.persistence.LockTimeoutException) {
          lockTimeOutException=ex;
        }
 else {
          throw ex;
        }
      }
 finally {
        closeEntityManager(em2);
      }
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
    assertFalse("String_Node_Str",lockTimeOutException == null);
  }
}

Fixed version (ground truth):
public void testPESSIMISTIC_READ_TIMEOUTLock(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isOnServer() && isSelectForUpateSupported() && !session.getPlatform().isMySQL()) {
    EntityManager em=createEntityManager();
    List result=em.createQuery("String_Node_Str").getResultList();
    Employee employee=(Employee)result.get(0);
    Exception lockTimeOutException=null;
    try {
      beginTransaction(em);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ);
      EntityManager em2=createEntityManager();
      try {
        beginTransaction(em2);
        HashMap<String,Object> properties=new HashMap<String,Object>();
        properties.put(QueryHints.PESSIMISTIC_LOCK_TIMEOUT,5);
        Employee employee2=(Employee)em2.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ,properties);
        employee2.setFirstName("String_Node_Str");
        commitTransaction(em2);
      }
 catch (      PersistenceException ex) {
        if (isTransactionActive(em2)) {
          rollbackTransaction(em2);
        }
        if (ex instanceof javax.persistence.LockTimeoutException) {
          lockTimeOutException=ex;
        }
 else {
          throw ex;
        }
      }
 finally {
        closeEntityManager(em2);
      }
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
    assertFalse("String_Node_Str",lockTimeOutException == null);
  }
}