SONARJAVA-6696: S8989 should not raise on private methods - #5885
SONARJAVA-6696: S8989 should not raise on private methods#5885romainbrenguier wants to merge 3 commits into
Conversation
@transactional has no effect on private methods since Spring AOP uses proxies that cannot intercept private methods. Skip private methods to avoid false positives. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Spring proxy-based AOP only intercepts public methods, so extend the exclusion from private-only to all non-public methods (protected, package-private). Also fix import ordering and update autoscan diffs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review ✅ Approved 2 resolved / 2 findingsUpdates rule S8989 to skip non-public methods where Spring AOP proxies cannot intercept ✅ 2 resolved✅ Quality: Import ordering broken by new ModifiersUtils import
✅ Edge Case: Only private skipped; protected/package-private also not proxied
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|
| @Transactional | ||
| private void privateMethod() throws IOException { // Compliant - private methods are not proxied by Spring | ||
| } | ||
|
|
||
| @Transactional | ||
| private void privateMethodMultipleExceptions() throws IOException, SQLException { // Compliant | ||
| } |
There was a problem hiding this comment.
If it has not effect, why would one put the annotation? This case will be covered by S2230.




Summary
@Transactionalmethods should specify rollback behavior for checked exceptions) now skips private methods@Transactionalhas no effect on them — raising an issue would be a false positive@TransactionalTest plan
@Transactional@Transactional@Transactionalstill raise issues🤖 Generated with Claude Code