Source:
public void flush() { List<BatchEntry> temp; bufferLock.lock(); try { lastFlush = System.currentTimeMillis(); if (batch == batchSize) { logger.trace("[{}] Batch empty, not flushing", name); return; } batch = batchSize; temp = buffer; buffer = new LinkedList<>(); } finally { bufferLock.unlock(); } long start = System.currentTimeMillis(); try { flushTransactionLock.lock(); start = System.currentTimeMillis(); de.beginTransaction(); for (final BatchEntry entry : temp) { de.addBatch(entry.getTableName(), entry.getEntityEntry()); } de.flush(); de.commit(); logger.trace("[{}] Batch flushed. Took ms, rows.", name, (System.currentTimeMillis() - start), temp.size()); } catch (final Exception e) { if (this.maxFlushRetries > 0) { logger.debug(dev, "[{}] Error occurred while flushing. Retrying.", name, e); } boolean success = false; int retryCount; for (retryCount = 0; retryCount < this.maxFlushRetries && !success; retryCount++) { try { Thread.sleep(this.flushRetryDelay); if (de.checkConnection() && de.isTransactionActive()) { de.rollback(); } de.beginTransaction(); for (final BatchEntry entry : temp) { de.addBatch(entry.getTableName(), entry.getEntityEntry()); } de.flush(); de.commit(); success = true; } catch (final Exception exc) { logger.debug(dev, "[{}] Error occurred while flushing (retry attempt {}).", name, retryCount + 1, exc); } } if (!success) { onFlushFailure(temp.toArray(new BatchEntry[temp.size()])); logger.error(dev, "[{}] Error occurred while flushing. Aborting batch flush.", name, e); } else { logger.trace("[{}] Batch flushed. Took ms, retries, rows.", name, (System.currentTimeMillis() - start), retryCount, temp.size()); } } finally { try { if (de.isTransactionActive()) { de.rollback(); } } catch (final Exception e) { logger.trace("[{}] Batch failed to check the flush transaction state", name); } flushTransactionLock.unlock(); } }

Target:
public void flush() { List<BatchEntry> temp; bufferLock.lock(); try { lastFlush = System.currentTimeMillis(); if (batch == batchSize) { logger.trace("[{}] Batch empty, not flushing", name); return; } batch = batchSize; temp = buffer; buffer = new LinkedList<>(); } finally { bufferLock.unlock(); } long start = System.currentTimeMillis(); try { flushTransactionLock.lock(); start = System.currentTimeMillis(); processBatch(temp); logger.trace("[{}] Batch flushed. Took ms, rows.", name, (System.currentTimeMillis() - start), temp.size()); } catch (final Exception e) { if (this.maxFlushRetries > 0) { logger.warn(dev, "[{}] Error occurred while flushing. Retrying.", name, e); } boolean success = false; int retryCount; for (retryCount = 0; retryCount < this.maxFlushRetries && !success; retryCount++) { try { Thread.sleep(this.flushRetryDelay); if (de.checkConnection() && de.isTransactionActive()) { de.rollback(); } processBatch(temp); success = true; } catch (final Exception exc) { logger.warn(dev, "[{}] Error occurred while flushing (retry attempt {}).", name, retryCount + 1, exc); } } if (!success) { try { if (de.isTransactionActive()) { de.rollback(); } } catch (final Exception ee) { ee.addSuppressed(e); logger.trace("[{}] Batch failed to check the flush transaction state", name, ee); } onFlushFailure(temp.toArray(new BatchEntry[temp.size()])); logger.error(dev, "[{}] Error occurred while flushing. Aborting batch flush.", name, e); } else { logger.trace("[{}] Batch flushed. Took ms, retries, rows.", name, (System.currentTimeMillis() - start), retryCount, temp.size()); } } finally { try { if (de.isTransactionActive()) { de.rollback(); } } catch (final Exception e) { logger.trace("[{}] Batch failed to check the flush transaction state", name, e); } finally { flushTransactionLock.unlock(); } } }