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
10fbae8f
Commit
10fbae8f
authored
Oct 02, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid leaking application context shutdown hooks in the tests
Closes gh-4053
parent
c6040e42
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
+26
-9
SpringApplication.java
...main/java/org/springframework/boot/SpringApplication.java
+8
-8
SimpleMainTests.java
...c/test/java/org/springframework/boot/SimpleMainTests.java
+2
-1
SpringApplicationTests.java
...java/org/springframework/boot/SpringApplicationTests.java
+5
-0
SpringApplicationBuilderTests.java
...framework/boot/builder/SpringApplicationBuilderTests.java
+11
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
View file @
10fbae8f
...
...
@@ -329,14 +329,6 @@ public class SpringApplication {
// Create, load, refresh and run the ApplicationContext
context
=
createApplicationContext
();
if
(
this
.
registerShutdownHook
)
{
try
{
context
.
registerShutdownHook
();
}
catch
(
AccessControlException
ex
)
{
// Not allowed in some environments.
}
}
context
.
setEnvironment
(
environment
);
postProcessApplicationContext
(
context
);
applyInitializers
(
context
);
...
...
@@ -358,6 +350,14 @@ public class SpringApplication {
// Refresh the context
refresh
(
context
);
if
(
this
.
registerShutdownHook
)
{
try
{
context
.
registerShutdownHook
();
}
catch
(
AccessControlException
ex
)
{
// Not allowed in some environments.
}
}
afterRefresh
(
context
,
applicationArguments
);
listeners
.
finished
(
context
,
null
);
return
context
;
...
...
spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java
View file @
10fbae8f
...
...
@@ -76,7 +76,8 @@ public class SimpleMainTests {
private
String
[]
getArgs
(
String
...
args
)
{
List
<
String
>
list
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
"--spring.main.webEnvironment=false"
,
"--spring.main.showBanner=false"
));
"--spring.main.webEnvironment=false"
,
"--spring.main.showBanner=false"
,
"--spring.main.registerShutdownHook=false"
));
if
(
args
.
length
>
0
)
{
list
.
add
(
"--spring.main.sources="
+
StringUtils
.
arrayToCommaDelimitedString
(
args
));
...
...
spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
View file @
10fbae8f
...
...
@@ -673,6 +673,11 @@ public class SpringApplicationTests {
return
this
.
applicationContext
;
}
@Override
public
void
close
()
{
this
.
applicationContext
.
close
();
}
}
private
static
class
TestSpringApplication
extends
SpringApplication
{
...
...
spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java
View file @
10fbae8f
...
...
@@ -310,5 +310,16 @@ public class SpringApplicationBuilderTests {
public
boolean
getRegisteredShutdownHook
()
{
return
this
.
registeredShutdownHook
;
}
@Override
public
void
close
()
{
super
.
close
();
this
.
applicationContext
.
close
();
}
@Override
public
ApplicationContext
getParent
()
{
return
this
.
applicationContext
.
getParent
();
}
}
}
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