mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 20:19:06 +00:00
Add nullability annotations to tests in module/spring-boot-validation
See gh-47263
This commit is contained in:
@@ -36,3 +36,7 @@ dependencies {
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@ import java.util.HashMap;
|
||||
import jakarta.validation.Validator;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import org.hibernate.validator.HibernateValidator;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
@@ -173,8 +174,8 @@ class ValidatorAdapterTests {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> type) {
|
||||
if (type.isInstance(this.delegate)) {
|
||||
public <T> @Nullable T unwrap(@Nullable Class<T> type) {
|
||||
if (type != null && type.isInstance(this.delegate)) {
|
||||
return (T) this.delegate;
|
||||
}
|
||||
return this.delegate.unwrap(type);
|
||||
|
||||
Reference in New Issue
Block a user