From 123f2ee60f9425fc3d865de25d3c01b762682a01 Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Mon, 19 Jun 2023 18:53:43 +0800 Subject: [PATCH] Add transient to some overrided field --- .../apache/dubbo/config/AbstractReferenceConfig.java | 3 +++ .../java/org/apache/dubbo/config/ModuleConfig.java | 3 +++ .../org/apache/dubbo/config/ReferenceConfigBase.java | 1 + .../org/apache/dubbo/config/ServiceConfigBase.java | 1 + .../main/java/com/alibaba/dubbo/rpc/Invocation.java | 6 ++++-- .../java/com/alibaba/dubbo/rpc/RpcInvocation.java | 8 +++++--- .../dubbo/registry/client/ServiceInstance.java | 1 + .../main/java/org/apache/dubbo/rpc/Invocation.java | 12 +++++++----- 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java index e659b10b6f7..058f1d1622f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java @@ -21,6 +21,8 @@ import org.apache.dubbo.rpc.model.ModuleModel; import org.apache.dubbo.rpc.support.ProtocolUtils; +import java.beans.Transient; + import static org.apache.dubbo.common.constants.CommonConstants.INVOKER_LISTENER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.REFER_ASYNC_KEY; @@ -184,6 +186,7 @@ public void setGeneric(String generic) { } @Override + @Transient protected boolean isNeedCheckMethod() { return StringUtils.isEmpty(getGeneric()); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java index 511c6bbfb79..ef6eaf870da 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java @@ -22,6 +22,7 @@ import org.apache.dubbo.rpc.model.ModuleModel; import org.apache.dubbo.rpc.model.ScopeModel; +import java.beans.Transient; import java.util.ArrayList; import java.util.List; @@ -135,11 +136,13 @@ protected void checkScopeModel(ScopeModel scopeModel) { } @Override + @Transient public ModuleModel getScopeModel() { return (ModuleModel) super.getScopeModel(); } @Override + @Transient protected ScopeModel getDefaultModel() { return ApplicationModel.defaultModel().getDefaultModule(); } 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 bfeacacba5b..4b41ea2786d 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 @@ -150,6 +150,7 @@ public List getPrefixes() { } @Override + @Transient public Map getMetaData() { return getMetaData(null); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java index 0db03d0208d..265779ed3f7 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java @@ -180,6 +180,7 @@ protected void preProcessRefresh() { } @Override + @Transient public Map getMetaData() { return getMetaData(null); } diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java index 2eda40f4958..85e5cfcfe52 100644 --- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java +++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java @@ -17,14 +17,15 @@ package com.alibaba.dubbo.rpc; +import org.apache.dubbo.rpc.model.ServiceModel; + +import java.beans.Transient; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; -import org.apache.dubbo.rpc.model.ServiceModel; - @Deprecated public interface Invocation extends org.apache.dubbo.rpc.Invocation { @@ -184,6 +185,7 @@ public String getAttachment(String key, String defaultValue) { } @Override + @Transient public Invoker getInvoker() { return new Invoker.CompatibleInvoker(delegate.getInvoker()); } diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java index 90352949274..d1cf40600d3 100644 --- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java +++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java @@ -17,6 +17,10 @@ package com.alibaba.dubbo.rpc; +import com.alibaba.dubbo.common.Constants; +import com.alibaba.dubbo.common.URL; + +import java.beans.Transient; import java.io.Serializable; import java.lang.reflect.Method; import java.util.Arrays; @@ -24,9 +28,6 @@ import java.util.List; import java.util.Map; -import com.alibaba.dubbo.common.Constants; -import com.alibaba.dubbo.common.URL; - public class RpcInvocation implements Invocation, Serializable { private static final long serialVersionUID = -4355285085441097045L; @@ -101,6 +102,7 @@ public RpcInvocation(String methodName, Class[] parameterTypes, Object[] argu this.invoker = invoker; } + @Transient public Invoker getInvoker() { return invoker; } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java index f1546815f81..9f9aaaa8600 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java @@ -103,6 +103,7 @@ default boolean isHealthy() { void setApplicationModel(ApplicationModel applicationModel); + @Transient ApplicationModel getApplicationModel(); @Transient diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java index 1cb4177a905..b40fa05e8a8 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java @@ -16,16 +16,17 @@ */ package org.apache.dubbo.rpc; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.stream.Stream; - import org.apache.dubbo.common.Experimental; import org.apache.dubbo.rpc.model.ModuleModel; import org.apache.dubbo.rpc.model.ScopeModelUtil; import org.apache.dubbo.rpc.model.ServiceModel; +import java.beans.Transient; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Stream; + /** * Invocation. (API, Prototype, NonThreadSafe) * @@ -148,6 +149,7 @@ default Object getObjectAttachmentWithoutConvert(String key) { * @return invoker. * @transient */ + @Transient Invoker getInvoker(); void setServiceModel(ServiceModel serviceModel);