Skip to content

Commit

Permalink
Fix dubbo.tag override by consumer.tag in NacosRegistry (#13592)
Browse files Browse the repository at this point in the history
  • Loading branch information
namelessssssssssss committed Jan 2, 2024
1 parent 180ff97 commit fed4755
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.common.utils.UrlUtils;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.ProviderFirstParams;
import org.apache.dubbo.rpc.model.ScopeModel;

import java.util.ArrayList;
Expand All @@ -41,7 +40,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -319,20 +317,6 @@ protected ServiceAddressURL createServiceURL(URLAddress address, URLParam param,
return new DubboServiceAddressURL(address, param, consumerURL, null);
}

protected URL removeParamsFromConsumer(URL consumer) {
Set<ProviderFirstParams> providerFirstParams = consumer.getOrDefaultApplicationModel()
.getExtensionLoader(ProviderFirstParams.class)
.getSupportedExtensionInstances();
if (CollectionUtils.isEmpty(providerFirstParams)) {
return consumer;
}

for (ProviderFirstParams paramsFilter : providerFirstParams) {
consumer = consumer.removeParameters(paramsFilter.params());
}
return consumer;
}

private String stripOffVariableKeys(String rawProvider) {
String[] keys = getVariableKeys();
if (keys == null || keys.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.ProviderFirstParams;
import org.apache.dubbo.registry.retry.FailedRegisteredTask;
import org.apache.dubbo.registry.retry.FailedSubscribedTask;
import org.apache.dubbo.registry.retry.FailedUnregisteredTask;
Expand Down Expand Up @@ -177,6 +178,20 @@ private void removeFailedUnsubscribed(URL url, NotifyListener listener) {
}
}

protected URL removeParamsFromConsumer(URL consumer) {
Set<ProviderFirstParams> providerFirstParams = consumer.getOrDefaultApplicationModel()
.getExtensionLoader(ProviderFirstParams.class)
.getSupportedExtensionInstances();
if (CollectionUtils.isEmpty(providerFirstParams)) {
return consumer;
}

for (ProviderFirstParams paramsFilter : providerFirstParams) {
consumer = consumer.removeParameters(paramsFilter.params());
}
return consumer;
}

ConcurrentMap<URL, FailedRegisteredTask> getFailedRegistered() {
return failedRegistered;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ public void destroy() {
}

private List<URL> toUrlWithEmpty(URL consumerURL, Collection<Instance> instances) {
consumerURL = removeParamsFromConsumer(consumerURL);
List<URL> urls = buildURLs(consumerURL, instances);
// Nacos does not support configurators and routers from registry, so all notifications are of providers type.
if (urls.size() == 0 && !getUrl().getParameter(ENABLE_EMPTY_PROTECTION_KEY, DEFAULT_ENABLE_EMPTY_PROTECTION)) {
Expand Down

0 comments on commit fed4755

Please sign in to comment.