diff options
author | Vladimir Piskarev | 2022-12-06 17:01:53 +0000 |
---|---|---|
committer | Vladimir Piskarev | 2022-12-06 17:01:53 +0000 |
commit | 4382ac726c32d0f52a77d8188070752e9c308aa0 (patch) | |
tree | 8d4266e2fbd0dc2023f04d102aa89d54ce7cf78e | |
parent | 37a7a8c28559489458319557ae43fef090e6204f (diff) | |
download | org.eclipse.handly-4382ac726c32d0f52a77d8188070752e9c308aa0.tar.gz org.eclipse.handly-4382ac726c32d0f52a77d8188070752e9c308aa0.tar.xz org.eclipse.handly-4382ac726c32d0f52a77d8188070752e9c308aa0.zip |
Bug 581178 - Tests hang occasionally
-rw-r--r-- | org.eclipse.handly.junit/src/org/eclipse/handly/junit/WorkspaceTestCase.java | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/org.eclipse.handly.junit/src/org/eclipse/handly/junit/WorkspaceTestCase.java b/org.eclipse.handly.junit/src/org/eclipse/handly/junit/WorkspaceTestCase.java index f2fa9eb3..44501bb7 100644 --- a/org.eclipse.handly.junit/src/org/eclipse/handly/junit/WorkspaceTestCase.java +++ b/org.eclipse.handly.junit/src/org/eclipse/handly/junit/WorkspaceTestCase.java @@ -242,20 +242,33 @@ public abstract class WorkspaceTestCase { IJobManager jobManager = Job.getJobManager(); jobManager.suspend(); - boolean wasInterrupted; - do + jobManager.sleep(null); + join(jobManager); + } + + private static void join(IJobManager jobManager) + { + Job[] jobs = jobManager.find(null); + for (Job job : jobs) { - wasInterrupted = false; - try - { - jobManager.join(null, null); - } - catch (InterruptedException e) + if (!job.shouldSchedule()) + continue; // don't join implicit jobs (can hang!) + + boolean wasInterrupted; + do { - wasInterrupted = true; + wasInterrupted = false; + try + { + job.join(); + } + catch (InterruptedException e) + { + wasInterrupted = true; + } } + while (wasInterrupted); } - while (wasInterrupted); } /** @@ -266,7 +279,9 @@ public abstract class WorkspaceTestCase */ protected final void resumeJobs() { - Job.getJobManager().resume(); + IJobManager jobManager = Job.getJobManager(); + jobManager.resume(); + jobManager.wakeUp(null); } /* |