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
80652007
Commit
80652007
authored
Apr 21, 2014
by
Patrick Radtke
Committed by
Dave Syer
Apr 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RelaxedDataBinder handling for untyped map
Fixes gh-709
parent
a77fee9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
RelaxedDataBinder.java
...java/org/springframework/boot/bind/RelaxedDataBinder.java
+3
-0
RelaxedDataBinderTests.java
...org/springframework/boot/bind/RelaxedDataBinderTests.java
+23
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java
View file @
80652007
...
...
@@ -229,6 +229,9 @@ public class RelaxedDataBinder extends DataBinder {
return
;
}
TypeDescriptor
descriptor
=
parent
.
getMapValueTypeDescriptor
();
if
(
descriptor
==
null
)
{
descriptor
=
TypeDescriptor
.
valueOf
(
Object
.
class
);
}
if
(!
descriptor
.
isMap
()
&&
!
descriptor
.
isCollection
()
&&
!
descriptor
.
getType
().
equals
(
Object
.
class
))
{
return
;
...
...
spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java
View file @
80652007
...
...
@@ -258,6 +258,13 @@ public class RelaxedDataBinderTests {
assertEquals
(
"123"
,
target
.
getNested
().
get
(
"value"
));
}
@Test
public
void
testBindNestedUntypedMap
()
throws
Exception
{
TargetWithNestedUntypedMap
target
=
new
TargetWithNestedUntypedMap
();
bind
(
target
,
"nested.foo: bar\n"
+
"nested.value: 123"
);
assertEquals
(
"123"
,
target
.
getNested
().
get
(
"value"
));
}
@Test
public
void
testBindNestedMapOfString
()
throws
Exception
{
TargetWithNestedMapOfString
target
=
new
TargetWithNestedMapOfString
();
...
...
@@ -503,6 +510,22 @@ public class RelaxedDataBinderTests {
}
}
@SuppressWarnings
(
"rawtypes"
)
public
static
class
TargetWithNestedUntypedMap
{
private
Map
nested
;
public
Map
getNested
()
{
return
this
.
nested
;
}
public
void
setNested
(
Map
nested
)
{
this
.
nested
=
nested
;
}
}
public
static
class
TargetWithNestedMapOfString
{
...
...
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