Nullability refinements and related polishing

This commit is contained in:
Juergen Hoeller
2019-07-31 13:45:48 +02:00
parent cca32a56a4
commit e6f86c5c75
12 changed files with 147 additions and 149 deletions

View File

@@ -163,6 +163,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
/**
* Get the {@code @SqlMergeMode} annotation declared on the supplied {@code element}.
*/
@Nullable
private SqlMergeMode getSqlMergeModeFor(AnnotatedElement element) {
return AnnotatedElementUtils.findMergedAnnotation(element, SqlMergeMode.class);
}

View File

@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
/**
* {@code TestPropertySourceAttributes} encapsulates attributes declared
@@ -196,7 +197,7 @@ class TestPropertySourceAttributes {
* @see TestPropertySource#locations
*/
String[] getLocations() {
return this.locations.toArray(new String[0]);
return StringUtils.toStringArray(this.locations);
}
/**
@@ -217,7 +218,7 @@ class TestPropertySourceAttributes {
* @see TestPropertySource#properties
*/
String[] getProperties() {
return this.properties.toArray(new String[0]);
return StringUtils.toStringArray(this.properties);
}
/**
@@ -245,7 +246,9 @@ class TestPropertySourceAttributes {
}
private static Class<?> declaringClass(MergedAnnotation<?> mergedAnnotation) {
return (Class<?>) mergedAnnotation.getSource();
Object source = mergedAnnotation.getSource();
Assert.state(source instanceof Class, "No source class available");
return (Class<?>) source;
}
}

View File

@@ -130,9 +130,7 @@ public abstract class TestPropertySourceUtils {
logger.trace(String.format("Processing inlined properties for TestPropertySource attributes %s", attrs));
}
String[] attrProps = attrs.getProperties();
if (attrProps != null) {
properties.addAll(0, Arrays.asList(attrProps));
}
properties.addAll(0, Arrays.asList(attrProps));
if (!attrs.isInheritProperties()) {
break;
}