diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java index 014acab03e1..8681a2ba4ec 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java @@ -2847,12 +2847,11 @@ private static Set> getPropertiesSafe() { private static List getOpenedDescriptors() { List paths = new ArrayList<>(); Path fd = Paths.get("/proc/self/fd/"); - try(DirectoryStream directoryStream = Files.newDirectoryStream(fd)){ - directoryStream.forEach(f -> { - try { - paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString()); - } catch (IOException e) { - e.printStackTrace(); + try (DirectoryStream directoryStream = Files.newDirectoryStream(fd)) { + directoryStream.forEach(path -> { + String resolvedPath = resolveSymLink(path); + if (isTestRelatedFileDescriptor(resolvedPath)) { + paths.add(resolvedPath); } }); } catch (IOException e1) { @@ -2865,6 +2864,22 @@ private static List getOpenedDescriptors() { return paths; } +private static boolean isTestRelatedFileDescriptor(String fileDescriptorPath) { + // Do not consider file descriptors of Maven artifacts that are currently opened + // by other Maven plugins executed in parallel build (such as parallel + // compilation of the swt.tools bundle etc.) + return fileDescriptorPath != null && !fileDescriptorPath.contains(".m2") + && !fileDescriptorPath.contains("target/classes"); +} + +private static String resolveSymLink(Path path) { + try { + return Files.isSymbolicLink(path) ? Files.readSymbolicLink(path).toString() : path.toString(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; +} private static void processUiEvents() { Display display = Display.getCurrent();