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
817c2289
Commit
817c2289
authored
May 31, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
58d634f4
0afd9473
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
BindFailureAnalyzer.java
...mework/boot/diagnostics/analyzer/BindFailureAnalyzer.java
+5
-4
BindFailureAnalyzerTests.java
...k/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java
+28
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzer.java
View file @
817c2289
...
...
@@ -70,11 +70,12 @@ class BindFailureAnalyzer extends AbstractFailureAnalyzer<BindException> {
}
private
String
getMessage
(
BindException
cause
)
{
if
(
cause
.
getCause
()
!=
null
&&
StringUtils
.
hasText
(
cause
.
getCause
().
getMessage
())
)
{
return
cause
.
getCause
().
getMessag
e
();
Throwable
failure
=
cause
;
while
(
failure
.
getCause
()
!=
null
)
{
failure
=
failure
.
getCaus
e
();
}
return
cause
.
getMessage
();
return
(
StringUtils
.
hasText
(
failure
.
getMessage
())
?
failure
.
getMessage
()
:
cause
.
getMessage
());
}
private
FailureAnalysis
getFailureAnalysis
(
Object
description
,
BindException
cause
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java
View file @
817c2289
...
...
@@ -77,6 +77,14 @@ public class BindFailureAnalyzerTests {
}
}
@Test
public
void
bindExceptionWithNestedFailureShouldDisplayNestedMessage
()
{
FailureAnalysis
analysis
=
performAnalysis
(
NestedFailureConfiguration
.
class
,
"test.foo.value=hello"
);
assertThat
(
analysis
.
getDescription
()).
contains
(
failure
(
"test.foo.value"
,
"hello"
,
"\"test.foo.value\" from property source \"test\""
,
"This is a failure"
));
}
private
static
String
failure
(
String
property
,
String
value
,
String
origin
,
String
reason
)
{
return
String
.
format
(
...
...
@@ -139,6 +147,11 @@ public class BindFailureAnalyzerTests {
}
@EnableConfigurationProperties
(
NestedFailureProperties
.
class
)
static
class
NestedFailureConfiguration
{
}
@ConfigurationProperties
(
"test.foo"
)
@Validated
static
class
FieldValidationFailureProperties
{
...
...
@@ -201,6 +214,21 @@ public class BindFailureAnalyzerTests {
}
@ConfigurationProperties
(
"test.foo"
)
static
class
NestedFailureProperties
{
private
String
value
;
public
String
getValue
()
{
return
this
.
value
;
}
public
void
setValue
(
String
value
)
{
throw
new
RuntimeException
(
"This is a failure"
);
}
}
enum
Fruit
{
APPLE
,
BANANA
,
ORANGE
...
...
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