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

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

commit f474ce4bdff8d874a38aa8761a3f0acbbe94e858
Author: gongdewei <[email protected]>
AuthorDate: Mon Aug 30 14:27:32 2021 +0800

    polish scope model
---
 .../rpc/model/ScopeModelAwareExtensionProcessor.java   |  2 +-
 .../org/apache/dubbo/rpc/model/ScopeModelUtil.java     | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelAwareExtensionProcessor.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelAwareExtensionProcessor.java
index 7ae6e5f..49e3012 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelAwareExtensionProcessor.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelAwareExtensionProcessor.java
@@ -34,7 +34,7 @@ public class ScopeModelAwareExtensionProcessor implements 
ExtensionPostProcessor
             return;
         }
 
-        // NOTE: Do not use ScopeModelUtil.getXxxModel() here, because cannot 
create a new model or use the default application/module model here.
+        // NOTE: Do not create a new model or use the default 
application/module model here!
         // Only the visible and only matching scope model can be injected, 
that is, module -> application -> framework.
         // The converse is a one-to-many relationship and cannot be injected.
         // One framework may have multiple applications, and one application 
may have multiple modules.
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelUtil.java 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelUtil.java
index e686ef1..7db702e 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelUtil.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelUtil.java
@@ -22,29 +22,32 @@ import org.apache.dubbo.common.extension.SPI;
 public class ScopeModelUtil {
 
     public static ModuleModel getModuleModel(ScopeModel scopeModel) {
-        if (scopeModel instanceof ModuleModel) {
-            return (ModuleModel) scopeModel;
-        }
         if (scopeModel == null) {
             return ApplicationModel.defaultModel().getDefaultModule();
         }
+        if (scopeModel instanceof ModuleModel) {
+            return (ModuleModel) scopeModel;
+        }
         return null;
     }
 
     public static ApplicationModel getApplicationModel(ScopeModel scopeModel) {
+        if (scopeModel == null) {
+            return ApplicationModel.defaultModel();
+        }
         if (scopeModel instanceof ApplicationModel) {
             return (ApplicationModel) scopeModel;
         } else if (scopeModel instanceof ModuleModel) {
             ModuleModel moduleModel = (ModuleModel) scopeModel;
             return moduleModel.getApplicationModel();
         }
-        if (scopeModel == null) {
-            return ApplicationModel.defaultModel();
-        }
         return null;
     }
 
     public static FrameworkModel getFrameworkModel(ScopeModel scopeModel) {
+        if (scopeModel == null) {
+            return FrameworkModel.defaultModel();
+        }
         if (scopeModel instanceof ApplicationModel) {
             return ((ApplicationModel) scopeModel).getFrameworkModel();
         } else if (scopeModel instanceof ModuleModel) {
@@ -53,9 +56,6 @@ public class ScopeModelUtil {
         } else if (scopeModel instanceof FrameworkModel) {
             return (FrameworkModel) scopeModel;
         }
-        if (scopeModel == null) {
-            return FrameworkModel.defaultModel();
-        }
         return null;
     }
 

Reply via email to