Skip to content

Commit

Permalink
Avoid ThreadLocal memory leak in JoinPointImpl
Browse files Browse the repository at this point in the history
according to https://rules.sonarsource.com/java/tag/leak/RSPEC-5164/.

Fixes #288.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
  • Loading branch information
kriegaex committed Mar 2, 2024
1 parent 1cdf711 commit 186d38b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,16 @@ public final String toLongString() {
if (arcs == null) {
arcs = new InheritableThreadLocalAroundClosureStack();
}
if (arc==null) {
this.arcs.get().pop();
Stack<AroundClosure> closureStack = arcs.get();
if (arc == null) {
closureStack.pop();
if (closureStack.empty()) {
// Avoid ThreadLocal memory leak according to https://rules.sonarsource.com/java/tag/leak/RSPEC-5164/.
// Should fix https://github.com/eclipse-aspectj/aspectj/issues/288.
arcs.remove();
}
} else {
this.arcs.get().push(arc);
closureStack.push(arc);
}
}

Expand Down

0 comments on commit 186d38b

Please sign in to comment.