Skip to content

Commit bfbe8f8

Browse files
committed
Polish MergedTestPropertySources
1 parent a37eaf7 commit bfbe8f8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

spring-test/src/main/java/org/springframework/test/context/support/MergedTestPropertySources.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@
3030
*/
3131
class MergedTestPropertySources {
3232

33-
private static final String[] EMPTY_STRING_ARRAY = new String[0];
33+
private static final MergedTestPropertySources empty = new MergedTestPropertySources(new String[0], new String[0]);
3434

3535
private final String[] locations;
3636

3737
private final String[] properties;
3838

3939

4040
/**
41-
* Create an <em>empty</em> {@code MergedTestPropertySources} instance.
41+
* Factory for an <em>empty</em> {@code MergedTestPropertySources} instance.
4242
*/
43-
MergedTestPropertySources() {
44-
this(EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY);
43+
static MergedTestPropertySources empty() {
44+
return empty;
4545
}
4646

47+
4748
/**
4849
* Create a {@code MergedTestPropertySources} instance with the supplied
4950
* {@code locations} and {@code properties}.

spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public abstract class TestPropertySourceUtils {
9292
static MergedTestPropertySources buildMergedTestPropertySources(Class<?> testClass) {
9393
MergedAnnotations mergedAnnotations = MergedAnnotations.from(testClass, SearchStrategy.EXHAUSTIVE);
9494
return (mergedAnnotations.isPresent(TestPropertySource.class) ? mergeTestPropertySources(mergedAnnotations) :
95-
new MergedTestPropertySources());
95+
MergedTestPropertySources.empty());
9696
}
9797

9898
private static MergedTestPropertySources mergeTestPropertySources(MergedAnnotations mergedAnnotations) {

0 commit comments

Comments
 (0)