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 2021/09/02 03:45:25 UTC

[dubbo] branch 3.0-multi-instances updated (de44579 -> ccdc691)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a change to branch 3.0-multi-instances
in repository https://gitbox.apache.org/repos/asf/dubbo.git.


    from de44579  Fix uts
     new d319adb  Fix ut in DubboBootstrapTest
     new ccdc691  Fix ut in DubboBootstrapTest

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../dubbo/config/bootstrap/DubboBootstrapTest.java     |  2 +-
 .../apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

[dubbo] 01/02: Fix ut in DubboBootstrapTest

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0-multi-instances
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit d319adb7236e7dadd33f09009cbe96df4da8e61c
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Thu Sep 2 11:44:36 2021 +0800

    Fix ut in DubboBootstrapTest
---
 .../dubbo/config/bootstrap/DubboBootstrapTest.java     |  2 +-
 .../apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
index 68c92f3..9c669c1 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
@@ -331,7 +331,7 @@ public class DubboBootstrapTest {
 
     private void assertMetadataService(DubboBootstrap bootstrap, int availablePort, boolean shouldReport) {
         Assertions.assertTrue(bootstrap.metadataServiceExporter.isExported());
-        DubboProtocol protocol = DubboProtocol.getDubboProtocol();
+        DubboProtocol protocol = DubboProtocol.getDubboProtocol(bootstrap.getApplicationModel());
         Map<String, Exporter<?>> exporters = protocol.getExporterMap();
         Assertions.assertEquals(2, exporters.size());
 
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
index 68792be..375c266 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
@@ -46,8 +46,10 @@ import org.apache.dubbo.rpc.Result;
 import org.apache.dubbo.rpc.RpcContext;
 import org.apache.dubbo.rpc.RpcException;
 import org.apache.dubbo.rpc.RpcInvocation;
+import org.apache.dubbo.rpc.model.ScopeModel;
 import org.apache.dubbo.rpc.protocol.AbstractProtocol;
 
+import java.lang.reflect.Field;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -222,6 +224,22 @@ public class DubboProtocol extends AbstractProtocol {
         return INSTANCE;
     }
 
+
+    public static DubboProtocol getDubboProtocol(ScopeModel scopeModel) {
+        Protocol protocolWrapper = scopeModel.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME);
+
+        try {
+            while (protocolWrapper instanceof DubboProtocol) {
+                Field protocolField = protocolWrapper.getClass().getDeclaredField("protocol");
+                protocolField.setAccessible(true);
+                protocolWrapper = (Protocol) protocolField.get(protocolWrapper);
+            }
+        } catch (NoSuchFieldException | IllegalAccessException ignore) {
+        }
+
+        return (DubboProtocol) protocolWrapper;
+    }
+
     @Override
     public Collection<Exporter<?>> getExporters() {
         return Collections.unmodifiableCollection(exporterMap.values());

[dubbo] 02/02: Fix ut in DubboBootstrapTest

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0-multi-instances
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit ccdc6915609383a6c8e99e11f1bda4cee4cf6b94
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Thu Sep 2 11:45:01 2021 +0800

    Fix ut in DubboBootstrapTest
---
 .../main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
index 375c266..47a41cc 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
@@ -229,7 +229,7 @@ public class DubboProtocol extends AbstractProtocol {
         Protocol protocolWrapper = scopeModel.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME);
 
         try {
-            while (protocolWrapper instanceof DubboProtocol) {
+            while (!(protocolWrapper instanceof DubboProtocol)) {
                 Field protocolField = protocolWrapper.getClass().getDeclaredField("protocol");
                 protocolField.setAccessible(true);
                 protocolWrapper = (Protocol) protocolField.get(protocolWrapper);