Program: 64773
Project: 64773
Buggy source:
/** 
 * INTERNAL: The method performs the logic that should be executed after the transaction has been completed. The status passed in indicates whether the transaction was committed or rolled back. This status flag may be different for different implementations. This method executes without a transaction context.
 * @param status The status code of the transaction completion.
 */
public void afterCompletion(Object status){
  UnitOfWorkImpl uow=getUnitOfWork();
  if (uow == null) {
    if (getTransactionController().isSequencingCallbackRequired()) {
      if (getTransactionController().canMergeUnitOfWork_impl(status)) {
        callSequencingCallback();
      }
    }
  }
 else {
    try {
      getTransactionController().logTxStateTrace(uow,"String_Node_Str",status);
      session.startOperationProfile(SessionProfiler.JtsAfterCompletion);
      if (!uow.isActive()) {
        throw TransactionException.inactiveUnitOfWork(uow);
      }
      if (getTransactionController().canMergeUnitOfWork_impl(status)) {
        if (getTransactionController().isSequencingCallbackRequired()) {
          callSequencingCallback();
        }
        if (uow.isMergePending()) {
          uow.mergeClonesAfterCompletion();
        }
      }
 else {
        getSession().releaseJTSConnection();
        uow.afterExternalTransactionRollback();
      }
    }
 catch (    RuntimeException rtEx) {
      uow.log(new SessionLogEntry(uow,SessionLog.WARNING,SessionLog.TRANSACTION,rtEx));
      throw rtEx;
    }
 finally {
      session.endOperationProfile(SessionProfiler.JtsAfterCompletion);
    }
    if (uow.shouldResumeUnitOfWorkOnTransactionCompletion() && getTransactionController().canMergeUnitOfWork_impl(status)) {
      uow.synchronizeAndResume();
      uow.setSynchronized(false);
    }
 else {
      uow.release();
      if (getSession().isClientSession() || (getSession().isSessionBroker() && ((SessionBroker)getSession()).isClientSessionBroker())) {
        getSession().release();
      }
    }
    getTransactionController().removeUnitOfWork(getTransactionKey());
    setUnitOfWork(null);
    setSession(null);
  }
  if (getTransactionController().isSequencingCallbackRequired()) {
    getTransactionController().removeSequencingListener(getTransactionKey());
    sequencingCallback=null;
    sequencingCallbackMap=null;
  }
  setTransaction(null);
  setTransactionKey(null);
}

Fixed version (ground truth):
/** 
 * INTERNAL: The method performs the logic that should be executed after the transaction has been completed. The status passed in indicates whether the transaction was committed or rolled back. This status flag may be different for different implementations. This method executes without a transaction context.
 * @param status The status code of the transaction completion.
 */
public void afterCompletion(Object status){
  UnitOfWorkImpl uow=getUnitOfWork();
  if (uow == null) {
    if (getTransactionController().isSequencingCallbackRequired()) {
      if (getTransactionController().canMergeUnitOfWork_impl(status)) {
        callSequencingCallback();
      }
    }
  }
 else {
    try {
      getTransactionController().logTxStateTrace(uow,"String_Node_Str",status);
      session.startOperationProfile(SessionProfiler.JtsAfterCompletion);
      if (!uow.isActive()) {
        throw TransactionException.inactiveUnitOfWork(uow);
      }
      if (getTransactionController().canMergeUnitOfWork_impl(status)) {
        if (getTransactionController().isSequencingCallbackRequired()) {
          callSequencingCallback();
        }
        if (uow.isMergePending()) {
          uow.mergeClonesAfterCompletion();
        }
      }
 else {
        getSession().releaseJTSConnection();
        uow.afterExternalTransactionRollback();
      }
    }
 catch (    RuntimeException exception) {
      if (!(exception instanceof EclipseLinkException && ((EclipseLinkException)exception).hasBeenLogged())) {
        uow.logThrowable(SessionLog.WARNING,SessionLog.TRANSACTION,exception);
      }
      throw exception;
    }
 finally {
      session.endOperationProfile(SessionProfiler.JtsAfterCompletion);
    }
    if (uow.shouldResumeUnitOfWorkOnTransactionCompletion() && getTransactionController().canMergeUnitOfWork_impl(status)) {
      uow.synchronizeAndResume();
      uow.setSynchronized(false);
    }
 else {
      uow.release();
      if (getSession().isClientSession() || (getSession().isSessionBroker() && ((SessionBroker)getSession()).isClientSessionBroker())) {
        getSession().release();
      }
    }
    getTransactionController().removeUnitOfWork(getTransactionKey());
    setUnitOfWork(null);
    setSession(null);
  }
  if (getTransactionController().isSequencingCallbackRequired()) {
    getTransactionController().removeSequencingListener(getTransactionKey());
    sequencingCallback=null;
    sequencingCallbackMap=null;
  }
  setTransaction(null);
  setTransactionKey(null);
}