Skip to content

Commit 24dd484

Browse files
committed
Polish internal SequencedProperties implementation
1 parent b43972b commit 24dd484

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ public static void addInlinedPropertiesToEnvironment(ConfigurableEnvironment env
389389
*/
390390
public static Map<String, Object> convertInlinedPropertiesToMap(String... inlinedProperties) {
391391
Assert.notNull(inlinedProperties, "'inlinedProperties' must not be null");
392-
SequencedProperties sequencedProperties = new SequencedProperties();
392+
393+
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
394+
SequencedProperties sequencedProperties = new SequencedProperties(map);
393395

394396
for (String input : inlinedProperties) {
395397
if (!StringUtils.hasText(input)) {
@@ -403,7 +405,7 @@ public static Map<String, Object> convertInlinedPropertiesToMap(String... inline
403405
}
404406
}
405407

406-
return sequencedProperties.map;
408+
return map;
407409
}
408410

409411
private static <T extends Annotation> List<List<MergedAnnotation<T>>> findRepeatableAnnotations(
@@ -452,14 +454,17 @@ private static <A extends Annotation> Comparator<MergedAnnotation<A>> highMetaDi
452454

453455
/**
454456
* Extension of {@link Properties} that mimics a {@code SequencedMap} by
455-
* tracking all added properties in a {@link LinkedHashMap} that can be
456-
* accessed directly via the {@code map} field.
457+
* tracking all added properties in the supplied {@link LinkedHashMap}.
457458
* @since 6.1
458459
*/
459460
@SuppressWarnings("serial")
460461
private static class SequencedProperties extends Properties {
461462

462-
final Map<String, Object> map = new LinkedHashMap<>();
463+
private final LinkedHashMap<String, Object> map;
464+
465+
SequencedProperties(LinkedHashMap<String, Object> map) {
466+
this.map = map;
467+
}
463468

464469
@Override
465470
public synchronized Object put(Object key, Object value) {

0 commit comments

Comments
 (0)