RESOLVED - BATCH-909: Turn off getWarnings() call in JdbcCursorItemReader when ignoreWarnings is true
getWarnings is now called only if debug is enabled
This commit is contained in:
@@ -178,7 +178,7 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
|
||||
preparedStatementSetter.setValues(preparedStatement);
|
||||
}
|
||||
this.rs = preparedStatement.executeQuery();
|
||||
handleWarnings(preparedStatement.getWarnings());
|
||||
handleWarnings(preparedStatement);
|
||||
}
|
||||
catch (SQLException se) {
|
||||
close(null);
|
||||
@@ -234,20 +234,26 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
|
||||
*
|
||||
* @param warnings the warnings object from the current statement. May be
|
||||
* <code>null</code>, in which case this method does nothing.
|
||||
* @throws SQLException
|
||||
*
|
||||
* @see org.springframework.jdbc.SQLWarningException
|
||||
*/
|
||||
private void handleWarnings(SQLWarning warnings) throws SQLWarningException {
|
||||
private void handleWarnings(PreparedStatement pstmt) throws SQLWarningException, SQLException {
|
||||
if (ignoreWarnings) {
|
||||
SQLWarning warningToLog = warnings;
|
||||
while (warningToLog != null) {
|
||||
log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '"
|
||||
+ warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
|
||||
warningToLog = warningToLog.getNextWarning();
|
||||
if (log.isDebugEnabled()) {
|
||||
SQLWarning warningToLog = pstmt.getWarnings();
|
||||
while (warningToLog != null) {
|
||||
log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '"
|
||||
+ warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
|
||||
warningToLog = warningToLog.getNextWarning();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (warnings != null) {
|
||||
throw new SQLWarningException("Warning not ignored", warnings);
|
||||
else {
|
||||
SQLWarning warnings = pstmt.getWarnings();
|
||||
if (warnings != null) {
|
||||
throw new SQLWarningException("Warning not ignored", warnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user