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

3.2.0: calling overridden method does not start transaction #34723

Closed
Shohou opened this issue Jul 13, 2023 · 3 comments
Closed

3.2.0: calling overridden method does not start transaction #34723

Shohou opened this issue Jul 13, 2023 · 3 comments
Labels
area/arc Issue related to ARC (dependency injection) area/narayana Transactions / Narayana kind/bug Something isn't working

Comments

@Shohou
Copy link

Shohou commented Jul 13, 2023

Describe the bug

https://github.com/Shohou/quarkus-super-tr
It has standard auto generated project with panache and rest-reactive. GreetingResource.hello() calls SomeService.doSomething() which doesn't have @Transactional annotation and doesn't start transaction. SomeService.doSomething() calls super.doSomething() of SomeAbstractService which has @Transactional and should start transaction, but with quarkus 3.2.0.Final this doesn't happen. But it does start transaction if I fall back to quarkus 3.1.3.Final

Expected behavior

calling SomeAbstractService.doSomething() from overridden method starts transaction as it has @Transactional annotation.

Actual behavior

transaction not started and attempt to modify and persist entity fails with PersistentObjectException exception saying entity is detached

How to Reproduce?

Reproducer: https://github.com/Shohou/quarkus-super-tr

Steps to reproduce:

  1. run ./gradlew clean quarkusDev
  2. call GET http://localhost:8080/hello and check quarkusDev console
  3. you will see it prints Transaction status - 6 and then throws PersistentObjectException exception
  4. edit gradle.properties and change quarkus version to 3.1.3.Final for quarkusPluginVersion and quarkusPlatformVersion
  5. restart ./gradlew clean quarkusDev
  6. call GET http://localhost:8080/hello and check quarkusDev console
  7. you will see it prints Transaction status - 0, doesn't throw exception and rest call succeeds

Output of uname -a or ver

No response

Output of java -version

openjdk version "17.0.7"

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.0.Final

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

No response

Additional information

No response

@Shohou Shohou added the kind/bug Something isn't working label Jul 13, 2023
@Shohou
Copy link
Author

Shohou commented Jul 13, 2023

issue can be also reproduced by running GreetingResourceTest or by running ./gradlew build which runs the same test and fails

@geoand geoand added area/narayana Transactions / Narayana area/arc Issue related to ARC (dependency injection) labels Jul 14, 2023
@Shohou
Copy link
Author

Shohou commented Aug 2, 2023

found that on 3.1.3.Final it didn't open transaction when I call super.doSomething() of SomeAbstractService, I got it wrong. It just takes @Transactional from super method and applies to overriding method as well. So the difference between versions is that 3.1.3.Final sees @Transactional from super method, but 3.2.x doesn't...

@Ladicek
Copy link
Contributor

Ladicek commented Sep 13, 2023

So the difference between versions is that 3.1.3.Final sees @Transactional from super method, but 3.2.x doesn't...

Sounds like this is a CDI compatibility issue. @Transactional is an interceptor binding annotation, so the CDI rules for annotation inheritance apply. Those rules are mostly the same as the Java language rules for annotation inheritance, and those are very clear: annotations are only inherited on classes (and only if the annotations are @Inherited, which @Transactional is), never on methods.

Inheritance of interceptor binding annotations was previously not working correctly and was fixed in #33523 in Quarkus 3.2. I left a buggy behavior in the default (non-compatible) mode for non-@Inherited class-level annotations, because of CI failures. There were no CI failures for buggy behavior of inheriting interceptor binding annotations from methods, so I just fixed that. I'm fairly sure this is the cause of this issue.

To sum up: you're observing an effect of a bug fix. CDI never inherits annotations on methods. You need to annotate the overriding method again.

@Ladicek Ladicek closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/narayana Transactions / Narayana kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants