From 88f0f1c60738cfd0504c6f40a41bc9e10fc76af0 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Wed, 20 Sep 2023 15:59:32 +0300 Subject: [PATCH] Properly add @CheckReturnValue * We don't add it if it's already there * We don't run the transformation twice Fixes: #35715 --- ...bernateReactivePanacheKotlinProcessor.java | 22 ------------------- .../PanacheHibernateResourceProcessor.java | 7 ++++-- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/extensions/panache/hibernate-reactive-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/kotlin/deployment/HibernateReactivePanacheKotlinProcessor.java b/extensions/panache/hibernate-reactive-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/kotlin/deployment/HibernateReactivePanacheKotlinProcessor.java index 6d4adddff02a3..4e5624b3a3b8c 100644 --- a/extensions/panache/hibernate-reactive-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/kotlin/deployment/HibernateReactivePanacheKotlinProcessor.java +++ b/extensions/panache/hibernate-reactive-panache-kotlin/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/kotlin/deployment/HibernateReactivePanacheKotlinProcessor.java @@ -14,9 +14,6 @@ import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; -import org.jboss.jandex.MethodInfo; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Type; import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.deployment.ValidationPhaseBuildItem; @@ -41,18 +38,12 @@ import io.quarkus.panache.common.deployment.PanacheMethodCustomizerBuildItem; import io.quarkus.panache.common.deployment.PanacheRepositoryEnhancer; import io.quarkus.panache.common.deployment.TypeBundle; -import io.smallrye.mutiny.Multi; -import io.smallrye.mutiny.Uni; public class HibernateReactivePanacheKotlinProcessor { private static final String META_INF_PANACHE_ARCHIVE_MARKER = "META-INF/panache-archive.marker"; private static final DotName DOTNAME_REACTIVE_SESSION = DotName.createSimple(Mutiny.Session.class.getName()); private static final DotName DOTNAME_ID = DotName.createSimple(Id.class.getName()); - private static final DotName DOTNAME_UNI = DotName.createSimple(Uni.class.getName()); - private static final DotName DOTNAME_MULTI = DotName.createSimple(Multi.class.getName()); - private static final String CHECK_RETURN_VALUE_BINARY_NAME = "io/smallrye/common/annotation/CheckReturnValue"; - private static final String CHECK_RETURN_VALUE_SIGNATURE = "L" + CHECK_RETURN_VALUE_BINARY_NAME + ";"; private static final TypeBundle TYPE_BUNDLE = ReactiveKotlinJpaTypeBundle.BUNDLE; @BuildStep @@ -171,17 +162,4 @@ public ValidationPhaseBuildItem.ValidationErrorBuildItem validate(ValidationPhas } return null; } - - @BuildStep - PanacheMethodCustomizerBuildItem mutinyReturnTypes() { - return new PanacheMethodCustomizerBuildItem(new PanacheMethodCustomizer() { - @Override - public void customize(Type entityClassSignature, MethodInfo method, MethodVisitor mv) { - DotName returnType = method.returnType().name(); - if (returnType.equals(DOTNAME_UNI) || returnType.equals(DOTNAME_MULTI)) { - mv.visitAnnotation(CHECK_RETURN_VALUE_SIGNATURE, true); - } - } - }); - } } diff --git a/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java b/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java index d320b3eb85e8a..75aa2098338bd 100644 --- a/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java +++ b/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java @@ -38,6 +38,7 @@ import io.quarkus.panache.common.deployment.PanacheJpaEntityOperationsEnhancer; import io.quarkus.panache.common.deployment.PanacheMethodCustomizer; import io.quarkus.panache.common.deployment.PanacheMethodCustomizerBuildItem; +import io.smallrye.common.annotation.CheckReturnValue; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; @@ -145,7 +146,8 @@ ValidationPhaseBuildItem.ValidationErrorBuildItem validate(ValidationPhaseBuildI return null; } - private static final String CHECK_RETURN_VALUE_BINARY_NAME = "io/smallrye/common/annotation/CheckReturnValue"; + private static final DotName DOTNAME_CHECK_RETURN_VALUE_CLASS = DotName.createSimple(CheckReturnValue.class); + private static final String CHECK_RETURN_VALUE_BINARY_NAME = CheckReturnValue.class.getName().replace('.', '/'); private static final String CHECK_RETURN_VALUE_SIGNATURE = "L" + CHECK_RETURN_VALUE_BINARY_NAME + ";"; @BuildStep @@ -154,7 +156,8 @@ PanacheMethodCustomizerBuildItem mutinyReturnTypes() { @Override public void customize(Type entityClassSignature, MethodInfo method, MethodVisitor mv) { DotName returnType = method.returnType().name(); - if (returnType.equals(DOTNAME_UNI) || returnType.equals(DOTNAME_MULTI)) { + if ((returnType.equals(DOTNAME_UNI) || returnType.equals(DOTNAME_MULTI)) + && !method.hasDeclaredAnnotation(DOTNAME_CHECK_RETURN_VALUE_CLASS)) { mv.visitAnnotation(CHECK_RETURN_VALUE_SIGNATURE, true); } }