Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
beb7cb4b
Commit
beb7cb4b
authored
May 18, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve property ordering in SpringIterableConfigurationPropertySource
Fixes gh-21470
parent
4f31c3bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
SpringIterableConfigurationPropertySource.java
...ies/source/SpringIterableConfigurationPropertySource.java
+2
-2
SpringIterableConfigurationPropertySourceTests.java
...ource/SpringIterableConfigurationPropertySourceTests.java
+14
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java
View file @
beb7cb4b
...
...
@@ -19,9 +19,9 @@ package org.springframework.boot.context.properties.source;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.ConcurrentModificationException
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
import
java.util.Objects
;
...
...
@@ -259,7 +259,7 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
}
private
<
K
,
V
>
Map
<
K
,
V
>
cloneOrCreate
(
Map
<
K
,
V
>
source
,
int
size
)
{
return
(
source
!=
null
)
?
new
HashMap
<>(
source
)
:
new
HashMap
<>(
size
);
return
(
source
!=
null
)
?
new
LinkedHashMap
<>(
source
)
:
new
Linked
HashMap
<>(
size
);
}
private
void
addParents
(
Map
<
ConfigurationPropertyName
,
Set
<
ConfigurationPropertyName
>>
descendants
,
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySourceTests.java
View file @
beb7cb4b
...
...
@@ -224,6 +224,20 @@ class SpringIterableConfigurationPropertySourceTests {
assertThat
(
adapter
.
stream
()).
hasSize
(
2
);
}
@Test
void
orderOfUnderlyingSourceIsPreserved
()
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"test.map.alpha"
,
"value1"
);
map
.
put
(
"test.map.bravo"
,
"value2"
);
map
.
put
(
"test.map.charlie"
,
"value3"
);
map
.
put
(
"test.map.delta"
,
"value4"
);
EnumerablePropertySource
<?>
source
=
new
OriginTrackedMapPropertySource
(
"test"
,
map
,
true
);
SpringIterableConfigurationPropertySource
propertySource
=
new
SpringIterableConfigurationPropertySource
(
source
,
DefaultPropertyMapper
.
INSTANCE
);
assertThat
(
propertySource
.
stream
().
map
(
ConfigurationPropertyName:
:
toString
)).
containsExactly
(
"test.map.alpha"
,
"test.map.bravo"
,
"test.map.charlie"
,
"test.map.delta"
);
}
/**
* Test {@link PropertySource} that's also an {@link OriginLookup}.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment