Code review comment: `dataRecords` might be empty, it's the same as before in this case

Code before review:
private void dump(final PipelineTableMetaData tableMetaData, final Connection connection) throws SQLException {
int batchSize = dumperConfig.getBatchSize();
DatabaseType databaseType = dumperConfig.getDataSourceConfig().getDatabaseType();
if (null != dumperConfig.getTransactionIsolation()) {
connection.setTransactionIsolation(dumperConfig.getTransactionIsolation());
}
try (PreparedStatement preparedStatement = JDBCStreamQueryUtils.generateStreamQueryPreparedStatement(databaseType, connection, buildInventoryDumpSQL())) {
dumpStatement.set(preparedStatement);
if (!(databaseType instanceof MySQLDatabaseType)) {
preparedStatement.setFetchSize(batchSize);
}
setParameters(preparedStatement);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
int rowCount = 0;
JobRateLimitAlgorithm rateLimitAlgorithm = dumperConfig.getRateLimitAlgorithm();
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
List<Record> dataRecords = new LinkedList<>();
while (resultSet.next()) {
if (dataRecords.size() >= batchSize) {
channel.pushRecords(dataRecords);
dataRecords = new LinkedList<>();
}
dataRecords.add(loadDataRecord(resultSet, resultSetMetaData, tableMetaData));
++rowCount;
if (!isRunning()) {
log.info("Broke because of inventory dump is not running.");
break;
}
if (null != rateLimitAlgorithm && 0 == rowCount % batchSize) {
rateLimitAlgorithm.intercept(JobOperationType.SELECT, 1);
}
}
dataRecords.add(new FinishedRecord(new FinishedPosition()));
channel.pushRecords(dataRecords);
dumpStatement.set(null);
log.info("Inventory dump done, rowCount={}", rowCount);
}
}
}

Line under review: channel.pushRecords(dataRecords);

Code after addressing the review:
private void dump(final PipelineTableMetaData tableMetaData, final Connection connection) throws SQLException {
int batchSize = dumperConfig.getBatchSize();
DatabaseType databaseType = dumperConfig.getDataSourceConfig().getDatabaseType();
if (null != dumperConfig.getTransactionIsolation()) {
connection.setTransactionIsolation(dumperConfig.getTransactionIsolation());
}
try (PreparedStatement preparedStatement = JDBCStreamQueryUtils.generateStreamQueryPreparedStatement(databaseType, connection, buildInventoryDumpSQL())) {
dumpStatement.set(preparedStatement);
if (!(databaseType instanceof MySQLDatabaseType)) {
preparedStatement.setFetchSize(batchSize);
}
setParameters(preparedStatement);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
int rowCount = 0;
JobRateLimitAlgorithm rateLimitAlgorithm = dumperConfig.getRateLimitAlgorithm();
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
List<Record> dataRecords = new LinkedList<>();
while (resultSet.next()) {
if (dataRecords.size() >= batchSize) {
channel.pushRecords(dataRecords);
dataRecords = new LinkedList<>();
}
dataRecords.add(loadDataRecord(resultSet, resultSetMetaData, tableMetaData));
++rowCount;
if (!isRunning()) {
log.info("Broke because of inventory dump is not running.");
break;
}
if (null != rateLimitAlgorithm && 0 == rowCount % batchSize) {
rateLimitAlgorithm.intercept(JobOperationType.SELECT, 1);
}
}
dataRecords.add(new FinishedRecord(new FinishedPosition()));
channel.pushRecords(dataRecords);
dumpStatement.set(null);
log.info("Inventory dump done, rowCount={}", rowCount);
}
}
}