spring-cloud / spring-cloud/spring-cloud-zookeeper

Compatibility with dubbo registry zookeeper

Open
#316 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Java
Stars
574
Forks
408
Avg merge
1d 12h
Merged PRs (30d)
4

Description

Describe the bug
Please provide details of the problem, including the version of Spring Cloud that you
are using.

java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast org.springframework.cloud.zookeeper.discovery.ZookeeperInstance to org.apache.dubbo.registry.zookeeper.ZookeeperInstance
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:54) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:69) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.doInServiceDiscovery(ZookeeperServiceDiscovery.java:188) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.getInstances(ZookeeperServiceDiscovery.java:147) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:319) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:225) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:187) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:88) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:184) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:134) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:581) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:440) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:246) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:76) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:60) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:249) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:546) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:516) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:498) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:85) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:80) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.ProtocolSecurityWrapper.refer(ProtocolSecurityWrapper.java:107) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.protocol.InvokerCountWrapper.refer(InvokerCountWrapper.java:48) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.createInvoker(ReferenceConfig.java:586) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:432) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:295) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:231) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.destroyReference(SimpleReferenceCache.java:265) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.destroy(SimpleReferenceCache.java:218) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.utils.SimpleReferenceCache.destroy(SimpleReferenceCache.java:242) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:414) ~[dubbo-3.2.0.jar:3.2.0]
	at java.base/java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4783) ~[na:na]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:389) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:170) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:142) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:113) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:102) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:47) ~[dubbo-3.2.0.jar:3.2.0]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:937) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:587) ~[spring-context-6.0.8.jar:6.0.8]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[spring-boot-3.0.6.jar:3.0.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[spring-boot-3.0.6.jar:3.0.6]
	at com.michael.dubbo.ConsumerApplication.main(ConsumerApplication.java:19) ~[classes/:na]
Caused by: java.lang.ClassCastException: Cannot cast org.springframework.cloud.zookeeper.discovery.ZookeeperInstance to org.apache.dubbo.registry.zookeeper.ZookeeperInstance
	at java.base/java.lang.Class.cast(Class.java:3991) ~[na:na]
	at org.apache.curator.x.discovery.details.JsonInstanceSerializer.deserialize(JsonInstanceSerializer.java:87) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForInstance(ServiceDiscoveryImpl.java:325) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForInstances(ServiceDiscoveryImpl.java:393) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.curator.x.discovery.details.ServiceDiscoveryImpl.queryForInstances(ServiceDiscoveryImpl.java:307) ~[curator-x-discovery-5.1.0.jar:na]
	at org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.lambda$getInstances$2(ZookeeperServiceDiscovery.java:147) ~[dubbo-3.2.0.jar:3.2.0]
	at org.apache.dubbo.common.function.ThrowableFunction.execute(ThrowableFunction.java:52) ~[dubbo-3.2.0.jar:3.2.0]
	... 55 common frames omitted

Sample

When using dubbo to interact with spring, the registry type conversion is abnormal. Is spring cloud compatible with dubbo's application-level instance registry?

Dubbo Issue As follow

https://github.com/apache/dubbo/issues/12243

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ZookeeperServiceDiscovery.java stack-trace entry points and Curator's JsonInstanceSerializer and ServiceDiscoveryImpl calls. Reproduce the interaction between Spring Cloud Zookeeper and Dubbo's application-level registry, then verify that the reported ClassCastException is resolved with coverage for this integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.