Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate annotation for class: interface io.smallrye.common.annotation.CheckReturnValue #35715

Closed
PartyBuzzProject opened this issue Sep 4, 2023 · 25 comments · Fixed by #36038
Labels
area/hibernate-orm Hibernate ORM area/smallrye kind/bug Something isn't working
Milestone

Comments

@PartyBuzzProject
Copy link

PartyBuzzProject commented Sep 4, 2023

Describe the bug

rest.zip

Expected behavior

No response

Actual behavior

Caused by: java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: interface io.smallrye.common.annotation.CheckReturnValue: @io.smallrye.common.annotation.CheckReturnValue()
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:126)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
    at java.base/java.lang.reflect.Executable.declaredAnnotations(Executable.java:625)
    at java.base/java.lang.reflect.Executable.declaredAnnotations(Executable.java:623)
    at java.base/java.lang.reflect.Executable.getAnnotation(Executable.java:591)
    at java.base/java.lang.reflect.Method.getAnnotation(Method.java:738)
    at java.base/java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:292)
    at java.base/java.lang.reflect.AccessibleObject.isAnnotationPresent(AccessibleObject.java:518)
    at org.hibernate.annotations.common.reflection.java.JavaAnnotationReader.isAnnotationPresent(JavaAnnotationReader.java:33)
    at org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.isAnnotationPresent(JavaXAnnotatedElement.java:43)
    at org.hibernate.annotations.common.reflection.java.JavaXMember.isAnnotationPresent(JavaXMember.java:26)
    at org.hibernate.jpa.event.internal.CallbackDefinitionResolverLegacyImpl.resolveEntityCallbacks(CallbackDefinitionResolverLegacyImpl.java:55)
    at org.hibernate.boot.model.internal.EntityBinder.bindCallbacks(EntityBinder.java:1091)
    at org.hibernate.boot.model.internal.EntityBinder.bindEntityClass(EntityBinder.java:244)
    at org.hibernate.boot.model.internal.AnnotationBinder.bindClass(AnnotationBinder.java:417)
    at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:255)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:275)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:318)
    at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:406)
    at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101)
    at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73)
    at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40)
    at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:78)
    at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:79)
    at io.quarkus.deployment.steps.ArcProcessor$generateResources844392269.deploy_0(Unknown Source)
    at io.quarkus.deployment.steps.ArcProcessor$generateResources844392269.deploy(Unknown Source)
    ... 16 more

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@PartyBuzzProject PartyBuzzProject added the kind/bug Something isn't working label Sep 4, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 4, 2023

/cc @Ladicek (smallrye), @jmartisk (smallrye), @phillip-kruger (smallrye), @radcortez (smallrye)

@geoand geoand added the area/hibernate-orm Hibernate ORM label Sep 4, 2023
@mklueh
Copy link
Contributor

mklueh commented Sep 7, 2023

Same here and this is the culprit

implementation("io.quarkus:quarkus-hibernate-reactive-panache-kotlin")

@PartyBuzzProject
Copy link
Author

@mklueh i dont know what it was but i set the project up new, and now it works. i had to learn a few tweaks but i got it to work. if you want i can help you try to solve it.

@mklueh
Copy link
Contributor

mklueh commented Sep 8, 2023

@PartyBuzzProject glad to hear. thanks

@go-neta
Copy link

go-neta commented Sep 12, 2023

@PartyBuzzProject - can you mention how you solved it? I am facing the same issue

@PartyBuzzProject
Copy link
Author

PartyBuzzProject commented Sep 12, 2023

@go-neta so in my case i wanted to use flyway so i had a jdbc driver besides the reactive driver and i now managed to remove the jdbc driver dependency and disable jdbc and write my own execution of flyway that currently looks like this:

@ApplicationScoped
class FlywayMigrator() {

    val runMigration: Boolean =
        ConfigProvider.getConfig().getValue("partybuzz.flyway.run-migration", Boolean::class.java)
    val datasourceUrl: String =
        ConfigProvider.getConfig().getValue("quarkus.datasource.reactive.url", String::class.java)
    val datasourceUsername: String =
        ConfigProvider.getConfig().getValue("quarkus.datasource.username", String::class.java)
    val datasourcePassword: String = ""
//        ConfigProvider.getConfig().getValue("quarkus.datasource.password", String::class.java)

    fun runFlywayMigration(@Observes event: StartupEvent?) {
        if (runMigration) {
            val flyway = Flyway.configure().dataSource("jdbc:$datasourceUrl", datasourceUsername, datasourcePassword).load()
            flyway.migrate()
        }
    }
}

its not worked out by now. so i need to add validation but im in early stage of development. hopefully that helps :)

@go-neta
Copy link

go-neta commented Sep 13, 2023

thanks for the update.
do you know what the underlying issue is?

@PartyBuzzProject
Copy link
Author

I have no idea. i think i also have too little experience with quarkus.

@gsmet
Copy link
Member

gsmet commented Sep 14, 2023

It would be nice if all people encountering this issue could provide a small reproducer project so that we can see the commonalities (might be a Gradle or Kotlin specific issue for instance).

Thanks.

@mklueh
Copy link
Contributor

mklueh commented Sep 15, 2023

It would be nice if all people encountering this issue could provide a small reproducer project so that we can see the commonalities (might be a Gradle or Kotlin specific issue for instance).

Thanks.

IMO it would be great if you had a full test project ( Multi Module Gradle + Kotlin ) that at least automatically verifies the compatibility between Quarkus dependencies, so users would not have to create dozens of reproducer projects and you would detect such issues before releasing a new version.

And then maybe people could check it out and add their individual issue (if it's something new and undetected) and you'll have it in your test suite as well, and over time you'd have more and more real-world usages you verify against.

@PartyBuzzProject
Copy link
Author

PartyBuzzProject commented Sep 18, 2023

@gsmet I have added a zip of my project in this issue.

@gsmet
Copy link
Member

gsmet commented Sep 18, 2023

IMO it would be great if you had a full test project ( Multi Module Gradle + Kotlin ) that at least automatically verifies the compatibility between Quarkus dependencies, so users would not have to create dozens of reproducer projects and you would detect such issues before releasing a new version.

@mklueh this is open source, you're welcome to contribute.

@gsmet
Copy link
Member

gsmet commented Sep 18, 2023

@jponge @cescoffier do you know who I could ping for this issue?

@jponge
Copy link
Member

jponge commented Sep 18, 2023

@gsmet I'll have a look at the zip file. At first sight the issue report is only a very partial stack trace with no context.

@go-neta
Copy link

go-neta commented Sep 18, 2023

I am facing the issue in the test environment.
Whenever I use the @QuarkusTest annotation in more then 1 test class I get the error below. So far only 1 http endpoint is tested successfully with this annotation, but now I am trying to test a grpc method with this annotation, while mocking the the repository. I also got this error in another test when trying to mock the repository but could finalize the tests without the @QuarkusTest annotation and the error was gone.
I am using kotlin, with hibernate reactive and panache. entities are annotated with @Entity, inheriting from PanacheEntityBase, and repositories are annotated with ApplicationScoped, inheriting from PanacheRepositoryBase.

My current test is failing on this line:
private var orderRepository: OrderRepository = Mockito.mock(OrderRepository::class.java)
stack-trace:

org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance
	at app//io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:786)
	at app//io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:752)
	at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
	at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at app//org.junit.jupiter.api.extension.InvocationInterceptor.interceptTestClassConstructor(InvocationInterceptor.java:73)
	at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
	at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
	at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:62)
	at app//org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestClassConstructor(ClassBasedTestDescriptor.java:363)
	at app//org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateTestClass(ClassBasedTestDescriptor.java:310)
	at app//org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:79)
	at app//org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:286)
	at app//org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:278)
	at [email protected]/java.util.Optional.orElseGet(Optional.java:364)
	at app//org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:277)
	at app//org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
	at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:105)
	at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:104)
	at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
	at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
	at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
	at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
	at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
	at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
	at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
	at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
	at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
	at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
	at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at app//org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:110)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:90)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:85)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
	at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at [email protected]/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at io.quarkus.runner.bootstrap.RunningQuarkusApplicationImpl.instance(RunningQuarkusApplicationImpl.java:90)
	at io.quarkus.test.junit.QuarkusTestExtension.createActualTestInstance(QuarkusTestExtension.java:792)
	at io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:780)
	... 81 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.runner.bootstrap.RunningQuarkusApplicationImpl.instance(RunningQuarkusApplicationImpl.java:88)
	... 83 more
Caused by: org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: class com.deliveryhero.posdirect.persistance.OrderRepository.

Mockito can only mock non-private & non-final classes, but the root cause of this error might be different.
Please check the full stacktrace to understand what the issue is.
If you're still not sure why you're getting this error, please open an issue on GitHub.


Java               : 17
JVM vendor name    : Amazon.com Inc.
JVM vendor version : 17.0.7+7-LTS
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 17.0.7+7-LTS
JVM info           : mixed mode, sharing
OS name            : Mac OS X
OS version         : 12.6.1


Underlying exception : java.lang.IllegalArgumentException: Could not create type
	at com.deliveryhero.posdirect.integration.PosOrderTransmissionServiceIT.<init>(PosOrderTransmissionServiceIT.kt:24)
	at com.deliveryhero.posdirect.integration.PosOrderTransmissionServiceIT_Bean.doCreate(Unknown Source)
	at com.deliveryhero.posdirect.integration.PosOrderTransmissionServiceIT_Bean.create(Unknown Source)
	at com.deliveryhero.posdirect.integration.PosOrderTransmissionServiceIT_Bean.get(Unknown Source)
	at com.deliveryhero.posdirect.integration.PosOrderTransmissionServiceIT_Bean.get(Unknown Source)
	at io.quarkus.arc.impl.InstanceImpl.getBeanInstance(InstanceImpl.java:325)
	at io.quarkus.arc.impl.InstanceImpl.getInternal(InstanceImpl.java:309)
	at io.quarkus.arc.impl.InstanceImpl.get(InstanceImpl.java:190)
	... 88 more
Caused by: java.lang.IllegalArgumentException: Could not create type
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:170)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:40)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:77)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:43)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:42)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:99)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:88)
	at org.mockito.Mockito.mock(Mockito.java:2101)
	at org.mockito.Mockito.mock(Mockito.java:2016)
	... 96 more
Caused by: java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: interface io.smallrye.common.annotation.CheckReturnValue: @io.smallrye.common.annotation.CheckReturnValue()
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:126)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
	at java.base/java.lang.reflect.Executable.declaredAnnotations(Executable.java:625)
	at java.base/java.lang.reflect.Executable.declaredAnnotations(Executable.java:623)
	at java.base/java.lang.reflect.Executable.getDeclaredAnnotations(Executable.java:611)
	at java.base/java.lang.reflect.Method.getDeclaredAnnotations(Method.java:747)
	at net.bytebuddy.description.method.MethodDescription$ForLoadedMethod.getDeclaredAnnotations(MethodDescription.java:1305)
	at net.bytebuddy.description.method.MethodDescription$TypeSubstituting.getDeclaredAnnotations(MethodDescription.java:1697)
	at net.bytebuddy.matcher.DeclaringAnnotationMatcher.doMatch(DeclaringAnnotationMatcher.java:48)
	at net.bytebuddy.matcher.DeclaringAnnotationMatcher.doMatch(DeclaringAnnotationMatcher.java:27)
	at net.bytebuddy.matcher.ElementMatcher$Junction$ForNonNullValues.matches(ElementMatcher.java:249)
	at net.bytebuddy.matcher.ElementMatcher$Junction$Disjunction.matches(ElementMatcher.java:214)
	at net.bytebuddy.matcher.NegatingMatcher.matches(NegatingMatcher.java:47)
	at net.bytebuddy.matcher.ElementMatcher$Junction$Conjunction.matches(ElementMatcher.java:146)
	at net.bytebuddy.matcher.ElementMatcher$Junction$Disjunction.matches(ElementMatcher.java:214)
	at net.bytebuddy.matcher.ElementMatcher$Junction$Conjunction.matches(ElementMatcher.java:146)
	at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:482)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.toTypeWriter(SubclassDynamicTypeBuilder.java:212)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.toTypeWriter(SubclassDynamicTypeBuilder.java:203)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4050)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3734)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:3986)
	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:296)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:47)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	... 107 more

Project set up:
kotlin: 1.8.22
java: 17
gradle: 8.1.1
from build.gradle:

dependencies {
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-kotlin'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
    implementation 'io.quarkus:quarkus-arc'
    implementation 'io.quarkus:quarkus-resteasy-reactive'
    implementation 'io.quarkus:quarkus-resteasy-reactive-jackson'
    implementation 'io.quarkus:quarkus-grpc'
    implementation 'io.quarkus:quarkus-opentelemetry'
    implementation 'io.quarkus:quarkus-hibernate-reactive-panache-kotlin'
    implementation 'io.quarkus:quarkus-reactive-pg-client'

    implementation 'io.quarkus:quarkus-logging-json'

    implementation 'library:io.deliveryhero.proto:v0.101.4'

    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.quarkus:quarkus-junit5-mockito'
    testImplementation 'org.mockito.kotlin:mockito-kotlin:5.1.0'
    testImplementation 'io.quarkus:quarkus-test-vertx'
    testImplementation 'io.rest-assured:rest-assured'
    testImplementation 'io.quarkus:quarkus-jacoco'
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

compileKotlin {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_17
    kotlinOptions.javaParameters = true
}

compileTestKotlin {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_17
}

test {
    systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
}

allOpen {
    annotation("jakarta.ws.rs.Path")
    annotation("jakarta.enterprise.context.ApplicationScoped")
    annotation("jakarta.persistence.Entity")
    annotation("io.quarkus.test.junit.QuarkusTest")
}

ktlint {
    ignoreFailures = false
}

I hope this is enough information. Let me know if you need more details

@jponge
Copy link
Member

jponge commented Sep 18, 2023

I've been able to reproduce the error, but I don't know where that double annotation comes from

@jponge
Copy link
Member

jponge commented Sep 18, 2023

I'm not familiar with this area of Quarkus, but I suspect the issue comes from HibernateReactivePanacheKotlinProcessor where mutinyReturnTypes is a build step that unconditionally adds @CheckReturnValue to Uni and Multi returning methods.

@jponge
Copy link
Member

jponge commented Sep 18, 2023

@nenros The issue is that in this case we have the annotation being added to these 2 methods:

io.smallrye.mutiny.Uni<T> findById(java.lang.Object id) in Lch/partybuzz/entity/BaseEntity;
io.smallrye.mutiny.Uni<T> findById(java.lang.Object id) in Lch/partybuzz/entity/EventEntity;

where EventEntity extends BaseEntity. Since the bytecode rewriting is in progress we get a double annotation.

Note that @CheckReturnValue is cosmetic to help IDEs check proper usage of Mutiny. Removing the annotation addition "solves" the problem, but...

@go-neta
Copy link

go-neta commented Sep 20, 2023

I changed the hibernate reactive library from this 'io.quarkus:quarkus-hibernate-reactive-panache-kotlin' to this: 'io.quarkus:quarkus-hibernate-reactive-panache' and the issue was gone

@geoand
Copy link
Contributor

geoand commented Sep 20, 2023

I'm not familiar with this area of Quarkus, but I suspect the issue comes from HibernateReactivePanacheKotlinProcessor where mutinyReturnTypes is a build step that unconditionally adds @CheckReturnValue to Uni and Multi returning methods.

Excellent analysis! Sounds like an easy fix in that case, no?

@jponge
Copy link
Member

jponge commented Sep 20, 2023

I'm not familiar with this area of Quarkus, but I suspect the issue comes from HibernateReactivePanacheKotlinProcessor where mutinyReturnTypes is a build step that unconditionally adds @CheckReturnValue to Uni and Multi returning methods.

Excellent analysis! Sounds like an easy fix in that case, no?

I'll have a look at a fix, because the problem happens with inheritance so it's not just about looking at wether the annotation is present or not ;-)

@geoand
Copy link
Contributor

geoand commented Sep 20, 2023

Interesting :)

@geoand
Copy link
Contributor

geoand commented Sep 20, 2023

Hold on, but why would having the annotation on a method of a subclass cause the problem?

@geoand
Copy link
Contributor

geoand commented Sep 20, 2023

Let me try something real quick

geoand added a commit to geoand/quarkus that referenced this issue Sep 20, 2023
* We don't add it if it's already there
* We don't run the transformation twice

Fixes: quarkusio#35715
@geoand
Copy link
Contributor

geoand commented Sep 20, 2023

Turns out the problem was easy enough to fix: #36038

gsmet pushed a commit to geoand/quarkus that referenced this issue Sep 21, 2023
* We don't add it if it's already there
* We don't run the transformation twice

Fixes: quarkusio#35715
geoand added a commit that referenced this issue Sep 21, 2023
Properly add @CheckReturnValue
@quarkus-bot quarkus-bot bot added this to the 3.5 - main milestone Sep 21, 2023
@gsmet gsmet modified the milestones: 3.5 - main, 3.4.2 Oct 3, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 3, 2023
* We don't add it if it's already there
* We don't run the transformation twice

Fixes: quarkusio#35715
(cherry picked from commit 88f0f1c)
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Feb 8, 2024
* We don't add it if it's already there
* We don't run the transformation twice

Fixes: quarkusio#35715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/smallrye kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants