Do not register shutdownHook for WAR deployments
The application context shutdownHook is not needed for WAR deployments, and we should let the Servlet container handle the application lifecycle here. Closes gh-19398
This commit is contained in:
parent
87de8a5e15
commit
9eed719c44
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
@ -131,6 +131,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
|
|||
if (this.registerErrorPageFilter) {
|
||||
application.addPrimarySources(Collections.singleton(ErrorPageFilterConfiguration.class));
|
||||
}
|
||||
application.setRegisterShutdownHook(false);
|
||||
return run(application);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
|
@ -100,6 +100,12 @@ class SpringBootServletInitializerTests {
|
|||
WithConfigurationAnnotation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shutdownHookIsNotRegistered() {
|
||||
new WithConfigurationAnnotation().createRootApplicationContext(this.servletContext);
|
||||
assertThat(this.application).hasFieldOrPropertyWithValue("registerShutdownHook", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void errorPageFilterRegistrationCanBeDisabled() {
|
||||
WebServer webServer = new UndertowServletWebServerFactory(0).getWebServer((servletContext) -> {
|
||||
|
|
Loading…
Reference in New Issue