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
9c8d2c80
Commit
9c8d2c80
authored
Jun 04, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve analysis of bind failures caused by a conversion failure
Closes gh-13357
parent
ea51cfab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
BindFailureAnalyzer.java
...mework/boot/diagnostics/analyzer/BindFailureAnalyzer.java
+6
-0
BindFailureAnalyzerTests.java
...k/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java
+6
-6
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzer.java
View file @
9c8d2c80
...
@@ -70,6 +70,12 @@ class BindFailureAnalyzer extends AbstractFailureAnalyzer<BindException> {
...
@@ -70,6 +70,12 @@ class BindFailureAnalyzer extends AbstractFailureAnalyzer<BindException> {
}
}
private
String
getMessage
(
BindException
cause
)
{
private
String
getMessage
(
BindException
cause
)
{
ConversionFailedException
conversionFailure
=
findCause
(
cause
,
ConversionFailedException
.
class
);
if
(
conversionFailure
!=
null
)
{
return
"failed to convert "
+
conversionFailure
.
getSourceType
()
+
" to "
+
conversionFailure
.
getTargetType
();
}
Throwable
failure
=
cause
;
Throwable
failure
=
cause
;
while
(
failure
.
getCause
()
!=
null
)
{
while
(
failure
.
getCause
()
!=
null
)
{
failure
=
failure
.
getCause
();
failure
=
failure
.
getCause
();
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java
View file @
9c8d2c80
...
@@ -62,10 +62,10 @@ public class BindFailureAnalyzerTests {
...
@@ -62,10 +62,10 @@ public class BindFailureAnalyzerTests {
@Test
@Test
public
void
bindExceptionDueToOtherFailure
()
{
public
void
bindExceptionDueToOtherFailure
()
{
FailureAnalysis
analysis
=
performAnalysis
(
GenericFailureConfiguration
.
class
,
FailureAnalysis
analysis
=
performAnalysis
(
GenericFailureConfiguration
.
class
,
"test.foo.value=
${BAR}
"
);
"test.foo.value=
alpha
"
);
assertThat
(
analysis
.
getDescription
()).
contains
(
failure
(
"test.foo.value"
,
"
${BAR}
"
,
assertThat
(
analysis
.
getDescription
()).
contains
(
failure
(
"test.foo.value"
,
"
alpha
"
,
"\"test.foo.value\" from property source \"test\""
,
"\"test.foo.value\" from property source \"test\""
,
"
Could not resolve placeholder 'BAR' in value \"${BAR}\"
"
));
"
failed to convert java.lang.String to int
"
));
}
}
@Test
@Test
...
@@ -187,13 +187,13 @@ public class BindFailureAnalyzerTests {
...
@@ -187,13 +187,13 @@ public class BindFailureAnalyzerTests {
@ConfigurationProperties
(
"test.foo"
)
@ConfigurationProperties
(
"test.foo"
)
static
class
GenericFailureProperties
{
static
class
GenericFailureProperties
{
private
String
value
;
private
int
value
;
public
String
getValue
()
{
public
int
getValue
()
{
return
this
.
value
;
return
this
.
value
;
}
}
public
void
setValue
(
String
value
)
{
public
void
setValue
(
int
value
)
{
this
.
value
=
value
;
this
.
value
=
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