-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document that the shutdown endpoint is not intended for use when deploying a war to a servlet container #17398
Comments
The shutdown endpoint will only create a thread to close the application context if you have called it. In other words, I don't believe that undeploying a war file from Tomcat will be sufficient to recreate this problem. Furthermore, the shutdown endpoint is disabled by default and is not intended for use when deploying a war file to a container. Instead, you should use the container's standard mechanisms to shut down and undeploy the application. |
I will try to create an example project. But in the meantime: the documentation says, the Then, what would be the correct way of shutting down a Spring war in a tomcat container? |
That's a fair point. We should improve the docs here.
Use the container's standard mechanism for undeploying an application. As part of that, the container will call the |
The root cause is So, if the docs state Sidenote: I'm setting this property explicit due to different profiles. This way, I can disable the actuator completely in dev+test, and enable it in production by just overriding the property mentioned:
|
The default for |
Find example attached. It's a simple as adding the Put your breakpoint into |
Also, if you compile my example project with So, if the |
I had misremembered this, sorry. The default for |
I was wrong here too. Sorry again. The sample has allowed me to see what's happening. When the shutdown endpoint is enabled, it's exposed as a bean. Framework's support for inferring a bean's destroy method and wrapping it in a |
So in my case I'd have to explicit set |
I am deploying Spring Boot application on Tomcat with the war packaging and also getting memory leak error message when I deploy it locally on Tomcat. BTW, I have implemented graceful shutdown in my application by referring to this document here. Application Versions:
I have found another way to implementing it manually by getting the Tomcat's connector object and waiting for grace period to allow all inflight requests to complete before moving to the shutdown phase with the help of @PreDestroy annotation. However, I just wanted to know if there is a better way to do this as this is a trivial problem that many developers would have faced. |
@freeman9397 Graceful shutdown as documented in the section you linked to is for embedded web servers. If you're deploying a war file to Tomcat then shutdown is outside of Spring Boot's control. |
@philwebb Thanks for the quick update. Do you know of a way how to handle graceful shutdown when application is deployed through a war file in the best way other than I mentioned? |
…ot-starter-parent from 2.3.5.RELEASE to 2.7.7 (minor) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [org.springframework.boot:spring-boot-starter-parent](https://spring.io/projects/spring-boot) ([source](https://github.com/spring-projects/spring-boot)) | parent | minor | `2.3.5.RELEASE` -> `2.7.7` | --- ### Release Notes <details> <summary>spring-projects/spring-boot</summary> ### [`v2.7.7`](https://github.com/spring-projects/spring-boot/releases/tag/v2.7.7) [Compare Source](spring-projects/spring-boot@v2.7.6...v2.7.7) #### 🐞 Bug Fixes - Fix typo in LocalDevToolsAutoConfiguration logging [#​33569](spring-projects/spring-boot#33569) - Web server fails to start due to "Resource location must not be null" when attempting to use a PKCS 11 KeyStore [#​32179](spring-projects/spring-boot#32179) #### 📔 Documentation - Improve gradle plugin tags documentation [#​33614](spring-projects/spring-boot#33614) - Improve maven plugin tags documentation [#​33609](spring-projects/spring-boot#33609) - Fix typo in tomcat accesslog checkExists doc [#​33460](spring-projects/spring-boot#33460) - Document that the shutdown endpoint is not intended for use when deploying a war to a servlet container [#​17398](spring-projects/spring-boot#17398) #### 🔨 Dependency Upgrades - Upgrade to Byte Buddy 1.12.20 [#​33570](spring-projects/spring-boot#33570) - Upgrade to Dropwizard Metrics 4.2.14 [#​33571](spring-projects/spring-boot#33571) - Upgrade to Elasticsearch 7.17.8 [#​33572](spring-projects/spring-boot#33572) - Upgrade to HttpClient 4.5.14 [#​33573](spring-projects/spring-boot#33573) - Upgrade to HttpCore 4.4.16 [#​33574](spring-projects/spring-boot#33574) - Upgrade to Infinispan 13.0.14.Final [#​33575](spring-projects/spring-boot#33575) - Upgrade to Jaybird 4.0.8.java8 [#​33576](spring-projects/spring-boot#33576) - Upgrade to Jetty 9.4.50.v20221201 [#​33577](spring-projects/spring-boot#33577) - Upgrade to MSSQL JDBC 10.2.2.jre8 [#​33578](spring-projects/spring-boot#33578) - Upgrade to Neo4j Java Driver 4.4.11 [#​33579](spring-projects/spring-boot#33579) - Upgrade to Netty 4.1.86.Final [#​33580](spring-projects/spring-boot#33580) - Upgrade to Reactor 2020.0.26 [#​33543](spring-projects/spring-boot#33543) - Upgrade to Spring Integration 5.5.16 [#​33581](https://github.com/spring-projects/spring...
When a *.war file is undeployed from Tomcat (eg via the tomcat web frontend), the following memory leak is detected:
Could you fix that?
The text was updated successfully, but these errors were encountered: