Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2020-05-20 10:18:38 -0400
committerAndrey Loskutov2020-05-20 10:18:38 -0400
commit8767458107de1a7d57e3c050b80cbc7196b54be7 (patch)
tree045017bd4b9f8d075e961c47985b699337c6f040
parent52605209658b93177a2cd8f1de09dbb940059695 (diff)
downloadeclipse.jdt.core-I20200524-1800.tar.gz
eclipse.jdt.core-I20200524-1800.tar.xz
eclipse.jdt.core-I20200524-1800.zip
Who knows what all this new docker infra is doingm nay be they don't have the /proc/self/stat or it is not accessible or ... Whatever, just use RuntimeMXBean, that *seem* to work. Change-Id: I3ea5ec96163c3ac67f5d5d584a1d90d0d74fed8c Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java28
1 files changed, 13 insertions, 15 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 f851fd1696..31d324d590 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
@@ -14,14 +14,12 @@
package org.eclipse.jdt.core.tests.builder;
import java.io.BufferedReader;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -168,21 +166,21 @@ public abstract class AbstractLeakTest extends BuilderTests {
private static List<String> getOpenDescriptors() throws Exception {
int pid = getPid();
- if (pid > 0) {
- // -F n : to print only name column (note: all lines start with "n")
- // -a : to "and" all following options
- // -b :to avoid blocking calls
- // -p <pid>: to select process with opened files
- List<String> lines = readLsofLines("lsof -F n -a -p " + pid + " / -b ", true);
- return lines;
- }
- return Collections.emptyList();
+ assertTrue("JVM PID must be > 0 : " + pid, pid > 0);
+ // -F n : to print only name column (note: all lines start with "n")
+ // -a : to "and" all following options
+ // -b :to avoid blocking calls
+ // -p <pid>: to select process with opened files
+ List<String> lines = readLsofLines("lsof -F n -a -p " + pid + " / -b ", true);
+ return lines;
}
private static int getPid() throws Exception {
- try (BufferedReader rdr = new BufferedReader(new FileReader("/proc/self/stat"));) {
- return Integer.parseInt(new StringTokenizer(rdr.readLine()).nextToken());
- }
+ String jvmName = ManagementFactory.getRuntimeMXBean().getName();
+ int indexOfAt = jvmName.indexOf('@');
+ String pidSubstring = jvmName.substring(0, indexOfAt);
+ int pid = Integer.valueOf(pidSubstring);
+ return pid;
}
private static List<String> readLsofLines(String cmd, boolean skipFirst) throws Exception {

Back to the top