Skip to content

修复dubbo使用服务分组和分组聚合获取不到url #1992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2021

Conversation

DHBin
Copy link
Contributor

@DHBin DHBin commented Mar 11, 2021

修复问题:

  1. 使用服务分组,当group是多个的情况下(例如group="provider1,provider2"),获取不到服务提供者
  2. 使用分组聚合,当group是多个的时候下(group="provider1,provider2")或者为*group="*")的情况下,获取不到服务提供者

修改com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository#getExportedURLs判断group为多个或者*的情况

	public List<URL> getExportedURLs(String serviceInterface, String group,
			String version) {
		if (group != null) {
			List<URL> urls = new LinkedList<>();
			if (CommonConstants.ANY_VALUE.equals(group)) {
				String serviceKey = URL.buildKey(serviceInterface, group, version);
				String expectKey = serviceKey.substring(2);
				for (String key : allExportedURLs.keySet()) {
					if (key.endsWith(expectKey)) {
						urls.addAll(allExportedURLs.get(key));
					}
				}
			}
			else {
				String[] groups = group.split(CommonConstants.COMMA_SEPARATOR);
				for (String expectKey : groups) {
					String serviceKey = URL.buildKey(serviceInterface, expectKey,
							version);
					List<URL> urlList = allExportedURLs.get(serviceKey);
					if (urlList != null) {
						urls.addAll(urlList);
					}
				}
			}
			return urls;
		}
		else {
			String serviceKey = URL.buildKey(serviceInterface, null, version);
			return allExportedURLs.getOrDefault(serviceKey, Collections.emptyList());
		}
	}

@theonefx
Copy link
Collaborator

LGTM

@theonefx theonefx merged commit 55b3336 into alibaba:master May 17, 2021
@theonefx theonefx added this to the 2.2.6.RELEASE milestone Jul 5, 2021
theonefx added a commit to theonefx/spring-cloud-alibaba that referenced this pull request Aug 2, 2021
修复dubbo使用服务分组和分组聚合获取不到url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants