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 bdf30e63f12542abf908231865977cf1c3f61c81
Author: Albumen Kevin <[email protected]>
AuthorDate: Tue Aug 31 20:09:14 2021 +0800

    add failback logic for ut
---
 .../apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
index 7c5ce8c..0f0aecf 100644
--- 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
+++ 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
@@ -34,6 +34,7 @@ import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Protocol;
 import org.apache.dubbo.rpc.ProxyFactory;
 import org.apache.dubbo.rpc.RpcInvocation;
+import org.apache.dubbo.rpc.model.ApplicationModel;
 import org.apache.dubbo.rpc.model.ModuleModel;
 import org.apache.dubbo.rpc.model.ProviderModel;
 import org.apache.dubbo.rpc.model.ScopeModelUtil;
@@ -134,7 +135,14 @@ class CallbackServiceCodec {
             // one channel can have multiple callback instances, no need to 
re-export for different instance.
             if (!channel.hasAttribute(cacheKey)) {
                 if (!isInstancesOverLimit(channel, url, clazz.getName(), 
instid, false)) {
-                    ModuleModel moduleModel = 
ScopeModelUtil.getModuleModel(inv.getServiceModel().getModuleModel());
+                    ModuleModel moduleModel;
+                    if (inv.getServiceModel() == null) {
+                        moduleModel = 
ApplicationModel.defaultModel().getDefaultModule();
+                        logger.error("Unable to get Service Model from 
Invocation. Please check if your invocation failed! " +
+                            "This error only happen in UT cases! Invocation:" 
+ inv);
+                    } else {
+                        moduleModel = inv.getServiceModel().getModuleModel();
+                    }
                     ServiceDescriptor serviceDescriptor = 
ScopeModelUtil.getApplicationModel(moduleModel).getApplicationServiceRepository().registerService(clazz);
                     ProviderModel providerModel = new 
ProviderModel(BaseServiceMetadata.buildServiceKey(exportUrl.getPath(), group, 
exportUrl.getVersion()),
                         inst,

Reply via email to