Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Duft2017-07-04 06:48:36 +0000
committerMarkus Duft2017-07-04 06:48:36 +0000
commit37849a2dc5e14ae4a58bdc5699b77466db1b0b0a (patch)
tree4ab9d0634b0c52608efc0dfae95a028906037df7
parent19f71fda3568e05b39ec569758d21f02c1e6ab3c (diff)
downloadeclipse.platform.debug-37849a2dc5e14ae4a58bdc5699b77466db1b0b0a.tar.gz
eclipse.platform.debug-37849a2dc5e14ae4a58bdc5699b77466db1b0b0a.tar.xz
eclipse.platform.debug-37849a2dc5e14ae4a58bdc5699b77466db1b0b0a.zip
LaunchGroup's .launch blocks until the awaited output is written. There is a chance that the thread is unable to set the 'finished' boolean to true before the test thread checks it. This can easily be reproduced with a breakpoint at 'finished.set' in the second thread. Change-Id: Iee056180a25e8078a6479bfef09de0359c78d298 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java
index c17d13078..8799b6f60 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java
@@ -273,8 +273,10 @@ public class LaunchGroupTests extends AbstractLaunchTest {
try {
// wait some time before causing the group to continue
Thread.sleep(2000);
- attachListener.getStream().write("TestOutput"); //$NON-NLS-1$
- finished.set(true);
+ synchronized (finished) {
+ attachListener.getStream().write("TestOutput"); //$NON-NLS-1$
+ finished.set(true);
+ }
} catch (Exception e) {
e.printStackTrace();
}
@@ -286,7 +288,12 @@ public class LaunchGroupTests extends AbstractLaunchTest {
// launching the group must block until the output is produced
grp.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- getLaunchManager().removeLaunchListener(attachListener);
+
+ synchronized (finished) {
+ // if the output appeared we have to wait for the thread to finish
+ // setting state.
+ getLaunchManager().removeLaunchListener(attachListener);
+ }
assertTrue("thread did not finish", finished.get()); //$NON-NLS-1$
assertTrue("output was not awaited", (System.currentTimeMillis() - start) >= 2000); //$NON-NLS-1$

Back to the top