diff options
author | Andrey Loskutov | 2021-04-22 16:34:44 +0000 |
---|---|---|
committer | Andrey Loskutov | 2021-04-22 17:49:03 +0000 |
commit | 2cea8caa28fd1fe3e5dcbd43a40f204e1dc84d35 (patch) | |
tree | ccca333f3771b05d954512d6db1206022bc1bfee | |
parent | faafc0ab6cd99562ebbe9577db2435ece4750ebd (diff) | |
download | eclipse.jdt.core-2cea8caa28fd1fe3e5dcbd43a40f204e1dc84d35.tar.gz eclipse.jdt.core-2cea8caa28fd1fe3e5dcbd43a40f204e1dc84d35.tar.xz eclipse.jdt.core-2cea8caa28fd1fe3e5dcbd43a40f204e1dc84d35.zip |
Bug 573088 - [test] testLeaksOnCleanBuild fails sporadically on Gerrit
Playing with GC/finalization - may be we have not referenced not closed
stream? If that helps, we probably have a real leak...
Change-Id: I4ad02cf11aad7c5ed6ac2b5d7e59203158957789
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/179683
-rw-r--r-- | org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java index 8986d6c591..9aa043fd8b 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java @@ -42,7 +42,7 @@ public abstract class AbstractLeakTest extends BuilderTests { static boolean LINUX; static boolean MAC; static boolean lsofCheckDone; - + static { String os = System.getProperty("os.name").toLowerCase(); WINDOWS = os.contains("windows"); @@ -168,12 +168,27 @@ public abstract class AbstractLeakTest extends BuilderTests { } private void checkOpenDescriptors(IFile file) throws Exception { + runGcAndFInalization(); List<String> processes = getProcessesOpenedFile(Paths.get(file.getLocation().toOSString())); if(!processes.isEmpty()) { - throw new IllegalStateException("File leaked during build: " + file); + runGcAndFInalization(); + Thread.sleep(5000); + processes = getProcessesOpenedFile(Paths.get(file.getLocation().toOSString())); + if(!processes.isEmpty()) { + throw new IllegalStateException("File leaked during build: " + file); + } } } + private void runGcAndFInalization() { + System.gc(); + System.runFinalization(); + System.gc(); + System.runFinalization(); + System.gc(); + System.runFinalization(); + } + private void selfTestLsof() throws Exception { Path tempFile = Files.createTempFile("testLsof", "tmp"); |