fix:fix incorrect empty metadata data handling. #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix #75
实例更新流程
核心逻辑源码:org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener#doOnEvent
ServiceInstancesChangedListener
)。InnerServiceListener
)与之对应。原有逻辑
在上述流程的第5步,获取到service metadata拉取到空值,也会正常更新。例如下方serviceInfos为空map,也正常返回了。

解决方案
可以借助dubbo的metadata异常处理流程来完成service metadata的拉取。也就是serviceInfos为空map时,返回dubbo框架内指定的空值,
MetadataInfo.EMPTY
。dubbo框架在获取远端service metadata时,如果拿到了
MetadataInfo.EMPTY
,则会重试2次,且每次重试间隔1000ms。源码:org.apache.dubbo.registry.client.AbstractServiceDiscovery#getRemoteMetadata(java.lang.String, java.util.List<org.apache.dubbo.registry.client.ServiceInstance>)如果重试后还是为
MetadataInfo.EMPTY
,则会走到实例变更监听器重试逻辑。这个重试逻辑会判断是否有实例存在空的service metadata,则会提交一个重试任务,等待10000ms后,重新触发整个url列表的变更。