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:
@@ -42,7 +42,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
* @param msg the detail message
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectOptimisticLockingFailureException(String msg, Throwable cause) {
|
||||
public ObjectOptimisticLockingFailureException(@Nullable String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.persistentClass = null;
|
||||
this.identifier = null;
|
||||
@@ -123,7 +123,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectOptimisticLockingFailureException(
|
||||
String persistentClassName, @Nullable Object identifier, String msg, @Nullable Throwable cause) {
|
||||
String persistentClassName, @Nullable Object identifier, @Nullable String msg, @Nullable Throwable cause) {
|
||||
|
||||
super(msg, cause);
|
||||
this.persistentClass = persistentClassName;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti
|
||||
* @param msg the detail message
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectRetrievalFailureException(String msg, Throwable cause) {
|
||||
public ObjectRetrievalFailureException(@Nullable String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.persistentClass = null;
|
||||
this.identifier = null;
|
||||
@@ -97,7 +97,7 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti
|
||||
* @param cause the source exception
|
||||
*/
|
||||
public ObjectRetrievalFailureException(
|
||||
String persistentClassName, @Nullable Object identifier, String msg, @Nullable Throwable cause) {
|
||||
String persistentClassName, @Nullable Object identifier, @Nullable String msg, @Nullable Throwable cause) {
|
||||
|
||||
super(msg, cause);
|
||||
this.persistentClass = persistentClassName;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.sql.SQLException;
|
||||
import org.hibernate.JDBCException;
|
||||
|
||||
import org.springframework.dao.UncategorizedDataAccessException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Hibernate-specific subclass of UncategorizedDataAccessException,
|
||||
@@ -48,6 +49,7 @@ public class HibernateJdbcException extends UncategorizedDataAccessException {
|
||||
/**
|
||||
* Return the SQL that led to the problem.
|
||||
*/
|
||||
@Nullable
|
||||
public String getSql() {
|
||||
return ((JDBCException) getCause()).getSQL();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.orm.hibernate5;
|
||||
import org.hibernate.QueryException;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Hibernate-specific subclass of InvalidDataAccessResourceUsageException,
|
||||
@@ -38,6 +39,7 @@ public class HibernateQueryException extends InvalidDataAccessResourceUsageExcep
|
||||
/**
|
||||
* Return the HQL query string that was invalid.
|
||||
*/
|
||||
@Nullable
|
||||
public String getQueryString() {
|
||||
return ((QueryException) getCause()).getQueryString();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.orm.hibernate5.SessionFactoryUtils;
|
||||
import org.springframework.orm.hibernate5.SessionHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
@@ -72,7 +73,7 @@ class AsyncRequestInterceptor implements CallableProcessingInterceptor, Deferred
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object concurrentResult) {
|
||||
public <T> void postProcess(NativeWebRequest request, Callable<T> task, @Nullable Object concurrentResult) {
|
||||
TransactionSynchronizationManager.unbindResource(this.sessionFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import jakarta.persistence.EntityManagerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.orm.jpa.EntityManagerFactoryUtils;
|
||||
import org.springframework.orm.jpa.EntityManagerHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
@@ -72,7 +73,7 @@ class AsyncRequestInterceptor implements CallableProcessingInterceptor, Deferred
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object concurrentResult) {
|
||||
public <T> void postProcess(NativeWebRequest request, Callable<T> task, @Nullable Object concurrentResult) {
|
||||
TransactionSynchronizationManager.unbindResource(this.emFactory);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user