aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2024-03-06 15:27:50 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-03-12 08:21:38 +0100
commit966397e3bfe0d38aeca28c6aec0f543d62a0e2ea (patch)
tree1e682471439a1f176868a211f2249341677724d8 /tests/src/test
parent512d3fc281d2e56227e487dbf8ccee28cb63e589 (diff)
downloadaspectj-966397e3bfe0d38aeca28c6aec0f543d62a0e2ea.tar.gz
aspectj-966397e3bfe0d38aeca28c6aec0f543d62a0e2ea.zip
Add regression tests for inheritable thread-local memory leak
Leak was introduced in commit 3c80a36527, fixing #128, but introducing #288 instead, which was the lesser of two evils, but still bad for some users unwilling to use native AspectJ syntax for their aspects, avoiding the problem. Relates to #288. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/src/test')
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java8
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml52
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java
index 40459ba8d..8395b5bbf 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java
@@ -23,6 +23,14 @@ public class Bugs1921Tests extends XMLBasedAjcTestCase {
runTest("shared cache negative test");
}
+ public void testGitHub_288_AssertionError() {
+ runTest("memory leak for @AspectJ nested, non-inlined around-advice - AssertionError");
+ }
+
+ public void testGitHub_288_OutOfMemoryError() {
+ runTest("memory leak for @AspectJ nested, non-inlined around-advice - OutOfMemoryError");
+ }
+
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Bugs1921Tests.class);
}
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml
index 975fa1c6c..494b6dadd 100644
--- a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml
+++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml
@@ -393,4 +393,56 @@
</run>
</ajc-test>
+ <!--
+ https://github.com/eclipse-aspectj/aspectj/issues/288,
+ https://github.com/eclipse-aspectj/aspectj/issues/141, AspectJ 1.9.21.2
+ -->
+ <ajc-test dir="bugs1921/github_288" title="memory leak for @AspectJ nested, non-inlined around-advice - AssertionError">
+ <compile files="NestedAroundClosureMemoryLeakTest.java MemoryHog.java FirstAspect.aj SecondAspect.aj" options="-1.8 -XnoInline"/>
+ <run class="NestedAroundClosureMemoryLeakTest" vmargs="-ea --add-opens java.base/java.lang=ALL-UNNAMED">
+ <stdout>
+ <line text="FirstAspect"/>
+ <line text="SecondAspect"/>
+ <line text="Executing task"/>
+ <line text="Finished executing tasks"/>
+ <line text="Finished executing GC"/>
+ <line text="Test passed - all inheritable thread-locals are null after GC"/>
+ </stdout>
+ <!-- No AssertionError on stderr-->
+ <stderr/>
+ </run>
+ </ajc-test>
+
+ <!--
+ https://github.com/eclipse-aspectj/aspectj/issues/288,
+ https://github.com/eclipse-aspectj/aspectj/issues/141, AspectJ 1.9.21.2
+ -->
+ <ajc-test dir="bugs1921/github_288" title="memory leak for @AspectJ nested, non-inlined around-advice - OutOfMemoryError">
+ <compile files="NestedAroundClosureMemoryLeakTest.java MemoryHog.java FirstAspect.aj SecondAspect.aj" options="-1.8 -XnoInline"/>
+ <run class="NestedAroundClosureMemoryLeakTest" vmargs="-ea --add-opens java.base/java.lang=ALL-UNNAMED -Xmx512M" options="oom">
+ <stdout>
+ <line text="FirstAspect"/>
+ <line text="SecondAspect"/>
+ <line text="Executing task"/>
+ <line text="FirstAspect"/>
+ <line text="SecondAspect"/>
+ <line text="Executing task"/>
+ <line text="FirstAspect"/>
+ <line text="SecondAspect"/>
+ <line text="Executing task"/>
+ <line text="FirstAspect"/>
+ <line text="SecondAspect"/>
+ <line text="Executing task"/>
+ <line text="FirstAspect"/>
+ <line text="SecondAspect"/>
+ <line text="Executing task"/>
+ <line text="Finished executing tasks"/>
+ <line text="Finished executing GC"/>
+ <line text="Test passed - no OutOfMemoryError due to inheritable thread-locals memory leak"/>
+ </stdout>
+ <!-- No fatal OutOfMemoryError on stderr -->
+ <stderr/>
+ </run>
+ </ajc-test>
+
</suite>