This is an automated email from the ASF dual-hosted git repository.
pottlinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
The following commit(s) were added to refs/heads/master by this push:
new 28339bae RAT-533, RAT-475: Remove garbage collection workaround and
use CleanupMode.NEVER to speed-up builds
28339bae is described below
commit 28339bae897a279001a8ee244686acf4679f82c3
Author: P. Ottlinger <[email protected]>
AuthorDate: Fri Jan 23 10:40:41 2026 +0100
RAT-533, RAT-475: Remove garbage collection workaround and use
CleanupMode.NEVER to speed-up builds
---
.../test/java/org/apache/rat/OptionCollectionTest.java | 15 ++-------------
.../src/test/java/org/apache/rat/ReporterOptionsTest.java | 15 ++-------------
.../apache/rat/config/exclusion/ExclusionUtilsTest.java | 15 ++-------------
.../fileProcessors/AbstractIgnoreBuilderTest.java | 13 ++-----------
.../src/test/java/org/apache/rat/mp/OptionMojoTest.java | 15 ++-------------
.../src/test/java/org/apache/rat/mp/RatCheckMojoTest.java | 11 ++---------
.../java/org/apache/rat/anttasks/ReportOptionTest.java | 10 ----------
src/changes/changes.xml | 3 +++
8 files changed, 15 insertions(+), 82 deletions(-)
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
b/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
index 87f7cd96..4011ce5e 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
@@ -46,8 +46,7 @@ import org.apache.rat.utils.Log;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsProvider;
@@ -67,7 +66,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
public class OptionCollectionTest {
- @TempDir
+ @TempDir(cleanup = CleanupMode.NEVER)
static Path testPath;
@AfterAll
@@ -166,16 +165,6 @@ public class OptionCollectionTest {
return result;
}
- /**
- * This method is a known workaround for
- * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit
5 issue #2811</a> }.
- */
- @AfterEach
- @EnabledOnOs(OS.WINDOWS)
- void cleanUp() {
- System.gc();
- }
-
@Test
public void testDeprecatedUseLogged() throws IOException {
TestingLog log = new TestingLog();
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
index 9c7a389c..8af8b686 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
@@ -35,8 +35,7 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;
@@ -46,7 +45,7 @@ import static org.assertj.core.api.Fail.fail;
public final class ReporterOptionsTest {
- @TempDir
+ @TempDir(cleanup = CleanupMode.NEVER)
static Path testPath;
@AfterAll
@@ -54,16 +53,6 @@ public final class ReporterOptionsTest {
AbstractConfigurationOptionsProvider.preserveData(testPath.toFile(),
"reporterOptionsTest");
}
- /**
- * This method is a known workaround for
- * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit
5 issue #2811</a> }.
- */
- @AfterEach
- @EnabledOnOs(OS.WINDOWS)
- void cleanUp() {
- System.gc();
- }
-
@BeforeEach
void setup() {
ReporterOptionsProvider.sourceDir = null;
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/ExclusionUtilsTest.java
b/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/ExclusionUtilsTest.java
index d57fb12c..48a2897e 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/ExclusionUtilsTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/ExclusionUtilsTest.java
@@ -22,8 +22,7 @@ import org.apache.rat.ConfigurationException;
import org.apache.rat.utils.ExtendedIterator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import java.io.FileWriter;
@@ -43,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class ExclusionUtilsTest {
- @TempDir
+ @TempDir(cleanup = CleanupMode.NEVER)
private File testDir;
private final int fileCount = 0;
@@ -59,16 +58,6 @@ public class ExclusionUtilsTest {
"This is a normal line", "**/ignoreMe/*", "C:\\No Space In
FileNames Please"
};
- /**
- * This method is a known workaround for
- * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit
5 issue #2811</a> }.
- */
- @AfterEach
- @EnabledOnOs(OS.WINDOWS)
- void cleanUp() {
- System.gc();
- }
-
private File createFile(Iterable<String> contents) {
File f = new File(testDir, "file" + fileCount);
try (PrintWriter pw = new PrintWriter(new FileWriter(f))) {
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/AbstractIgnoreBuilderTest.java
b/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/AbstractIgnoreBuilderTest.java
index 1a4de5ec..76f37e60 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/AbstractIgnoreBuilderTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/config/exclusion/fileProcessors/AbstractIgnoreBuilderTest.java
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import java.io.File;
@@ -44,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class AbstractIgnoreBuilderTest {
- @TempDir
+ @TempDir(cleanup = CleanupMode.NEVER)
protected Path tmpPath;
protected DocumentName baseName;
@@ -59,16 +60,6 @@ public class AbstractIgnoreBuilderTest {
baseName = null;
}
- /**
- * This method is a known workaround for
- * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit
5 issue #2811</a> }.
- */
- @AfterEach
- @EnabledOnOs(OS.WINDOWS)
- void cleanUp() {
- System.gc();
- }
-
/**
* Writes a text file to the baseDir directory.
* @param name the name of the file.
diff --git
a/apache-rat-plugin/src/test/java/org/apache/rat/mp/OptionMojoTest.java
b/apache-rat-plugin/src/test/java/org/apache/rat/mp/OptionMojoTest.java
index 03a49fc5..68c2864b 100644
--- a/apache-rat-plugin/src/test/java/org/apache/rat/mp/OptionMojoTest.java
+++ b/apache-rat-plugin/src/test/java/org/apache/rat/mp/OptionMojoTest.java
@@ -35,8 +35,7 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsProvider;
@@ -57,7 +56,7 @@ import static org.junit.jupiter.api.Assertions.fail;
public class OptionMojoTest {
- @TempDir
+ @TempDir(cleanup = CleanupMode.NEVER)
static Path testPath;
static String POM_FMT;
@@ -72,16 +71,6 @@ public class OptionMojoTest {
AbstractConfigurationOptionsProvider.preserveData(testPath.toFile(),
"optionTest");
}
- /**
- * This method is a known workaround for
- * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit
5 issue #2811</a> }.
- */
- @AfterEach
- @EnabledOnOs(OS.WINDOWS)
- void cleanUp() {
- System.gc();
- }
-
@ParameterizedTest
@ArgumentsSource(MojoOptionsProvider.class)
void testOptionsUpdateConfig(String name, OptionCollectionTest.OptionTest
test) {
diff --git
a/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
b/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
index 0d10e37f..1afb32eb 100644
--- a/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
+++ b/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
@@ -51,8 +51,7 @@ import org.apache.rat.testhelpers.XmlUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
@@ -62,7 +61,7 @@ import org.w3c.dom.NodeList;
*/
public class RatCheckMojoTest {
- @TempDir
+ @TempDir(cleanup = CleanupMode.NEVER)
static Path tempDir;
private final static XPath xPath = XPathFactory.newInstance().newXPath();
@@ -72,12 +71,6 @@ public class RatCheckMojoTest {
AbstractConfigurationOptionsProvider.preserveData(tempDir.toFile(),
"unit");
}
- @AfterAll
- @EnabledOnOs(OS.WINDOWS)
- static void cleanup() {
- System.gc(); // hacky workaround for windows bug.
- }
-
private RatCheckMojo getMojo(File pomFile) throws IOException {
try {
final RatCheckMojo mojo = new OptionMojoTest.SimpleMojoTestcase() {
diff --git
a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
index 9ad73463..b438f934 100644
---
a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
+++
b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
@@ -80,16 +80,6 @@ public class ReportOptionTest {
AbstractConfigurationOptionsProvider.preserveData(testPath.toFile(),
"optionTest");
}
- @AfterAll
- // hacky workaround for windows bug described in RAT-475, try to force
resource cleanup via GC
- @EnabledOnOs(OS.WINDOWS)
- // GC is also enabled on GitHubAction runs as its JDK is configured to do
I/O stuff lazily, thus a GC forces all resources to be closed
- // Failures happen on ASF Jenkins as well, therefore we call the
workaround under linux as well
- @EnabledIf("isRunningOnGitHubActionOrLinux")
- static void cleanup() {
- System.gc();
- }
-
@ParameterizedTest
@ArgumentsSource(AntOptionsProvider.class)
public void testOptionsUpdateConfig(String name,
OptionCollectionTest.OptionTest test) {
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 951c630e..766bb80b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,6 +68,9 @@ in order to be properly linked in site reports.
</release>
-->
<release version="1.0.0" date="xxxx-yy-zz" description="Current SNAPSHOT -
release to be done">
+ <action issue="RAT-475, RAT-533" type="add" dev="pottlinger"
due-to="Ryan Schmitt">
+ Speedup tests and avoid garbage collection workaround by changing to
CleanupMode.NONE in jUnit's TempDir usages.
+ </action>
<action issue="RAT-533" type="fix" dev="pottlinger" due-to="Ryan
Schmitt">
Reduce sample size of charset detection from 12000 to 256 byte (Tika)
to increase I/O performance of RAT scans.
</action>