From 8e90b2c6f8f488a9ba124a24dd0a4ce5fa117305 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Thu, 13 May 2010 15:05:14 +0000 Subject: [PATCH] bug 311468: JUnit failure: ErrorParserFileMatchingTest - SymbolicLink finally, a fix --- .../cdt/core/testplugin/ResourceHelper.java | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java index b6fa1dad385..5c1c1729a1a 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java @@ -538,30 +538,16 @@ public class ResourceHelper { String command = "ln -s " + realPath.toOSString() + ' ' + linkedPath.toOSString(); Process process = Runtime.getRuntime().exec(command); + // Thread is not supposed to be in interrupted state here and it causes waitFor() to throw immediately Assert.assertFalse("Thread is in interrupted state", Thread.interrupted()); try { process.waitFor(); } catch (InterruptedException e) { - Assert.assertTrue("Command to create symbolic link was interrupted: "+e.getMessage(), - new File(linkedPath.toOSString()).exists()); - } - - if (!new File(linkedPath.toOSString()).exists()) { - // Not supposed to happen, trying to figure out what's going on - final int timeCount = 5; - for (int i=1;i<=timeCount;i++) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - if (new File(linkedPath.toOSString()).exists()) { - Assert.fail("Symbolic link created only after "+i+" seconds: [" + command +"]"); - break; - } - } - - Assert.fail("Symbolic link NOT created after "+timeCount+" seconds: [" + command +"]"); + } finally { + // Clear interrupted state, see Java bug http://bugs.sun.com/view_bug.do?bug_id=6420270 + Thread.interrupted(); } + Assert.assertTrue("Symbolic link not created, command=[" + command +"]", new File(linkedPath.toOSString()).exists()); IResource resource = project.getFile(linkName); resource.refreshLocal(IResource.DEPTH_ZERO, null);