This is an automated email from the ASF dual-hosted git repository.
liujun 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 0a8747a enhance customized classloader path
0a8747a is described below
commit 0a8747a678fcff10582644f21afd6441a8bcfda1
Author: ken.lj <[email protected]>
AuthorDate: Sat Feb 20 14:42:12 2021 +0800
enhance customized classloader path
---
.../common/bytecode/CustomizedLoaderClassPath.java | 38 +++++++++++++++++-----
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/CustomizedLoaderClassPath.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/CustomizedLoaderClassPath.java
index b1ef491..4afc886 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/CustomizedLoaderClassPath.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/CustomizedLoaderClassPath.java
@@ -66,11 +66,22 @@ public class CustomizedLoaderClassPath implements ClassPath
{
if (cl == null) {
return null; // not found
} else {
- InputStream result = cl.getResourceAsStream(cname);
- if (result == null && (cl != this.getClass().getClassLoader())) {
- return
this.getClass().getClassLoader().getResourceAsStream(cname);
+ InputStream result;
+
+ if (classname.startsWith("org.apache.dubbo") && cl !=
this.getClass().getClassLoader()) {
+ result =
this.getClass().getClassLoader().getResourceAsStream(cname);
+ if (result != null) {
+ return result;
+ } else {
+ return cl.getResourceAsStream(cname);
+ }
+ } else {
+ result = cl.getResourceAsStream(cname);
+ if (result == null && (cl !=
this.getClass().getClassLoader())) {
+ return
this.getClass().getClassLoader().getResourceAsStream(cname);
+ }
+ return result;
}
- return result;
}
}
@@ -87,11 +98,22 @@ public class CustomizedLoaderClassPath implements ClassPath
{
if (cl == null) {
return null; // not found
} else {
- URL url = cl.getResource(cname);
- if (url == null && (cl != this.getClass().getClassLoader())) {
- return this.getClass().getClassLoader().getResource(cname);
+ URL url;
+
+ if (classname.startsWith("org.apache.dubbo") && cl !=
this.getClass().getClassLoader()) {
+ url = this.getClass().getClassLoader().getResource(cname);
+ if (url != null) {
+ return url;
+ } else {
+ return cl.getResource(cname);
+ }
+ } else {
+ url = cl.getResource(cname);
+ if (url == null && (cl != this.getClass().getClassLoader())) {
+ return this.getClass().getClassLoader().getResource(cname);
+ }
+ return url;
}
- return url;
}
}