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 5e8f554 [3.0] Fallback use class's cl to adapt ut (#9483)
5e8f554 is described below
commit 5e8f5544df23289c12c8ecea3d2accef3f2fd99a
Author: Albumen Kevin <[email protected]>
AuthorDate: Fri Dec 24 14:50:38 2021 +0800
[3.0] Fallback use class's cl to adapt ut (#9483)
---
.../java/org/apache/dubbo/rpc/filter/ClassLoaderFilter.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ClassLoaderFilter.java
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ClassLoaderFilter.java
index c8e51fd..99bae40 100644
---
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ClassLoaderFilter.java
+++
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ClassLoaderFilter.java
@@ -33,7 +33,15 @@ public class ClassLoaderFilter implements Filter {
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
ClassLoader ocl = Thread.currentThread().getContextClassLoader();
-
Thread.currentThread().setContextClassLoader(invocation.getServiceModel().getClassLoader());
+ ClassLoader newClassLoader;
+ if (invocation.getServiceModel() != null) {
+ newClassLoader = invocation.getServiceModel().getClassLoader();
+ } else {
+ newClassLoader = invoker.getClass().getClassLoader();
+ }
+ if (newClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(newClassLoader);
+ }
try {
return invoker.invoke(invocation);
} finally {