arunikayadav42 opened a new pull request, #15973: URL: https://github.com/apache/dubbo/pull/15973
## What is the purpose of the change? Fixes #15798. **Problem:** In Spring Boot applications, Dubbo currently destroys the [ModuleModel](cci:1://file:///Users/mayankwadhwani/Arunika/github_projects/dubbo/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/DubboBeanUtils.java:220:4-226:5) immediately upon receiving the [ContextClosedEvent](cci:1://file:///Users/mayankwadhwani/Arunika/github_projects/dubbo/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboBootstrapApplicationListener.java:124:4-130:5). This causes a race condition where other beans (e.g., scheduled tasks or other `DisposableBean` implementations) that are still destroying themselves may try to call Dubbo services, resulting in `RpcException: Directory of type RegistryDirectory already destroyed for service`. **Solution:** Refactored [DubboDeployApplicationListener](cci:2://file:///Users/mayankwadhwani/Arunika/github_projects/dubbo/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java:52:0-221:1) to implement `DisposableBean` and moved the destruction logic from [onContextClosedEvent](cci:1://file:///Users/mayankwadhwani/Arunika/github_projects/dubbo/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboBootstrapApplicationListener.java:124:4-130:5) to the [destroy()](cci:1://file:///Users/mayankwadhwani/Arunika/github_projects/dubbo/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/GracefulShutdownTest.java:58:8-70:9) method. This defers Dubbo's shutdown until the bean destruction phase, ensuring that other beans have time to complete their cleanup while Dubbo services are still available, effectively supporting a graceful shutdown. ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues/15798) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. (Added [GracefulShutdownTest.java](cci:7://file:///Users/mayankwadhwani/Arunika/github_projects/dubbo/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/GracefulShutdownTest.java:0:0-0:0) in this PR) - [ ] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](https://github.com/apache/dubbo/blob/3.3/CONTRIBUTING.md) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
