diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java index d58858363..b8e416b08 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java @@ -47,7 +47,7 @@ public Stream> scan(Class clazz) { methodAnnotationClass.getName()); return Arrays.stream(clazz.getDeclaredMethods()) - .filter(method -> !method.isBridge()) + .filter(AnnotationScannerUtil::isMethodInSourceCode) .filter(method -> AnnotationScannerUtil.findAnnotation(methodAnnotationClass, method) != null) .map(this::mapMethodToChannel); } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java index 93c7cf9fe..6c3ec13b3 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java @@ -60,7 +60,7 @@ protected Stream> getAnnotatedMethods(Class type) { log.debug("Scanning class \"{}\" for @\"{}\" annotated methods", type.getName(), annotationClass.getName()); return Arrays.stream(ReflectionUtils.getAllDeclaredMethods(type)) - .filter(method -> !method.isBridge()) + .filter(AnnotationScannerUtil::isMethodInSourceCode) .filter(method -> AnnotationScannerUtil.findAnnotation(annotationClass, method) != null) .peek(method -> log.debug("Mapping method \"{}\" to channels", method.getName())) .flatMap(method -> AnnotationScannerUtil.findAnnotations(annotationClass, method).stream() diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java index 5aeb45323..de4b8b4df 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java @@ -18,7 +18,6 @@ import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationClassLevelOperationsScanner; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.AnnotationUtils; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -58,8 +57,8 @@ protected Set getAnnotatedMethods(Class clazz) { methodAnnotationClass.getName()); return Arrays.stream(clazz.getDeclaredMethods()) - .filter(method -> !method.isBridge()) - .filter(method -> AnnotationUtils.findAnnotation(method, methodAnnotationClass) != null) + .filter(AnnotationScannerUtil::isMethodInSourceCode) + .filter(method -> AnnotationScannerUtil.findAnnotation(methodAnnotationClass, method) != null) .collect(toSet()); } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AnnotationScannerUtil.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AnnotationScannerUtil.java index 91ea0d498..297aa60a6 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AnnotationScannerUtil.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AnnotationScannerUtil.java @@ -10,12 +10,20 @@ import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; import java.util.Set; public class AnnotationScannerUtil { private AnnotationScannerUtil() {} + /** + * Check that a method was written by a developer and not generated by the compiler. + */ + public static boolean isMethodInSourceCode(Method method) { + return !method.isSynthetic(); + } + public static T findAnnotationOrThrow(Class annotationClass, AnnotatedElement element) { T annotation = findAnnotation(annotationClass, element); if (annotation == null) { diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java index df688d8d9..481234370 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java @@ -50,7 +50,7 @@ public Stream> scan(Class clazz) { methodAnnotationClass.getName()); return Arrays.stream(clazz.getDeclaredMethods()) - .filter(method -> !method.isBridge()) + .filter(AnnotationScannerUtil::isMethodInSourceCode) .filter(method -> AnnotationScannerUtil.findAnnotation(methodAnnotationClass, method) != null) .map(this::mapMethodToOperation); }