spring-projects / spring-projects/spring-tools

Warning when annotated methods are self-invocated from within its own class

Open
#1,193 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

for: eclipse for: vscode status: needs-discussion status: needs-investigation theme: validation type: enhancement
Dominant language
Java
Stars
983
Forks
240
Avg merge
7d 1h
Merged PRs (30d)
7

Description

Expected Behavior

Given the example

1    @Transactional
2    public void foo() {
3        ...
4    }
5
6    public void bar() {
7        this.foo();
8    } 

when calling bar(), foo() will not be executed in a transaction, because AOP only works with calls from outside the class AFAIK. The same applies probably for other annotations like @Cacheable.

I would expect from my IDE to be warned or at least informed about this situation. So in the line 7 I would expect a marker.

Current Behavior

No hints at all. You need to know what is going on.

Context

The situation is simply error-prone for inexperienced devs. A simple info or warning marker could help resolving the risk.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by locating the IDE inspections for Java and Spring annotations, then trace how calls such as this.foo() are analyzed. Done means reliably identifying self-invocation of annotated methods, presenting an informational or warning marker at the call site, and covering the behavior with tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
developer-experience, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.