Refine null-safety in the spring-orm module
Closes gh-34159
This commit is contained in:
@@ -42,7 +42,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
|||||||
/**
|
/**
|
||||||
* Return the underlying SQLException.
|
* Return the underlying SQLException.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("NullAway")
|
@SuppressWarnings("NullAway") // JDBCException instances always have a non null cause
|
||||||
public SQLException getSQLException() {
|
public SQLException getSQLException() {
|
||||||
return ((JDBCException) getCause()).getSQLException();
|
return ((JDBCException) getCause()).getSQLException();
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
|||||||
/**
|
/**
|
||||||
* Return the SQL that led to the problem.
|
* Return the SQL that led to the problem.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("NullAway")
|
@SuppressWarnings("NullAway") // JDBCException instances always have a non null cause
|
||||||
public @Nullable String getSql() {
|
public @Nullable String getSql() {
|
||||||
return ((JDBCException) getCause()).getSQL();
|
return ((JDBCException) getCause()).getSQL();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ public class HibernateQueryException extends InvalidDataAccessResourceUsageExcep
|
|||||||
/**
|
/**
|
||||||
* Return the HQL query string that was invalid.
|
* Return the HQL query string that was invalid.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("NullAway")
|
|
||||||
public @Nullable String getQueryString() {
|
public @Nullable String getQueryString() {
|
||||||
return ((QueryException) getCause()).getQueryString();
|
QueryException cause = (QueryException) getCause();
|
||||||
|
return cause == null ? null : cause.getQueryString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ public class DefaultPersistenceUnitManager
|
|||||||
* @see #obtainDefaultPersistenceUnitInfo()
|
* @see #obtainDefaultPersistenceUnitInfo()
|
||||||
* @see #obtainPersistenceUnitInfo(String)
|
* @see #obtainPersistenceUnitInfo(String)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("NullAway")
|
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||||
public void preparePersistenceUnitInfos() {
|
public void preparePersistenceUnitInfos() {
|
||||||
this.persistenceUnitInfoNames.clear();
|
this.persistenceUnitInfoNames.clear();
|
||||||
this.persistenceUnitInfos.clear();
|
this.persistenceUnitInfos.clear();
|
||||||
|
|||||||
@@ -238,13 +238,13 @@ class PersistenceManagedTypesBeanRegistrationAotProcessor implements BeanRegistr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("NullAway")
|
@SuppressWarnings("NullAway") // Not null assertion performed in ReflectionHints.registerType
|
||||||
private void registerForReflection(ReflectionHints reflection, @Nullable Annotation annotation, String attribute) {
|
private void registerForReflection(ReflectionHints reflection, @Nullable Annotation annotation, String attribute) {
|
||||||
if (annotation == null) {
|
if (annotation == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Class<?> embeddableInstantiatorClass = (Class<?>) AnnotationUtils.getAnnotationAttributes(annotation).get(attribute);
|
Class<?> type = (Class<?>) AnnotationUtils.getAnnotationAttributes(annotation).get(attribute);
|
||||||
reflection.registerType(embeddableInstantiatorClass, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
reflection.registerType(type, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -848,7 +848,7 @@ public class PersistenceAnnotationBeanPostProcessor implements InstantiationAwar
|
|||||||
return CodeBlock.of("$L($L)", generatedMethod.getName(), REGISTERED_BEAN_PARAMETER);
|
return CodeBlock.of("$L($L)", generatedMethod.getName(), REGISTERED_BEAN_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("NullAway")
|
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||||
private void generateGetEntityManagerMethod(MethodSpec.Builder method, PersistenceElement injectedElement) {
|
private void generateGetEntityManagerMethod(MethodSpec.Builder method, PersistenceElement injectedElement) {
|
||||||
String unitName = injectedElement.unitName;
|
String unitName = injectedElement.unitName;
|
||||||
Properties properties = injectedElement.properties;
|
Properties properties = injectedElement.properties;
|
||||||
|
|||||||
Reference in New Issue
Block a user