You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/02/25 08:52:04 UTC
[dubbo] branch 3.0 updated: Fixe the issue that the default protocol configured by the consumer does not take effect in the application-level mode (#9683)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new eed418a Fixe the issue that the default protocol configured by the consumer does not take effect in the application-level mode (#9683)
eed418a is described below
commit eed418a96d2b822e793ae428684f9f0a3d069e45
Author: 灼华 <43...@users.noreply.github.com>
AuthorDate: Fri Feb 25 16:51:50 2022 +0800
Fixe the issue that the default protocol configured by the consumer does not take effect in the application-level mode (#9683)
---
.../main/java/org/apache/dubbo/config/ReferenceConfigBase.java | 10 ++++++++++
.../src/main/java/org/apache/dubbo/config/ReferenceConfig.java | 2 ++
2 files changed, 12 insertions(+)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java
index f60f5d0..fe90258 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.config;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.ClassUtils;
+import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.RegexProperties;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.annotation.Reference;
@@ -159,6 +160,15 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
return metaData;
}
+ protected void checkProtocol() {
+ if (StringUtils.isEmpty(protocol)) {
+ List<ProtocolConfig> defaultProtocols = getConfigManager().getDefaultProtocols();
+ if (CollectionUtils.isNotEmpty(defaultProtocols)) {
+ protocol = defaultProtocols.iterator().next().getName();
+ }
+ }
+ }
+
/**
* Get service interface class of this reference.
* The actual service type of remote provider.
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
index 539e6d6..c73b1de 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
@@ -557,6 +557,8 @@ public class ReferenceConfig<T> extends ReferenceConfigBase<T> {
// get consumer's global configuration
completeCompoundConfigs();
+ checkProtocol();
+
// init some null configuration.
List<ConfigInitializer> configInitializers = this.getExtensionLoader(ConfigInitializer.class)
.getActivateExtension(URL.valueOf("configInitializer://"), (String[]) null);