Program: 172325
Project: 172325
Buggy source:
/** 
 * Perform a set of operations under a single Hibernate transaction. Keep trying if the operation fails because of a concurrency issue.
 * @param callback The worker.
 * @param write Whether this is a write operation.
 * @return Whether the operation finished with a commit.
 */
public void perform(HibernateTxnCallback callback,boolean write){
  Session sess=null;
  Transaction txn=null;
  while (true) {
    try {
      sess=fSessionFactory.openSession();
      txn=sess.beginTransaction();
      callback.perform(sess);
      txn.commit();
      return;
    }
 catch (    Throwable t) {
      if (txn != null) {
        try {
          txn.rollback();
        }
 catch (        HibernateException he) {
        }
        if (t instanceof StaleStateException || t instanceof GenericJDBCException || t instanceof LockAcquisitionException) {
          if (t instanceof StaleStateException) {
            System.err.println("String_Node_Str");
            StackTraceElement[] stack=t.getStackTrace();
            long threadID=Thread.currentThread().getId();
            for (            StackTraceElement frame : stack) {
              System.err.println(threadID + "String_Node_Str" + frame);
            }
          }
 else {
            System.err.println("String_Node_Str");
            StackTraceElement[] stack=t.getStackTrace();
            long threadID=Thread.currentThread().getId();
            for (            StackTraceElement frame : stack) {
              System.err.println(threadID + "String_Node_Str" + frame);
            }
            try {
              long interval;
synchronized (fRandom) {
                interval=fRandom.nextInt(1000);
              }
              Thread.sleep(interval);
              continue;
            }
 catch (            InterruptedException ie) {
            }
          }
          continue;
        }
      }
      if (t instanceof AVMException) {
        throw (AVMException)t;
      }
      throw new AVMException("String_Node_Str",t);
    }
 finally {
      if (sess != null) {
        try {
          sess.close();
        }
 catch (        HibernateException he) {
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Perform a set of operations under a single Hibernate transaction. Keep trying if the operation fails because of a concurrency issue.
 * @param callback The worker.
 * @param write Whether this is a write operation.
 * @return Whether the operation finished with a commit.
 */
public void perform(HibernateTxnCallback callback,boolean write){
  Session sess=null;
  Transaction txn=null;
  while (true) {
    try {
      sess=fSessionFactory.openSession();
      sess.setFlushMode(FlushMode.ALWAYS);
      txn=sess.beginTransaction();
      callback.perform(sess);
      txn.commit();
      return;
    }
 catch (    Throwable t) {
      if (txn != null) {
        try {
          txn.rollback();
        }
 catch (        HibernateException he) {
        }
        if (t instanceof StaleStateException || t instanceof GenericJDBCException || t instanceof LockAcquisitionException) {
          if (t instanceof StaleStateException) {
            System.err.println("String_Node_Str");
          }
 else {
            System.err.println("String_Node_Str");
            try {
              long interval;
synchronized (fRandom) {
                interval=fRandom.nextInt(1000);
              }
              Thread.sleep(interval);
              continue;
            }
 catch (            InterruptedException ie) {
            }
          }
          continue;
        }
      }
      if (t instanceof AVMException) {
        throw (AVMException)t;
      }
      throw new AVMException("String_Node_Str",t);
    }
 finally {
      if (sess != null) {
        try {
          sess.close();
        }
 catch (        HibernateException he) {
        }
      }
    }
  }
}