Program: 155073
Project: 155073
Buggy source:
private void commit(Thread thread,TransactionImpl tx) throws SystemException, HeuristicMixedException, HeuristicRollbackException {
  StoreFailureException sfe=null;
  int xaErrorCode=-1;
  if (tx.getResourceCount() == 0) {
    tx.setStatus(Status.STATUS_COMMITTED);
  }
 else {
    try {
      tx.doCommit();
    }
 catch (    XAException e) {
      xaErrorCode=e.errorCode;
      e.printStackTrace();
      log.severe("String_Node_Str" + getTxStatusAsString(tx.getStatus()) + "String_Node_Str"+ xaErrorCode);
      if (tx.getStatus() == Status.STATUS_COMMITTED) {
        tmOk=false;
        throw new TransactionFailureException("String_Node_Str",e);
      }
    }
catch (    StoreFailureException e) {
      sfe=e;
      e.printStackTrace();
      log.severe("String_Node_Str" + getTxStatusAsString(tx.getStatus()) + "String_Node_Str"+ e);
    }
  }
  if (tx.getStatus() != Status.STATUS_COMMITTED) {
    try {
      tx.doRollback();
    }
 catch (    XAException e) {
      e.printStackTrace();
      log.severe("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
      tmOk=false;
      throw new HeuristicMixedException("String_Node_Str" + xaErrorCode + "String_Node_Str"+ e.errorCode);
    }
    tx.doAfterCompletion();
    txThreadMap.remove(thread);
    try {
      if (tx.isGlobalStartRecordWritten()) {
        getTxLog().txDone(tx.getGlobalId());
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
      log.severe("String_Node_Str");
      tmOk=false;
      throw new SystemException("String_Node_Str" + "String_Node_Str" + e);
    }
    tx.setStatus(Status.STATUS_NO_TRANSACTION);
    if (sfe == null) {
      throw new HeuristicRollbackException("String_Node_Str" + "String_Node_Str" + xaErrorCode);
    }
 else {
      throw new HeuristicRollbackException("String_Node_Str" + sfe);
    }
  }
  tx.doAfterCompletion();
  txThreadMap.remove(thread);
  try {
    if (tx.isGlobalStartRecordWritten()) {
      getTxLog().txDone(tx.getGlobalId());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    log.severe("String_Node_Str");
    tmOk=false;
    throw new SystemException("String_Node_Str" + "String_Node_Str" + e);
  }
  tx.setStatus(Status.STATUS_NO_TRANSACTION);
}

Fixed version (ground truth):
private void commit(Thread thread,TransactionImpl tx) throws SystemException, HeuristicMixedException, HeuristicRollbackException {
  StoreFailureException sfe=null;
  int xaErrorCode=-1;
  if (tx.getResourceCount() == 0) {
    tx.setStatus(Status.STATUS_COMMITTED);
  }
 else {
    try {
      tx.doCommit();
    }
 catch (    XAException e) {
      xaErrorCode=e.errorCode;
      e.printStackTrace();
      log.severe("String_Node_Str" + getTxStatusAsString(tx.getStatus()) + "String_Node_Str"+ xaErrorCode);
      if (tx.getStatus() == Status.STATUS_COMMITTED) {
        tmOk=false;
        throw new TransactionFailureException("String_Node_Str",e);
      }
    }
catch (    StoreFailureException e) {
      sfe=e;
    }
  }
  if (tx.getStatus() != Status.STATUS_COMMITTED) {
    try {
      tx.doRollback();
    }
 catch (    XAException e) {
      e.printStackTrace();
      log.severe("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
      tmOk=false;
      if (sfe != null) {
        sfe.printStackTrace();
      }
      throw new HeuristicMixedException("String_Node_Str" + xaErrorCode + "String_Node_Str"+ e.errorCode);
    }
    tx.doAfterCompletion();
    txThreadMap.remove(thread);
    try {
      if (tx.isGlobalStartRecordWritten()) {
        getTxLog().txDone(tx.getGlobalId());
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
      log.severe("String_Node_Str");
      tmOk=false;
      throw new SystemException("String_Node_Str" + "String_Node_Str" + e);
    }
    tx.setStatus(Status.STATUS_NO_TRANSACTION);
    if (sfe == null) {
      throw new HeuristicRollbackException("String_Node_Str" + "String_Node_Str" + xaErrorCode);
    }
 else {
      throw new HeuristicRollbackException("String_Node_Str" + sfe);
    }
  }
  tx.doAfterCompletion();
  txThreadMap.remove(thread);
  try {
    if (tx.isGlobalStartRecordWritten()) {
      getTxLog().txDone(tx.getGlobalId());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    log.severe("String_Node_Str");
    tmOk=false;
    throw new SystemException("String_Node_Str" + "String_Node_Str" + e);
  }
  tx.setStatus(Status.STATUS_NO_TRANSACTION);
}