Skip to content

Conversation

@arunikayadav42
Copy link

What is the purpose of the change?

Fixes #15798.
Problem:
In Spring Boot applications, Dubbo currently destroys the ModuleModel immediately upon receiving the ContextClosedEvent. 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 to implement DisposableBean and moved the destruction logic from onContextClosedEvent to the destroy() 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

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. (Added GracefulShutdownTest.java in this PR)
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

ModuleModel moduleModel = DubboBeanUtils.getModuleModel(context);
Assertions.assertFalse(moduleModel.isDestroyed(), "Module should be running");

System.out.println("Closing context...");
Copy link
Contributor

@zrlw zrlw Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. should use log.info (log4j2.xml) instead of System.out.XXX
  2. code format issue should be fixed by mvn spotless:apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Directory of type RegistryDirectory already destroyed for service

2 participants