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
226ee61d
Commit
226ee61d
authored
Mar 16, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create exception reporters when needed so they pick up current state
Fixes gh-25691
parent
df1d1dba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
SpringApplication.java
...main/java/org/springframework/boot/SpringApplication.java
+19
-9
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
View file @
226ee61d
...
@@ -299,7 +299,6 @@ public class SpringApplication {
...
@@ -299,7 +299,6 @@ public class SpringApplication {
StopWatch
stopWatch
=
new
StopWatch
();
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
stopWatch
.
start
();
ConfigurableApplicationContext
context
=
null
;
ConfigurableApplicationContext
context
=
null
;
Collection
<
SpringBootExceptionReporter
>
exceptionReporters
=
new
ArrayList
<>();
configureHeadlessProperty
();
configureHeadlessProperty
();
SpringApplicationRunListeners
listeners
=
getRunListeners
(
args
);
SpringApplicationRunListeners
listeners
=
getRunListeners
(
args
);
listeners
.
starting
();
listeners
.
starting
();
...
@@ -309,8 +308,6 @@ public class SpringApplication {
...
@@ -309,8 +308,6 @@ public class SpringApplication {
configureIgnoreBeanInfo
(
environment
);
configureIgnoreBeanInfo
(
environment
);
Banner
printedBanner
=
printBanner
(
environment
);
Banner
printedBanner
=
printBanner
(
environment
);
context
=
createApplicationContext
();
context
=
createApplicationContext
();
exceptionReporters
=
getSpringFactoriesInstances
(
SpringBootExceptionReporter
.
class
,
new
Class
[]
{
ConfigurableApplicationContext
.
class
},
context
);
prepareContext
(
context
,
environment
,
listeners
,
applicationArguments
,
printedBanner
);
prepareContext
(
context
,
environment
,
listeners
,
applicationArguments
,
printedBanner
);
refreshContext
(
context
);
refreshContext
(
context
);
afterRefresh
(
context
,
applicationArguments
);
afterRefresh
(
context
,
applicationArguments
);
...
@@ -322,7 +319,7 @@ public class SpringApplication {
...
@@ -322,7 +319,7 @@ public class SpringApplication {
callRunners
(
context
,
applicationArguments
);
callRunners
(
context
,
applicationArguments
);
}
}
catch
(
Throwable
ex
)
{
catch
(
Throwable
ex
)
{
handleRunFailure
(
context
,
ex
,
exceptionReporters
,
listeners
);
handleRunFailure
(
context
,
ex
,
listeners
);
throw
new
IllegalStateException
(
ex
);
throw
new
IllegalStateException
(
ex
);
}
}
...
@@ -330,7 +327,7 @@ public class SpringApplication {
...
@@ -330,7 +327,7 @@ public class SpringApplication {
listeners
.
running
(
context
);
listeners
.
running
(
context
);
}
}
catch
(
Throwable
ex
)
{
catch
(
Throwable
ex
)
{
handleRunFailure
(
context
,
ex
,
exceptionReporters
,
null
);
handleRunFailure
(
context
,
ex
,
null
);
throw
new
IllegalStateException
(
ex
);
throw
new
IllegalStateException
(
ex
);
}
}
return
context
;
return
context
;
...
@@ -800,7 +797,7 @@ public class SpringApplication {
...
@@ -800,7 +797,7 @@ public class SpringApplication {
}
}
private
void
handleRunFailure
(
ConfigurableApplicationContext
context
,
Throwable
exception
,
private
void
handleRunFailure
(
ConfigurableApplicationContext
context
,
Throwable
exception
,
Collection
<
SpringBootExceptionReporter
>
exceptionReporters
,
SpringApplicationRunListeners
listeners
)
{
SpringApplicationRunListeners
listeners
)
{
try
{
try
{
try
{
try
{
handleExitCode
(
context
,
exception
);
handleExitCode
(
context
,
exception
);
...
@@ -809,7 +806,7 @@ public class SpringApplication {
...
@@ -809,7 +806,7 @@ public class SpringApplication {
}
}
}
}
finally
{
finally
{
reportFailure
(
exceptionReporters
,
exception
);
reportFailure
(
context
,
exception
);
if
(
context
!=
null
)
{
if
(
context
!=
null
)
{
context
.
close
();
context
.
close
();
}
}
...
@@ -821,9 +818,9 @@ public class SpringApplication {
...
@@ -821,9 +818,9 @@ public class SpringApplication {
ReflectionUtils
.
rethrowRuntimeException
(
exception
);
ReflectionUtils
.
rethrowRuntimeException
(
exception
);
}
}
private
void
reportFailure
(
Collection
<
SpringBootExceptionReporter
>
exceptionReporters
,
Throwable
failure
)
{
private
void
reportFailure
(
ApplicationContext
context
,
Throwable
failure
)
{
try
{
try
{
for
(
SpringBootExceptionReporter
reporter
:
exceptionReporters
)
{
for
(
SpringBootExceptionReporter
reporter
:
getExceptionReporters
(
context
)
)
{
if
(
reporter
.
reportException
(
failure
))
{
if
(
reporter
.
reportException
(
failure
))
{
registerLoggedException
(
failure
);
registerLoggedException
(
failure
);
return
;
return
;
...
@@ -839,6 +836,19 @@ public class SpringApplication {
...
@@ -839,6 +836,19 @@ public class SpringApplication {
}
}
}
}
private
Collection
<
SpringBootExceptionReporter
>
getExceptionReporters
(
ApplicationContext
context
)
{
try
{
if
(
context
!=
null
)
{
return
getSpringFactoriesInstances
(
SpringBootExceptionReporter
.
class
,
new
Class
[]
{
ConfigurableApplicationContext
.
class
},
context
);
}
}
catch
(
Throwable
ex
)
{
// Continue
}
return
Collections
.
emptyList
();
}
/**
/**
* Register that the given exception has been logged. By default, if the running in
* Register that the given exception has been logged. By default, if the running in
* the main thread, this method will suppress additional printing of the stacktrace.
* the main thread, this method will suppress additional printing of the stacktrace.
...
...
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