Program: 67902
Project: 67902
Buggy source:
/** 
 * Set the lock mode for an entity object contained in the persistence context.
 * @param entity
 * @param lockMode
 * @throws PersistenceException if an unsupported lock call is made
 * @throws IllegalArgumentException if the instance is not an entity or is a detached entity
 * @throws javax.persistence.TransactionRequiredException if there is no transaction
 */
public void lock(Object entity,LockModeType lockMode,Map properties){
  try {
    verifyOpen();
    if (lockMode.name().contains(ObjectLevelReadQuery.PESSIMISTIC)) {
      ReadObjectQuery query=getReadObjectQuery(entity,properties);
      if (properties == null || !properties.containsKey(QueryHints.REFRESH)) {
        query.refreshIdentityMapResult();
      }
      if (properties == null || !properties.containsKey(QueryHints.REFRESH_CASCADE)) {
        query.cascadePrivateParts();
      }
      executeQuery(query,lockMode,getActivePersistenceContext(checkForTransaction(false)));
    }
 else {
      RepeatableWriteUnitOfWork context=getActivePersistenceContext(checkForTransaction(false));
      ClassDescriptor descriptor=context.getDescriptor(entity);
      OptimisticLockingPolicy lockingPolicy=descriptor.getOptimisticLockingPolicy();
      if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)) {
        throw new PersistenceException(ExceptionLocalization.buildMessage("String_Node_Str",null));
      }
      context.forceUpdateToVersionField(entity,(lockMode == LockModeType.WRITE || lockMode.name().equals(ObjectLevelReadQuery.OPTIMISTIC_FORCE_INCREMENT)));
    }
  }
 catch (  LockTimeoutException e) {
    throw e;
  }
catch (  RuntimeException e) {
    setRollbackOnly();
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Set the lock mode for an entity object contained in the persistence context.
 * @param entity
 * @param lockMode
 * @throws PersistenceException if an unsupported lock call is made
 * @throws IllegalArgumentException if the instance is not an entity or is a detached entity
 * @throws javax.persistence.TransactionRequiredException if there is no transaction
 */
public void lock(Object entity,LockModeType lockMode,Map properties){
  try {
    if (lockMode.name().contains(ObjectLevelReadQuery.NONE)) {
      return;
    }
    verifyOpen();
    if (lockMode.name().contains(ObjectLevelReadQuery.PESSIMISTIC)) {
      ReadObjectQuery query=getReadObjectQuery(entity,properties);
      if (properties == null || !properties.containsKey(QueryHints.REFRESH)) {
        query.refreshIdentityMapResult();
      }
      if (properties == null || !properties.containsKey(QueryHints.REFRESH_CASCADE)) {
        query.cascadePrivateParts();
      }
      executeQuery(query,lockMode,getActivePersistenceContext(checkForTransaction(false)));
    }
 else {
      RepeatableWriteUnitOfWork context=getActivePersistenceContext(checkForTransaction(false));
      ClassDescriptor descriptor=context.getDescriptor(entity);
      OptimisticLockingPolicy lockingPolicy=descriptor.getOptimisticLockingPolicy();
      if ((lockingPolicy == null) || !(lockingPolicy instanceof VersionLockingPolicy)) {
        throw new PersistenceException(ExceptionLocalization.buildMessage("String_Node_Str",null));
      }
      context.forceUpdateToVersionField(entity,(lockMode == LockModeType.WRITE || lockMode.name().equals(ObjectLevelReadQuery.OPTIMISTIC_FORCE_INCREMENT)));
    }
  }
 catch (  LockTimeoutException e) {
    throw e;
  }
catch (  RuntimeException e) {
    setRollbackOnly();
    throw e;
  }
}