<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->

- [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 3.1.3,3.1.5-snapshot
* Operating System version: mac os 12
* Java version: 1.8

### Steps to reproduce this issue

1. When a timer calls the dubbo service at startup

Pls. provide [GitHub address] to reproduce this issue.

### Expected Behavior

<!-- What do you expect from the above steps？-->

### Actual Behavior

<!-- What actually happens? -->

If there is an exception, please attach the exception trace:

```
Found one Java-level deadlock:
=============================
"Timer-1":
  waiting to lock monitor 0x000000015b48b420 (object 0x00000005c0742138, a java.util.concurrent.ConcurrentHashMap),
  which is held by "main"
"main":
  waiting to lock monitor 0x000000013a5413a0 (object 0x00000005c100c958, a org.apache.dubbo.config.deploy.DefaultModuleDeployer),
  which is held by "Timer-1"

Java stack information for the threads listed above:
===================================================
"Timer-1":
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216)
	- waiting to lock <0x00000005c0742138> (a java.util.concurrent.ConcurrentHashMap)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160)
	at org.apache.dubbo.config.spring.extension.SpringExtensionInjector.getOptionalBean(SpringExtensionInjector.java:78)
	at org.apache.dubbo.config.spring.extension.SpringExtensionInjector.getInstance(SpringExtensionInjector.java:64)
	at org.apache.dubbo.common.extension.inject.AdaptiveExtensionInjector.lambda$getInstance$0(AdaptiveExtensionInjector.java:58)
	at org.apache.dubbo.common.extension.inject.AdaptiveExtensionInjector$$Lambda$450/1638051511.apply(Unknown Source)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361)
	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531)
	at org.apache.dubbo.common.extension.inject.AdaptiveExtensionInjector.getInstance(AdaptiveExtensionInjector.java:60)
	at org.apache.dubbo.common.extension.ExtensionLoader.injectExtension(ExtensionLoader.java:876)
	at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:775)
	at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:561)
	- locked <0x000000071aa3b240> (a org.apache.dubbo.common.utils.Holder)
	at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:535)
	at org.apache.dubbo.common.extension.ExtensionLoader.getActivateExtension(ExtensionLoader.java:420)
	at org.apache.dubbo.common.extension.ExtensionLoader.getActivateExtension(ExtensionLoader.java:320)
	at org.apache.dubbo.rpc.cluster.filter.DefaultFilterChainBuilder.buildInvokerChain(DefaultFilterChainBuilder.java:50)
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:74)
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52)
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.toInvokers(ServiceDiscoveryRegistryDirectory.java:352)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshInvoker(ServiceDiscoveryRegistryDirectory.java:254)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshOverrideAndInvoker(ServiceDiscoveryRegistryDirectory.java:182)
	- locked <0x0000000718a10cb0> (a org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.notify(ServiceDiscoveryRegistryDirectory.java:176)
	- locked <0x0000000718a10cb0> (a org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory)
	at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.addListenerAndNotify(ServiceInstancesChangedListener.java:237)
	- locked <0x000000071901a7e0> (a org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:326)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:217)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:185)
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:88)
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:183)
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:127)
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:569)
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65)
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:437)
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:245)
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:76)
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:60)
	- locked <0x00000007189af330> (a org.apache.dubbo.registry.client.migration.MigrationRuleHandler)
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:247)
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:534)
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:504)
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:486)
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74)
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:81)
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71)
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52)
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:614)
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:448)
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
	- locked <0x00000005c2313808> (a org.apache.dubbo.config.ReferenceConfig)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:232)
	- locked <0x00000005c2313808> (a org.apache.dubbo.config.ReferenceConfig)
	at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:131)
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:396)
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer$$Lambda$1160/1414372344.accept(Unknown Source)
	at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707)
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:376)
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:167)
	- locked <0x00000005c100c958> (a org.apache.dubbo.config.deploy.DefaultModuleDeployer)
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:139)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:228)
	at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:346)
	at org.apache.dubbo.config.spring.ReferenceBean.access$100(ReferenceBean.java:99)
	at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.createObject(ReferenceBean.java:353)
	at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:88)
	- locked <0x00000005c2313660> (a org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:195)
	at com.sun.proxy.$Proxy193.allOrganization(Unknown Source)
	at com.***.OrganizationCache.lambda$new$0(OrganizationCache.java:44)
	at com.***.OrganizationCache$$Lambda$1157/1612491156.get(Unknown Source)
	at com.***.CacheByOne.refresh(CacheByOne.java:75)
	at com.***.CacheByOne$$Lambda$1158/1114712230.apply(Unknown Source)
	at com.***.AbstractCache$1.run(AbstractCache.java:61)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
"main":
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:143)
	- waiting to lock <0x00000005c100c958> (a org.apache.dubbo.config.deploy.DefaultModuleDeployer)
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:139)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:228)
	at com.***.ElementApiAutoConfiguration.elementApiDubboReference(ElementApiAutoConfiguration.java:25)
	at com.***.ElementApiAutoConfiguration$$EnhancerBySpringCGLIB$$eed7a286.CGLIB$elementApiDubboReference$1(<generated>)
	at com.***.ElementApiAutoConfiguration$$EnhancerBySpringCGLIB$$eed7a286$$FastClassBySpringCGLIB$$b1a4f79b.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
	at com.***.ElementApiAutoConfiguration$$EnhancerBySpringCGLIB$$eed7a286.elementApiDubboReference(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$240/1599674462.getObject(Unknown Source)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	- locked <0x00000005c0742138> (a java.util.concurrent.ConcurrentHashMap)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	- locked <0x00000005c0741e30> (a java.lang.Object)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:771)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:763)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1318)
	at com.***.Application.main(Application.java:22)

Found 1 deadlock.
```

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
 * <p>
 * Spring FactoryBean for {@link ReferenceConfig}.
 * </p>
 *
 *
 * <p></p>
 * Step 1: Register ReferenceBean in Java-config class:
 * <pre class="code">
 * &#64;Configuration
 * public class ReferenceConfiguration {
 *     &#64;Bean
 *     &#64;DubboReference(group = "demo")
 *     public ReferenceBean&lt;HelloService&gt; helloService() {
 *         return new ReferenceBean();
 *     }
 *
 *     // As GenericService
 *     &#64;Bean