From 43df701a10a80306dd98da8644a9bbfbf5d17089 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sat, 2 Mar 2024 11:52:31 +0100 Subject: Avoid ThreadLocal memory leak in JoinPointImpl according to https://rules.sonarsource.com/java/tag/leak/RSPEC-5164/. Now, there no longer is a thread-local stack of AroundClosure instances, but rather a list of them, which can only grow but never shrink. Instead, we now have a thread-local (integer) list index, for every thread being initialised with pointing to the last element. I.e., every thread can unwind by decrementing the index while proceeding, independently of other threads. A positive side effect is that this approach also works for long-lived threads from thread pools, used by executor services. Hence, test Bugs199Tests.testAsyncProceedNestedAroundAdviceThreadPool_gh128, which was previously commented out, has been activated and passes, see #141. I am not sure if this brings @AspectJ style, non-inlined, nested around advice execution functionally on par with native ones, but at least for current scenarios it seems to work. Fixes #288, #141. Signed-off-by: Alexander Kriegisch --- .../src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java | 5 +++-- tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java index 6ec1291d4..3428c3e3c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java @@ -49,8 +49,9 @@ public class Bugs199Tests extends XMLBasedAjcTestCase { } public void testAsyncProceedNestedAroundAdviceThreadPool_gh128() { - // TODO: future improvement, see https://github.com/eclipse-aspectj/aspectj/issues/141 - // runTest("asynchronous proceed for nested around-advice (@AspectJ, thread pool)"); + // Test created for #128, but initially commented out and remaining work recorded in #141. + // Now, test is expected to pass. See https://github.com/eclipse-aspectj/aspectj/issues/141. + runTest("asynchronous proceed for nested around-advice (@AspectJ, thread pool)"); } public void testAsyncProceedNestedAroundAdviceNative_gh128() { diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml index d8868ca22..35136023a 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml @@ -196,7 +196,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -354,7 +354,7 @@ - + @@ -433,7 +433,7 @@ - + -- cgit v1.2.3