Skip to content

Commit c719d4c

Browse files
committed
Fix the error 'no method body' with reactor.core.publisher.Signal
1 parent d8402c2 commit c719d4c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

discovery-agent-starter/src/main/java/com/nepxion/discovery/agent/plugin/spring/async/SpringAsyncPlugin.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import javassist.CtClass;
1313
import javassist.CtMethod;
14+
import javassist.Modifier;
1415

1516
import java.security.ProtectionDomain;
1617

@@ -37,10 +38,14 @@ public byte[] doInTransform(ClassLoader classLoader, String className, Class<?>
3738
try {
3839
ClassInfo classInfo = new ClassInfo(className, classfileBuffer, classLoader);
3940
CtClass ctClass = classInfo.getCtClass();
40-
CtMethod method = ctClass.getMethod("doSubmit", "(Ljava/util/concurrent/Callable;Lorg/springframework/core/task/AsyncTaskExecutor;Ljava/lang/Class;)Ljava/lang/Object;");
41-
if (null != method) {
41+
if (ctClass.isInterface()) {
42+
return null;
43+
}
44+
45+
CtMethod ctMethod = ctClass.getMethod("doSubmit", "(Ljava/util/concurrent/Callable;Lorg/springframework/core/task/AsyncTaskExecutor;Ljava/lang/Class;)Ljava/lang/Object;");
46+
if (null != ctMethod && !Modifier.isNative(ctMethod.getModifiers()) && !Modifier.isAbstract(ctMethod.getModifiers())) {
4247
StringBuffer sb = new StringBuffer();
43-
CtClass[] parameterTypes = method.getParameterTypes();
48+
CtClass[] parameterTypes = ctMethod.getParameterTypes();
4449
for (int i = 0; i < parameterTypes.length; i++) {
4550
final String paramTypeName = parameterTypes[i].getName();
4651
if (CALLABLE_CLASS_NAME.equals(paramTypeName)) {
@@ -49,7 +54,7 @@ public byte[] doInTransform(ClassLoader classLoader, String className, Class<?>
4954
}
5055

5156
if (sb.length() > 0) {
52-
method.insertBefore(sb.toString());
57+
ctMethod.insertBefore(sb.toString());
5358
}
5459
}
5560

discovery-agent-starter/src/main/java/com/nepxion/discovery/agent/plugin/thread/ThreadTransformCallback.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import javassist.CtConstructor;
1515
import javassist.CtField;
1616
import javassist.CtMethod;
17+
import javassist.Modifier;
1718

1819
import java.lang.reflect.Method;
1920
import java.security.ProtectionDomain;
@@ -31,6 +32,9 @@ public byte[] doInTransform(ClassLoader classLoader, String className, Class<?>
3132
try {
3233
ClassInfo classInfo = new ClassInfo(className, classfileBuffer, classLoader);
3334
CtClass ctClass = classInfo.getCtClass();
35+
if (ctClass.isInterface()) {
36+
return null;
37+
}
3438

3539
addField(ctClass, AsyncContextAccessor.class);
3640

@@ -41,7 +45,7 @@ public byte[] doInTransform(ClassLoader classLoader, String className, Class<?>
4145

4246
String implMethodName = getImplMethodName();
4347
CtMethod ctMethod = ctClass.getDeclaredMethod(implMethodName);
44-
if (null != ctMethod) {
48+
if (null != ctMethod && !Modifier.isNative(ctMethod.getModifiers()) && !Modifier.isAbstract(ctMethod.getModifiers())) {
4549
ctMethod.insertBefore(ThreadConstant.RUN_BEFORE_INTERCEPTOR);
4650
ctMethod.insertAfter(ThreadConstant.RUN_AFTER_INTERCEPTOR);
4751
}

0 commit comments

Comments
 (0)