Fix nullability warnings

This commit is contained in:
Juergen Hoeller
2020-10-26 22:19:26 +01:00
parent 5b910a87c3
commit 0aa3205e38
4 changed files with 20 additions and 14 deletions

View File

@@ -75,8 +75,10 @@ public abstract class TestContextAnnotationUtils {
private static final ConcurrentLruCache<Class<?>, EnclosingConfiguration> cachedEnclosingConfigurationModes =
new ConcurrentLruCache<>(32, TestContextAnnotationUtils::lookUpEnclosingConfiguration);
@Nullable
private static volatile EnclosingConfiguration defaultEnclosingConfigurationMode;
/**
* Find the first annotation of the specified {@code annotationType} within
* the annotation hierarchy <em>above</em> the supplied class, merge that
@@ -411,13 +413,15 @@ public abstract class TestContextAnnotationUtils {
}
private static EnclosingConfiguration getDefaultEnclosingConfigurationMode() {
if (defaultEnclosingConfigurationMode == null) {
EnclosingConfiguration defaultConfigurationMode = defaultEnclosingConfigurationMode;
if (defaultConfigurationMode == null) {
String value = SpringProperties.getProperty(NestedTestConfiguration.ENCLOSING_CONFIGURATION_PROPERTY_NAME);
EnclosingConfiguration enclosingConfigurationMode = EnclosingConfiguration.from(value);
defaultEnclosingConfigurationMode =
defaultConfigurationMode =
(enclosingConfigurationMode != null ? enclosingConfigurationMode : EnclosingConfiguration.INHERIT);
defaultEnclosingConfigurationMode = defaultConfigurationMode;
}
return defaultEnclosingConfigurationMode;
return defaultConfigurationMode;
}
private static void assertNonEmptyAnnotationTypeArray(Class<?>[] annotationTypes, String message) {
@@ -503,9 +507,10 @@ public abstract class TestContextAnnotationUtils {
this.declaringClass = declaringClass;
this.composedAnnotation = composedAnnotation;
this.annotation = annotation;
this.annotationAttributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
rootDeclaringClass, annotation.annotationType().getName(), false, false);
Assert.state(this.annotationAttributes != null, "No annotation attributes");
Assert.state(attributes != null, "No annotation attributes");
this.annotationAttributes = attributes;
}
public Class<?> getRootDeclaringClass() {

View File

@@ -126,16 +126,15 @@ public abstract class TestPropertySourceUtils {
}
private static boolean duplicationDetected(TestPropertySourceAttributes currentAttributes,
TestPropertySourceAttributes previousAttributes) {
@Nullable TestPropertySourceAttributes previousAttributes) {
boolean duplicationDetected =
(currentAttributes.equals(previousAttributes) && !currentAttributes.isEmpty());
if (duplicationDetected && logger.isDebugEnabled()) {
logger.debug(String.format("Ignoring duplicate %s declaration on %s, "
+ "since it is also declared on %s.", currentAttributes,
previousAttributes.getDeclaringClass().getName(),
currentAttributes.getDeclaringClass().getName()));
logger.debug(String.format("Ignoring duplicate %s declaration on %s since it is also declared on %s",
currentAttributes, currentAttributes.getDeclaringClass().getName(),
previousAttributes.getDeclaringClass().getName()));
}
return duplicationDetected;