Skip to content

Commit

Permalink
Fix the error 'no method body' with reactor.core.publisher.Signal
Browse files Browse the repository at this point in the history
  • Loading branch information
HaojunRen committed Jan 15, 2024
1 parent d8402c2 commit c719d4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import javassist.CtClass;
import javassist.CtMethod;
import javassist.Modifier;

import java.security.ProtectionDomain;

Expand All @@ -37,10 +38,14 @@ public byte[] doInTransform(ClassLoader classLoader, String className, Class<?>
try {
ClassInfo classInfo = new ClassInfo(className, classfileBuffer, classLoader);
CtClass ctClass = classInfo.getCtClass();
CtMethod method = ctClass.getMethod("doSubmit", "(Ljava/util/concurrent/Callable;Lorg/springframework/core/task/AsyncTaskExecutor;Ljava/lang/Class;)Ljava/lang/Object;");
if (null != method) {
if (ctClass.isInterface()) {
return null;
}

CtMethod ctMethod = ctClass.getMethod("doSubmit", "(Ljava/util/concurrent/Callable;Lorg/springframework/core/task/AsyncTaskExecutor;Ljava/lang/Class;)Ljava/lang/Object;");
if (null != ctMethod && !Modifier.isNative(ctMethod.getModifiers()) && !Modifier.isAbstract(ctMethod.getModifiers())) {
StringBuffer sb = new StringBuffer();
CtClass[] parameterTypes = method.getParameterTypes();
CtClass[] parameterTypes = ctMethod.getParameterTypes();
for (int i = 0; i < parameterTypes.length; i++) {
final String paramTypeName = parameterTypes[i].getName();
if (CALLABLE_CLASS_NAME.equals(paramTypeName)) {
Expand All @@ -49,7 +54,7 @@ public byte[] doInTransform(ClassLoader classLoader, String className, Class<?>
}

if (sb.length() > 0) {
method.insertBefore(sb.toString());
ctMethod.insertBefore(sb.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javassist.CtConstructor;
import javassist.CtField;
import javassist.CtMethod;
import javassist.Modifier;

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

addField(ctClass, AsyncContextAccessor.class);

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

String implMethodName = getImplMethodName();
CtMethod ctMethod = ctClass.getDeclaredMethod(implMethodName);
if (null != ctMethod) {
if (null != ctMethod && !Modifier.isNative(ctMethod.getModifiers()) && !Modifier.isAbstract(ctMethod.getModifiers())) {
ctMethod.insertBefore(ThreadConstant.RUN_BEFORE_INTERCEPTOR);
ctMethod.insertAfter(ThreadConstant.RUN_AFTER_INTERCEPTOR);
}
Expand Down

0 comments on commit c719d4c

Please sign in to comment.