Refine null-safety in the spring-orm module
Closes gh-34159
This commit is contained in:
parent
abccba22f1
commit
73b24b6f7b
|
|
@ -42,7 +42,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
|||
/**
|
||||
* Return the underlying SQLException.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // JDBCException instances always have a non null cause
|
||||
public SQLException getSQLException() {
|
||||
return ((JDBCException) getCause()).getSQLException();
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
|||
/**
|
||||
* Return the SQL that led to the problem.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // JDBCException instances always have a non null cause
|
||||
public @Nullable String getSql() {
|
||||
return ((JDBCException) getCause()).getSQL();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ public class HibernateQueryException extends InvalidDataAccessResourceUsageExcep
|
|||
/**
|
||||
* Return the HQL query string that was invalid.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
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 #obtainPersistenceUnitInfo(String)
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||
public void preparePersistenceUnitInfos() {
|
||||
this.persistenceUnitInfoNames.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) {
|
||||
if (annotation == null) {
|
||||
return;
|
||||
}
|
||||
Class<?> embeddableInstantiatorClass = (Class<?>) AnnotationUtils.getAnnotationAttributes(annotation).get(attribute);
|
||||
reflection.registerType(embeddableInstantiatorClass, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
Class<?> type = (Class<?>) AnnotationUtils.getAnnotationAttributes(annotation).get(attribute);
|
||||
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);
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||
private void generateGetEntityManagerMethod(MethodSpec.Builder method, PersistenceElement injectedElement) {
|
||||
String unitName = injectedElement.unitName;
|
||||
Properties properties = injectedElement.properties;
|
||||
|
|
|
|||
Loading…
Reference in New Issue