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
79f47b15
Commit
79f47b15
authored
Jun 16, 2021
by
Scott Frederick
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x' into 2.5.x
Closes gh-26935
parents
577c58b7
5147fcac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
BeanNotOfRequiredTypeFailureAnalyzer.java
...ostics/analyzer/BeanNotOfRequiredTypeFailureAnalyzer.java
+8
-3
BeanNotOfRequiredTypeFailureAnalyzerTests.java
...s/analyzer/BeanNotOfRequiredTypeFailureAnalyzerTests.java
+7
-3
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanNotOfRequiredTypeFailureAnalyzer.java
View file @
79f47b15
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -29,6 +29,7 @@ import org.springframework.boot.diagnostics.FailureAnalysis;
...
@@ -29,6 +29,7 @@ import org.springframework.boot.diagnostics.FailureAnalysis;
* {@link BeanNotOfRequiredTypeException}.
* {@link BeanNotOfRequiredTypeException}.
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Scott Frederick
* @since 1.4.0
* @since 1.4.0
*/
*/
public
class
BeanNotOfRequiredTypeFailureAnalyzer
extends
AbstractFailureAnalyzer
<
BeanNotOfRequiredTypeException
>
{
public
class
BeanNotOfRequiredTypeFailureAnalyzer
extends
AbstractFailureAnalyzer
<
BeanNotOfRequiredTypeException
>
{
...
@@ -48,8 +49,12 @@ public class BeanNotOfRequiredTypeFailureAnalyzer extends AbstractFailureAnalyze
...
@@ -48,8 +49,12 @@ public class BeanNotOfRequiredTypeFailureAnalyzer extends AbstractFailureAnalyze
private
String
getDescription
(
BeanNotOfRequiredTypeException
ex
)
{
private
String
getDescription
(
BeanNotOfRequiredTypeException
ex
)
{
StringWriter
description
=
new
StringWriter
();
StringWriter
description
=
new
StringWriter
();
PrintWriter
printer
=
new
PrintWriter
(
description
);
PrintWriter
printer
=
new
PrintWriter
(
description
);
printer
.
printf
(
"The bean '%s' could not be injected as a '%s' because it is a "
printer
.
printf
(
"The bean '%s' could not be injected because it is a JDK dynamic proxy%n%n"
,
ex
.
getBeanName
());
+
"JDK dynamic proxy that implements:%n"
,
ex
.
getBeanName
(),
ex
.
getRequiredType
().
getName
());
printer
.
printf
(
"The bean is of type '%s' and implements:%n"
,
ex
.
getActualType
().
getName
());
for
(
Class
<?>
actualTypeInterface
:
ex
.
getActualType
().
getInterfaces
())
{
printer
.
println
(
"\t"
+
actualTypeInterface
.
getName
());
}
printer
.
printf
(
"%nExpected a bean of type '%s' which implements:%n"
,
ex
.
getRequiredType
().
getName
());
for
(
Class
<?>
requiredTypeInterface
:
ex
.
getRequiredType
().
getInterfaces
())
{
for
(
Class
<?>
requiredTypeInterface
:
ex
.
getRequiredType
().
getInterfaces
())
{
printer
.
println
(
"\t"
+
requiredTypeInterface
.
getName
());
printer
.
println
(
"\t"
+
requiredTypeInterface
.
getName
());
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanNotOfRequiredTypeFailureAnalyzerTests.java
View file @
79f47b15
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -35,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
...
@@ -35,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
* Tests for {@link BeanNotOfRequiredTypeFailureAnalyzer}.
* Tests for {@link BeanNotOfRequiredTypeFailureAnalyzer}.
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Scott Frederick
*/
*/
class
BeanNotOfRequiredTypeFailureAnalyzerTests
{
class
BeanNotOfRequiredTypeFailureAnalyzerTests
{
...
@@ -44,8 +45,11 @@ class BeanNotOfRequiredTypeFailureAnalyzerTests {
...
@@ -44,8 +45,11 @@ class BeanNotOfRequiredTypeFailureAnalyzerTests {
void
jdkProxyCausesInjectionFailure
()
{
void
jdkProxyCausesInjectionFailure
()
{
FailureAnalysis
analysis
=
performAnalysis
(
JdkProxyConfiguration
.
class
);
FailureAnalysis
analysis
=
performAnalysis
(
JdkProxyConfiguration
.
class
);
assertThat
(
analysis
.
getDescription
()).
startsWith
(
"The bean 'asyncBean'"
);
assertThat
(
analysis
.
getDescription
()).
startsWith
(
"The bean 'asyncBean'"
);
assertThat
(
analysis
.
getDescription
()).
contains
(
"'"
+
AsyncBean
.
class
.
getName
()
+
"'"
);
assertThat
(
analysis
.
getDescription
())
assertThat
(
analysis
.
getDescription
()).
endsWith
(
String
.
format
(
"%s%n"
,
SomeInterface
.
class
.
getName
()));
.
containsPattern
(
"The bean is of type '"
+
AsyncBean
.
class
.
getPackage
().
getName
()
+
".\\$Proxy.*'"
);
assertThat
(
analysis
.
getDescription
()).
contains
(
"and implements:\n\t"
+
SomeInterface
.
class
.
getName
());
assertThat
(
analysis
.
getDescription
()).
contains
(
"Expected a bean of type '"
+
AsyncBean
.
class
.
getName
()
+
"'"
);
assertThat
(
analysis
.
getDescription
()).
contains
(
"which implements:\n\t"
+
SomeInterface
.
class
.
getName
());
}
}
private
FailureAnalysis
performAnalysis
(
Class
<?>
configuration
)
{
private
FailureAnalysis
performAnalysis
(
Class
<?>
configuration
)
{
...
...
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