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
ebae76b1
Commit
ebae76b1
authored
Sep 04, 2019
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect against null BindHandler.onStart result
Fixes gh-18129
parent
1851f711
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
Binder.java
.../springframework/boot/context/properties/bind/Binder.java
+3
-2
BinderTests.java
...ngframework/boot/context/properties/bind/BinderTests.java
+14
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java
View file @
ebae76b1
...
...
@@ -285,10 +285,11 @@ public class Binder {
boolean
allowRecursiveBinding
,
boolean
create
)
{
context
.
clearConfigurationProperty
();
try
{
t
arget
=
handler
.
onStart
(
name
,
target
,
context
);
if
(
t
arget
==
null
)
{
Bindable
<
T
>
replacementT
arget
=
handler
.
onStart
(
name
,
target
,
context
);
if
(
replacementT
arget
==
null
)
{
return
handleBindResult
(
name
,
target
,
handler
,
context
,
null
,
create
);
}
target
=
replacementTarget
;
Object
bound
=
bindObject
(
name
,
target
,
handler
,
context
,
allowRecursiveBinding
);
return
handleBindResult
(
name
,
target
,
handler
,
context
,
bound
,
create
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java
View file @
ebae76b1
...
...
@@ -318,6 +318,20 @@ class BinderTests {
assertThat
(
value
).
isInstanceOf
(
JavaBean
.
class
);
}
@Test
void
bindToJavaBeanWhenHandlerOnStartReturnsNullShouldReturnUnbound
()
{
// gh-18129
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo.value"
,
"bar"
));
BindResult
<
JavaBean
>
result
=
this
.
binder
.
bind
(
"foo"
,
Bindable
.
of
(
JavaBean
.
class
),
new
BindHandler
()
{
@Override
public
<
T
>
Bindable
<
T
>
onStart
(
ConfigurationPropertyName
name
,
Bindable
<
T
>
target
,
BindContext
context
)
{
return
null
;
}
});
assertThat
(
result
.
isBound
()).
isFalse
();
}
static
class
JavaBean
{
private
String
value
;
...
...
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