You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ki...@apache.org on 2021/04/27 14:55:09 UTC
[dubbo] branch master updated: [Dubbo-2.7.10] Fix
`setSkyWalkingDynamicField(java.lang.Object) not found` (#7517)
This is an automated email from the ASF dual-hosted git repository.
kimmking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 68062c1 [Dubbo-2.7.10] Fix `setSkyWalkingDynamicField(java.lang.Object) not found` (#7517)
68062c1 is described below
commit 68062c1d0ac4160cdc00dc28369f4440ffbde20e
Author: zifeihan <zi...@apache.org>
AuthorDate: Tue Apr 27 22:54:24 2021 +0800
[Dubbo-2.7.10] Fix `setSkyWalkingDynamicField(java.lang.Object) not found` (#7517)
* Fix `setSkyWalkingDynamicField(java.lang.Object) not found`
* Polishing.
* Polishing.
* Polishing.
---
.../org/apache/dubbo/common/bytecode/Wrapper.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java b/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java
index e8fb687..fb8e19f 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java
@@ -16,6 +16,10 @@
*/
package org.apache.dubbo.common.bytecode;
+import java.util.Arrays;
+import java.util.stream.Collectors;
+import javassist.ClassPool;
+import javassist.CtMethod;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.ReflectUtils;
@@ -150,7 +154,23 @@ public abstract class Wrapper {
pts.put(fn, ft);
}
- Method[] methods = c.getMethods();
+ final ClassPool classPool = new ClassPool(ClassPool.getDefault());
+ classPool.appendClassPath(new CustomizedLoaderClassPath(cl));
+
+ List<String> allMethod = new ArrayList<>();
+ try {
+ final CtMethod[] ctMethods = classPool.get(c.getName()).getMethods();
+ for (CtMethod method : ctMethods) {
+ allMethod.add(ReflectUtils.getDesc(method));
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ Method[] methods = Arrays.stream(c.getMethods())
+ .filter(method -> allMethod.contains(ReflectUtils.getDesc(method)))
+ .collect(Collectors.toList())
+ .toArray(new Method[] {});
// get all public method.
boolean hasMethod = hasMethods(methods);
if (hasMethod) {
@@ -159,7 +179,7 @@ public abstract class Wrapper {
sameNameMethodCount.compute(m.getName(),
(key, oldValue) -> oldValue == null ? 1 : oldValue + 1);
}
-
+
c3.append(" try{");
for (Method m : methods) {
//ignore Object's method.