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
0df37b91
Commit
0df37b91
authored
Jun 04, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore unresolvable placeholders during property binding
Closes gh-13122
parent
9c8d2c80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
15 deletions
+9
-15
PropertySourcesPlaceholdersResolver.java
.../properties/bind/PropertySourcesPlaceholdersResolver.java
+2
-2
BinderTests.java
...ngframework/boot/context/properties/bind/BinderTests.java
+3
-7
PropertySourcesPlaceholdersResolverTests.java
...erties/bind/PropertySourcesPlaceholdersResolverTests.java
+4
-6
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java
View file @
0df37b91
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -51,7 +51,7 @@ public class PropertySourcesPlaceholdersResolver implements PlaceholdersResolver
this
.
helper
=
(
helper
!=
null
?
helper
:
new
PropertyPlaceholderHelper
(
SystemPropertyUtils
.
PLACEHOLDER_PREFIX
,
SystemPropertyUtils
.
PLACEHOLDER_SUFFIX
,
SystemPropertyUtils
.
VALUE_SEPARATOR
,
fals
e
));
SystemPropertyUtils
.
VALUE_SEPARATOR
,
tru
e
));
}
@Override
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java
View file @
0df37b91
...
...
@@ -30,7 +30,6 @@ import org.assertj.core.matcher.AssertionMatcher;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.internal.matchers.ThrowableMessageMatcher
;
import
org.junit.rules.ExpectedException
;
import
org.mockito.Answers
;
import
org.mockito.InOrder
;
...
...
@@ -53,7 +52,6 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.validation.beanvalidation.SpringValidatorAdapter
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
...
...
@@ -153,15 +151,13 @@ public class BinderTests {
}
@Test
public
void
bindToValueWithMissingPlaceholder
sShouldThrowException
()
{
public
void
bindToValueWithMissingPlaceholder
ShouldResolveToValueWithPlaceholder
()
{
StandardEnvironment
environment
=
new
StandardEnvironment
();
this
.
sources
.
add
(
new
MockConfigurationPropertySource
(
"foo"
,
"${bar}"
));
this
.
binder
=
new
Binder
(
this
.
sources
,
new
PropertySourcesPlaceholdersResolver
(
environment
));
this
.
thrown
.
expect
(
BindException
.
class
);
this
.
thrown
.
expectCause
(
ThrowableMessageMatcher
.
hasMessage
(
containsString
(
"Could not resolve placeholder 'bar' in value \"${bar}\""
)));
this
.
binder
.
bind
(
"foo"
,
Bindable
.
of
(
Integer
.
class
));
BindResult
<
String
>
result
=
this
.
binder
.
bind
(
"foo"
,
Bindable
.
of
(
String
.
class
));
assertThat
(
result
.
get
()).
isEqualTo
(
"${bar}"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolverTests.java
View file @
0df37b91
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -67,12 +67,10 @@ public class PropertySourcesPlaceholdersResolverTests {
}
@Test
public
void
resolveIfPlaceholderAbsentAndNoDefault
ShouldThrowException
()
{
public
void
resolveIfPlaceholderAbsentAndNoDefault
UsesPlaceholder
()
{
this
.
resolver
=
new
PropertySourcesPlaceholdersResolver
((
PropertySources
)
null
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Could not resolve placeholder 'FOO' in value \"${FOO}\""
);
this
.
resolver
.
resolvePlaceholders
(
"${FOO}"
);
Object
resolved
=
this
.
resolver
.
resolvePlaceholders
(
"${FOO}"
);
assertThat
(
resolved
).
isEqualTo
(
"${FOO}"
);
}
@Test
...
...
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