From 5ad558c800d3c11c4e8dc3452dfc5ba505f2fdb1 Mon Sep 17 00:00:00 2001 From: Carlos Grappa Date: Fri, 19 Jun 2020 00:04:32 -0300 Subject: [PATCH] BAEL-4154 IOException Too many open files (#9511) * BAEL-4154 IOException Too many open files * Add comment to explain GC dependency Co-authored-by: Carlos Grappa --- .../exceptions/TooManyOpenFilesExceptionLiveTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/TooManyOpenFilesExceptionLiveTest.java b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/TooManyOpenFilesExceptionLiveTest.java index 9373563df7..adaa183f71 100644 --- a/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/TooManyOpenFilesExceptionLiveTest.java +++ b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/TooManyOpenFilesExceptionLiveTest.java @@ -16,6 +16,10 @@ import org.junit.jupiter.api.AfterEach; public class TooManyOpenFilesExceptionLiveTest { + //This is not a regular UnitTest due to the fact that it depends on System.gc() to work properly. + //As we have to force the JVM to run out of file descriptors, any other tests that uses IO may fail. + //This may indirectly affect other tests that are part of the Jenkins Build. + private File tempFile; @BeforeEach @@ -25,6 +29,7 @@ public class TooManyOpenFilesExceptionLiveTest { @AfterEach public void tearDown() { + //Enforce a GC to clear unreferenced files and release descriptors System.gc(); tempFile.delete(); }