Add missing @Nullable annotations on parameters

Issue: SPR-15540
This commit is contained in:
Sebastien Deleuze
2017-05-31 12:37:54 +02:00
parent ad2c0f8410
commit b47d713e14
380 changed files with 1085 additions and 732 deletions

View File

@@ -38,6 +38,7 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.Customer;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.lang.Nullable;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
@@ -106,7 +107,7 @@ public class SqlQueryTests {
SqlQuery<Integer> query = new MappingSqlQueryWithParameters<Integer>() {
@Override
protected Integer mapRow(ResultSet rs, int rownum, Object[] params, Map<? ,?> context)
protected Integer mapRow(ResultSet rs, int rownum, @Nullable Object[] params, @Nullable Map<? ,?> context)
throws SQLException {
assertTrue("params were null", params == null);
assertTrue("context was null", context == null);
@@ -729,7 +730,7 @@ public class SqlQueryTests {
}
@Override
protected Customer updateRow(ResultSet rs, int rownum, Map<? ,?> context)
protected Customer updateRow(ResultSet rs, int rownum, @Nullable Map<? ,?> context)
throws SQLException {
rs.updateString(2, "" + context.get(rs.getInt(COLUMN_NAMES[0])));
return null;

View File

@@ -49,6 +49,7 @@ import org.springframework.jdbc.core.support.AbstractSqlTypeValue;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.jdbc.support.SQLExceptionTranslator;
import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
import org.springframework.lang.Nullable;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import static org.junit.Assert.*;
@@ -689,7 +690,8 @@ public class StoredProcedureTests {
getJdbcTemplate().setExceptionTranslator(new SQLExceptionTranslator() {
@Override
public DataAccessException translate(String task, String sql,
@Nullable
public DataAccessException translate(String task, @Nullable String sql,
SQLException sqlex) {
return new CustomDataException(sql, sqlex);
}

View File

@@ -20,6 +20,7 @@ import java.sql.SQLException;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.TransientDataAccessResourceException;
import org.springframework.lang.Nullable;
/**
* Custom SQLException translation for testing.
@@ -28,7 +29,7 @@ import org.springframework.dao.TransientDataAccessResourceException;
*/
public class CustomSqlExceptionTranslator implements SQLExceptionTranslator {
@Override
public DataAccessException translate(String task, String sql, SQLException ex) {
public DataAccessException translate(String task, @Nullable String sql, SQLException ex) {
if (ex.getErrorCode() == 2) {
return new TransientDataAccessResourceException("Custom", ex);
}

View File

@@ -33,6 +33,7 @@ import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.InvalidResultSetAccessException;
import org.springframework.lang.Nullable;
import static org.junit.Assert.*;
@@ -134,7 +135,8 @@ public class SQLErrorCodeSQLExceptionTranslatorTests {
SQLErrorCodeSQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator() {
@Override
protected DataAccessException customTranslate(String task, String sql, SQLException sqlex) {
@Nullable
protected DataAccessException customTranslate(String task, @Nullable String sql, SQLException sqlex) {
assertEquals(TASK, task);
assertEquals(SQL, sql);
return (sqlex == badSqlEx) ? customDex : null;