kfyty opened a new pull request, #15457:
URL: https://github.com/apache/dubbo/pull/15457
## Destroy default application instance, so that DubboBootstrap#stop() can
thoroughly destroyed
The following code will run normally :
```java
public class Main {
public static void main(String[] args) throws Exception {
// code1
// PojoUtils.isPojo(PojoUtils.class);
DubboBootstrap bootstrap =
DubboBootstrap.newInstance(FrameworkModel.defaultModel())
.protocol(new ProtocolConfig(CommonConstants.DUBBO, 50051))
.service(ServiceBuilder.newBuilder().interfaceClass(DemoService.class).ref(new
DemoServiceImpl()).build())
.start();
// stop it
bootstrap.stop();
// create new instance and restart it
bootstrap = DubboBootstrap.newInstance(FrameworkModel.defaultModel())
.protocol(new ProtocolConfig(CommonConstants.DUBBO, 50051))
.service(ServiceBuilder.newBuilder().interfaceClass(DemoService.class).ref(new
DemoServiceImpl()).build())
.start();
bootstrap.stop();
}
public interface DemoService {
String sayHello(String name);
}
public static class DemoServiceImpl implements DemoService {
@Override
public String sayHello(String name) {
return "Hello " + name + ", response from provider.";
}
}
}
```
But, if cancel comment at line 5, and run the code will get a
IllegalStateException: ExtensionDirector is destroyed.
Because static property of PojoUtils#GENERIC_WITH_CLZ will create instance
of ApplicationModel,and will cause the method of
FrameworkModel#notifyProtocolDestroy never invoked, so DubboBootstrap#stop not
thoroughly destroyed !
This commit fixed this question.
## Checklist
- [x] Make sure there is a
[GitHub_issue](https://github.com/apache/dubbo/issues) 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. If the new
feature or significant change is committed, please remember to add sample in
[dubbo samples](https://github.com/apache/dubbo-samples) project.
- [x] Make sure gitHub actions can pass. [Why the workflow is failing and
how to fix it?](../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]