<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: xxx</li>
<li>Operating System version: xxx</li>
<li>Java version: xxx</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>run main method of Application of dubbo-demo-xml-consumer.</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">The application will exit without thrown exception</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="java.lang.IllegalStateException: There's no ApplicationConfig specified.
	at org.apache.dubbo.config.context.ConfigManager.lambda$getApplicationOrElseThrow$0(ConfigManager.java:88)
	at java.base/java.util.Optional.orElseThrow(Optional.java:401)
	at org.apache.dubbo.config.context.ConfigManager.getApplicationOrElseThrow(ConfigManager.java:88)
	at org.apache.dubbo.rpc.model.ApplicationModel.getApplicationConfig(ApplicationModel.java:100)
	at org.apache.dubbo.rpc.model.ApplicationModel.getName(ApplicationModel.java:104)
	at org.apache.dubbo.rpc.model.ApplicationModel.getApplication(ApplicationModel.java:112)
	at org.apache.dubbo.registry.integration.RegistryProtocol.destroy(RegistryProtocol.java:500)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.destroy(ProtocolFilterWrapper.java:166)
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.destroy(ProtocolListenerWrapper.java:80)
	at org.apache.dubbo.config.DubboShutdownHook.destroyProtocols(DubboShutdownHook.java:140)
	at org.apache.dubbo.config.DubboShutdownHook.destroyAll(DubboShutdownHook.java:124)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1037)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.stop(DubboBootstrap.java:817)
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextClosedEvent(DubboBootstrapApplicationListener.java:63)
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:54)
	at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991)
	at org.springframework.context.support.AbstractApplicationContext$2.run(AbstractApplicationContext.java:929)"><pre lang="log" class="notranslate"><code class="notranslate">java.lang.IllegalStateException: There's no ApplicationConfig specified.
	at org.apache.dubbo.config.context.ConfigManager.lambda$getApplicationOrElseThrow$0(ConfigManager.java:88)
	at java.base/java.util.Optional.orElseThrow(Optional.java:401)
	at org.apache.dubbo.config.context.ConfigManager.getApplicationOrElseThrow(ConfigManager.java:88)
	at org.apache.dubbo.rpc.model.ApplicationModel.getApplicationConfig(ApplicationModel.java:100)
	at org.apache.dubbo.rpc.model.ApplicationModel.getName(ApplicationModel.java:104)
	at org.apache.dubbo.rpc.model.ApplicationModel.getApplication(ApplicationModel.java:112)
	at org.apache.dubbo.registry.integration.RegistryProtocol.destroy(RegistryProtocol.java:500)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.destroy(ProtocolFilterWrapper.java:166)
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.destroy(ProtocolListenerWrapper.java:80)
	at org.apache.dubbo.config.DubboShutdownHook.destroyProtocols(DubboShutdownHook.java:140)
	at org.apache.dubbo.config.DubboShutdownHook.destroyAll(DubboShutdownHook.java:124)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:1037)
	at org.apache.dubbo.config.bootstrap.DubboBootstrap.stop(DubboBootstrap.java:817)
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextClosedEvent(DubboBootstrapApplicationListener.java:63)
	at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:54)
	at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991)
	at org.springframework.context.support.AbstractApplicationContext$2.run(AbstractApplicationContext.java:929)
</code></pre></div>
<p dir="auto">It's because the destroy method of DubboBootstrap is invoked twice when the application is closing.<br>
(1.When the DubboBootstrapApplicationListener accept the ContextClosedEvent, running once.)<br>
(2.The ShutdownHookCallback register when new the DubboBootstrap, running another time.)</p>