java:S6809 does not recognize surrounding transaction

I get this issue with a method that has a Transactionl annotation.
Methods with Spring proxy should not be called via “this” [java:S6809]

IMO this is wrong because if there is a surrounding transaction calling another transactional method locally is perfectly fine.

1 Like

Hey there!

I’ve moved your post to the section on reporting false-positives.

Can you please include a text-based code sample rather than a screenshot?

I’ve discussed this with other Spring developers and concluded that the issue is correct.

There is one case that will break the transactional behavior:
If, in the example, the save method will throw a RuntimeException and the saveWithEventsAndPersons will catch the exception the transaction of the save method will not be marked as rollback-only.

This means it’s not a false positive.

1 Like

Hey @simasch

Thanks a lot for the follow-up!

Hello. I recently found out that the interpretation was changed, and now it doesn’t allow @Transactional methods within another @Transactional method, even with the correct propagation level.
In my opinion, this is a false positive.
If we consider the behavior being different between proxy and direct invocation as a code smell, then annotating the whole class would have the same effect, and every method should be violating S6809.

1 Like

Hey @prokop7

I think it would be best if you created a new thread and made sure you provide all the details noted in this post: