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
4ccce2a7
Commit
4ccce2a7
authored
Apr 30, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-26322
parents
63d48615
1af7fa22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
BeanCurrentlyInCreationFailureAnalyzer.java
...tics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java
+4
-3
BeanCurrentlyInCreationFailureAnalyzerTests.java
...analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java
+31
-1
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java
View file @
4ccce2a7
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -70,11 +70,12 @@ class BeanCurrentlyInCreationFailureAnalyzer extends AbstractFailureAnalyzer<Bea
message
.
append
(
String
.
format
(
"The dependencies of some of the beans in the application context form a cycle:%n%n"
));
List
<
BeanInCycle
>
beansInCycle
=
dependencyCycle
.
getBeansInCycle
();
boolean
singleBean
=
beansInCycle
.
size
()
==
1
;
int
cycleStart
=
dependencyCycle
.
getCycleStart
();
for
(
int
i
=
0
;
i
<
beansInCycle
.
size
();
i
++)
{
BeanInCycle
beanInCycle
=
beansInCycle
.
get
(
i
);
if
(
i
==
cycleStart
)
{
message
.
append
(
String
.
format
(
"┌─────┐%n"
));
message
.
append
(
String
.
format
(
singleBean
?
"┌──->──┐%n"
:
"┌─────┐%n"
));
}
else
if
(
i
>
0
)
{
String
leftSide
=
(
i
<
cycleStart
)
?
" "
:
"↑"
;
...
...
@@ -83,7 +84,7 @@ class BeanCurrentlyInCreationFailureAnalyzer extends AbstractFailureAnalyzer<Bea
String
leftSide
=
(
i
<
cycleStart
)
?
" "
:
"|"
;
message
.
append
(
String
.
format
(
"%s %s%n"
,
leftSide
,
beanInCycle
));
}
message
.
append
(
String
.
format
(
"└─────┘%n"
));
message
.
append
(
String
.
format
(
singleBean
?
"└──<-──┘%n"
:
"└─────┘%n"
));
return
message
.
toString
();
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java
View file @
4ccce2a7
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -109,6 +109,19 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
assertThat
(
lines
.
get
(
11
)).
isEqualTo
(
"└─────┘"
);
}
@Test
void
testSelfReferenceCycle
()
throws
IOException
{
FailureAnalysis
analysis
=
performAnalysis
(
SelfReferenceBeanConfiguration
.
class
);
List
<
String
>
lines
=
readDescriptionLines
(
analysis
);
assertThat
(
lines
).
hasSize
(
5
);
assertThat
(
lines
.
get
(
0
))
.
isEqualTo
(
"The dependencies of some of the beans in the application context form a cycle:"
);
assertThat
(
lines
.
get
(
1
)).
isEqualTo
(
""
);
assertThat
(
lines
.
get
(
2
)).
isEqualTo
(
"┌──->──┐"
);
assertThat
(
lines
.
get
(
3
)).
startsWith
(
"| bean defined in "
+
SelfReferenceBeanConfiguration
.
class
.
getName
());
assertThat
(
lines
.
get
(
4
)).
isEqualTo
(
"└──<-──┘"
);
}
@Test
void
cycleWithAnUnknownStartIsNotAnalyzed
()
{
assertThat
(
this
.
analyzer
.
analyze
(
new
BeanCurrentlyInCreationException
(
"test"
))).
isNull
();
...
...
@@ -240,6 +253,16 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
SelfReferenceBeanConfiguration
{
@Bean
SelfReferenceBean
bean
(
SelfReferenceBean
bean
)
{
return
new
SelfReferenceBean
();
}
}
static
class
RefererOne
{
@Autowired
...
...
@@ -266,4 +289,11 @@ class BeanCurrentlyInCreationFailureAnalyzerTests {
}
static
class
SelfReferenceBean
{
@Autowired
SelfReferenceBean
bean
;
}
}
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