Perform NullAway build-time checks in more modules
This commit enables null-safety build-time checks in: - spring-jdbc - spring-r2dbc - spring-orm - spring-beans - spring-aop See gh-32475
This commit is contained in:
@@ -42,6 +42,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
||||
/**
|
||||
* Return the underlying SQLException.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public SQLException getSQLException() {
|
||||
return ((JDBCException) getCause()).getSQLException();
|
||||
}
|
||||
@@ -50,6 +51,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
||||
* Return the SQL that led to the problem.
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
public String getSql() {
|
||||
return ((JDBCException) getCause()).getSQL();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class HibernateQueryException extends InvalidDataAccessResourceUsageExcep
|
||||
* Return the HQL query string that was invalid.
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
public String getQueryString() {
|
||||
return ((QueryException) getCause()).getQueryString();
|
||||
}
|
||||
|
||||
@@ -947,6 +947,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
@SuppressWarnings("NullAway")
|
||||
public List<?> findByNamedQueryAndNamedParam(
|
||||
String queryName, @Nullable String[] paramNames, @Nullable Object[] values)
|
||||
throws DataAccessException {
|
||||
|
||||
@@ -427,7 +427,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
if (cause != null) {
|
||||
String message = ex.getMessage();
|
||||
String causeString = cause.toString();
|
||||
if (!message.endsWith(causeString)) {
|
||||
if (message != null && !message.endsWith(causeString)) {
|
||||
ex = new PersistenceException(message + "; nested exception is " + causeString, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ public class LocalContainerEntityManagerFactoryBean extends AbstractEntityManage
|
||||
@Override
|
||||
public void afterPropertiesSet() throws PersistenceException {
|
||||
PersistenceUnitManager managerToUse = this.persistenceUnitManager;
|
||||
if (this.persistenceUnitManager == null) {
|
||||
if (managerToUse == null) {
|
||||
this.internalPersistenceUnitManager.afterPropertiesSet();
|
||||
managerToUse = this.internalPersistenceUnitManager;
|
||||
}
|
||||
|
||||
@@ -452,6 +452,7 @@ public class DefaultPersistenceUnitManager
|
||||
* @see #obtainDefaultPersistenceUnitInfo()
|
||||
* @see #obtainPersistenceUnitInfo(String)
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
public void preparePersistenceUnitInfos() {
|
||||
this.persistenceUnitInfoNames.clear();
|
||||
this.persistenceUnitInfos.clear();
|
||||
|
||||
@@ -359,6 +359,7 @@ public class PersistenceAnnotationBeanPostProcessor implements InstantiationAwar
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||
Class<?> beanClass = registeredBean.getBeanClass();
|
||||
String beanName = registeredBean.getBeanName();
|
||||
@@ -857,6 +858,7 @@ public class PersistenceAnnotationBeanPostProcessor implements InstantiationAwar
|
||||
return CodeBlock.of("$L($L)", generatedMethod.getName(), REGISTERED_BEAN_PARAMETER);
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
private void generateGetEntityManagerMethod(MethodSpec.Builder method, PersistenceElement injectedElement) {
|
||||
String unitName = injectedElement.unitName;
|
||||
Properties properties = injectedElement.properties;
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.hibernate.property.access.spi.PropertyAccess;
|
||||
final class Target_BytecodeProvider {
|
||||
|
||||
@Substitute
|
||||
@SuppressWarnings("NullAway")
|
||||
public ReflectionOptimizer getReflectionOptimizer(Class<?> clazz, Map<String, PropertyAccess> propertyAccessMap) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.hibernate.bytecode.spi.BytecodeProvider;
|
||||
final class Target_BytecodeProviderInitiator {
|
||||
|
||||
@Alias
|
||||
@SuppressWarnings("NullAway")
|
||||
public static String BYTECODE_PROVIDER_NAME_NONE;
|
||||
|
||||
@Alias
|
||||
|
||||
Reference in New Issue
Block a user