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
e524adb2
Commit
e524adb2
authored
Jul 25, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
eefa0ada
1831f3be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
IndexedElementsBinder.java
...k/boot/context/properties/bind/IndexedElementsBinder.java
+4
-3
CollectionBinderTests.java
...k/boot/context/properties/bind/CollectionBinderTests.java
+23
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java
View file @
e524adb2
...
...
@@ -128,9 +128,10 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
}
for
(
ConfigurationPropertyName
name
:
(
IterableConfigurationPropertySource
)
source
.
filter
(
root:
:
isAncestorOf
))
{
name
=
name
.
chop
(
root
.
getNumberOfElements
()
+
1
);
if
(
name
.
isLastElementIndexed
())
{
String
key
=
name
.
getLastElement
(
Form
.
UNIFORM
);
ConfigurationPropertyName
choppedName
=
name
.
chop
(
root
.
getNumberOfElements
()
+
1
);
if
(
choppedName
.
isLastElementIndexed
())
{
String
key
=
choppedName
.
getLastElement
(
Form
.
UNIFORM
);
ConfigurationProperty
value
=
source
.
getConfigurationProperty
(
name
);
children
.
add
(
key
,
value
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java
View file @
e524adb2
...
...
@@ -134,6 +134,29 @@ public class CollectionBinderTests {
}
}
@Test
public
void
bindToNonScalarCollectionWhenNonSequentialShouldThrowException
()
{
MockConfigurationPropertySource
source
=
new
MockConfigurationPropertySource
();
source
.
put
(
"foo[0].value"
,
"1"
);
source
.
put
(
"foo[1].value"
,
"2"
);
source
.
put
(
"foo[4].value"
,
"4"
);
this
.
sources
.
add
(
source
);
try
{
Bindable
<
List
<
JavaBean
>>
target
=
Bindable
.
listOf
(
JavaBean
.
class
);
this
.
binder
.
bind
(
"foo"
,
target
);
fail
(
"No exception thrown"
);
}
catch
(
BindException
ex
)
{
ex
.
printStackTrace
();
Set
<
ConfigurationProperty
>
unbound
=
((
UnboundConfigurationPropertiesException
)
ex
.
getCause
()).
getUnboundProperties
();
assertThat
(
unbound
).
hasSize
(
1
);
ConfigurationProperty
property
=
unbound
.
iterator
().
next
();
assertThat
(
property
.
getName
().
toString
()).
isEqualTo
(
"foo[4].value"
);
assertThat
(
property
.
getValue
()).
isEqualTo
(
"4"
);
}
}
@Test
public
void
bindToCollectionWhenNonIterableShouldReturnPopulatedCollection
()
{
MockConfigurationPropertySource
source
=
new
MockConfigurationPropertySource
();
...
...
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