rspec/rules/S2229/java/rule.adoc

42 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
When using Spring proxies, calling a method in the same class (e.g. ``++this.aMethod()++``) with an incompatible ``++@Transactional++`` requirement will result in runtime exceptions because Spring only "sees" the caller and makes no provisions for properly invoking the callee.
Therefore, certain calls should never be made within the same class:
||From||To||
| non-``++@Transactional++`` | MANDATORY, NESTED, REQUIRED, REQUIRES_NEW |
| MANDATORY | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
| NESTED | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
| NEVER | MANDATORY, NESTED, REQUIRED, REQUIRES_NEW |
| NOT_SUPPORTED | MANDATORY, NESTED, REQUIRED, REQUIRES_NEW |
| REQUIRED or ``++@Transactional++`` | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
| REQUIRES_NEW | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
| SUPPORTS | MANDATORY, NESTED, NEVER, NOT_SUPPORTED, REQUIRED, REQUIRES_NEW |
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
@Override
public void doTheThing() {
// ...
actuallyDoTheThing(); // Noncompliant
}
@Override
@Transactional
public void actuallyDoTheThing() {
// ...
}
----