Refine null-safety in more modules
This commit refines the null-safety in: - spring-jdbc - spring-r2dbc - spring-orm - spring-beans - spring-aop See gh-32475
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.jdbc;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when SQL specified is invalid. Such exceptions always have
|
||||
@@ -52,6 +53,7 @@ public class BadSqlGrammarException extends InvalidDataAccessResourceUsageExcept
|
||||
/**
|
||||
* Return the wrapped SQLException.
|
||||
*/
|
||||
@Nullable
|
||||
public SQLException getSQLException() {
|
||||
return (SQLException) getCause();
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class InvalidResultSetAccessException extends InvalidDataAccessResourceUs
|
||||
/**
|
||||
* Return the wrapped SQLException.
|
||||
*/
|
||||
@Nullable
|
||||
public SQLException getSQLException() {
|
||||
return (SQLException) getCause();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.jdbc;
|
||||
import java.sql.SQLWarning;
|
||||
|
||||
import org.springframework.dao.UncategorizedDataAccessException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when we're not ignoring {@link java.sql.SQLWarning SQLWarnings}.
|
||||
@@ -49,6 +50,7 @@ public class SQLWarningException extends UncategorizedDataAccessException {
|
||||
* Return the underlying {@link SQLWarning}.
|
||||
* @since 5.3.29
|
||||
*/
|
||||
@Nullable
|
||||
public SQLWarning getSQLWarning() {
|
||||
return (SQLWarning) getCause();
|
||||
}
|
||||
@@ -58,6 +60,7 @@ public class SQLWarningException extends UncategorizedDataAccessException {
|
||||
* @deprecated as of 5.3.29, in favor of {@link #getSQLWarning()}
|
||||
*/
|
||||
@Deprecated(since = "5.3.29")
|
||||
@Nullable
|
||||
public SQLWarning SQLWarning() {
|
||||
return getSQLWarning();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class UncategorizedSQLException extends UncategorizedDataAccessException
|
||||
/**
|
||||
* Return the underlying SQLException.
|
||||
*/
|
||||
@Nullable
|
||||
public SQLException getSQLException() {
|
||||
return (SQLException) getCause();
|
||||
}
|
||||
|
||||
@@ -907,11 +907,13 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T queryForObject(String sql, @Nullable Object[] args, Class<T> requiredType) throws DataAccessException {
|
||||
return queryForObject(sql, args, getSingleColumnRowMapper(requiredType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T queryForObject(String sql, Class<T> requiredType, @Nullable Object... args) throws DataAccessException {
|
||||
return queryForObject(sql, args, getSingleColumnRowMapper(requiredType));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -34,9 +35,11 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractDataFieldMaxValueIncrementer implements DataFieldMaxValueIncrementer, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private DataSource dataSource;
|
||||
|
||||
/** The name of the sequence/table containing the sequence. */
|
||||
@Nullable
|
||||
private String incrementerName;
|
||||
|
||||
/** The length to which a string result should be pre-pended with zeroes. */
|
||||
|
||||
Reference in New Issue
Block a user