Commit 9eed719c authored by Brian Clozel's avatar Brian Clozel

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
parent 87de8a5e
/* /*
* 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"); * 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.
...@@ -131,6 +131,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit ...@@ -131,6 +131,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
if (this.registerErrorPageFilter) { if (this.registerErrorPageFilter) {
application.addPrimarySources(Collections.singleton(ErrorPageFilterConfiguration.class)); application.addPrimarySources(Collections.singleton(ErrorPageFilterConfiguration.class));
} }
application.setRegisterShutdownHook(false);
return run(application); return run(application);
} }
......
/* /*
* 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"); * 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.
...@@ -100,6 +100,12 @@ class SpringBootServletInitializerTests { ...@@ -100,6 +100,12 @@ class SpringBootServletInitializerTests {
WithConfigurationAnnotation.class); WithConfigurationAnnotation.class);
} }
@Test
void shutdownHookIsNotRegistered() {
new WithConfigurationAnnotation().createRootApplicationContext(this.servletContext);
assertThat(this.application).hasFieldOrPropertyWithValue("registerShutdownHook", false);
}
@Test @Test
void errorPageFilterRegistrationCanBeDisabled() { void errorPageFilterRegistrationCanBeDisabled() {
WebServer webServer = new UndertowServletWebServerFactory(0).getWebServer((servletContext) -> { WebServer webServer = new UndertowServletWebServerFactory(0).getWebServer((servletContext) -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment