A transaction, async or cache annotation sits on a private or static method, where a proxy cannot apply it
What it finds
Spring applies @Transactional, @Async, @Cacheable and the like through a proxy that wraps calls coming from other beans. A proxy can only override methods that a subclass could override, so on a private or static method the annotation does nothing: the method runs without a transaction, synchronously or uncached, as the Spring documentation on proxying explains.
Reported is one of @Transactional, @Async, @Cacheable, @CachePut, @CacheEvict and @Retryable on a private or static method.
From the rule's source, unproxied_annotation.rs.
import org.springframework.scheduling.annotation.Async;import org.springframework.transaction.annotation.Transactional; class Orders { @Transactionaltx0 reports: @Transactional has no effect on a private method private void save() {} @Asynctx0 reports: @Async has no effect on a static method static void notifyAll(String message) {} @Transactional public void place() {}} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:unproxied-annotation" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:unproxied-annotation] reason="..."tx0 explain tx0/java:unproxied-annotation shows the same in the terminal. Found a false positive? Report it.