diff options
author | John Arthorne | 2004-06-16 15:37:15 +0000 |
---|---|---|
committer | John Arthorne | 2004-06-16 15:37:15 +0000 |
commit | 7fab885fe0050c1cf6a3ab03d9441d7ed1276143 (patch) | |
tree | 5b3b706740d1f63537b071f8364e7ad90a53a48b | |
parent | 533f3ce49c062e72d968d14ebda4d6e16c698ccc (diff) | |
download | eclipse.platform.runtime-7fab885fe0050c1cf6a3ab03d9441d7ed1276143.tar.gz eclipse.platform.runtime-7fab885fe0050c1cf6a3ab03d9441d7ed1276143.tar.xz eclipse.platform.runtime-7fab885fe0050c1cf6a3ab03d9441d7ed1276143.zip |
Bug 66707 Illegal rule push incorrectly reported as mismatched endRule
2 files changed, 31 insertions, 2 deletions
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/ImplicitJobs.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/ImplicitJobs.java index 0a61723ce..b37d70b77 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/ImplicitJobs.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/jobs/ImplicitJobs.java @@ -75,9 +75,9 @@ class ImplicitJobs { //indicate if it is a system job to ensure isBlocking works correctly threadJob.setRealJob(realJob); threadJob.setThread(currentThread); - threadJob.push(rule); } try { + threadJob.push(rule); //join the thread job outside sync block if (threadJob.acquireRule) { //no need to reaquire any locks because the thread did not wait to get this lock diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java index d270a1a10..4d2b58836 100644 --- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java +++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java @@ -334,6 +334,35 @@ public class BeginEndRuleTest extends AbstractJobManagerTest { manager.endRule(rule1); } + /** + * Tests create a job with one scheduling rule, and then attempting + * to acquire an unrelated rule from within that job. + */ + public void testFailedNestRuleInJob() { + final ISchedulingRule rule1 = new PathRule("/testFailedNestRuleInJob/A/"); + final ISchedulingRule rule2 = new PathRule("/testFailedNestRuleInJob/B/"); + final Exception[] exception = new Exception[1]; + Job job = new Job("testFailedNestRuleInJob") { + protected IStatus run(IProgressMonitor monitor) { + try { + try { + manager.beginRule(rule2, monitor); + } finally { + manager.endRule(rule2); + } + } catch (RuntimeException e) { + exception[0] = e; + } + return Status.OK_STATUS; + } + }; + job.setRule(rule1); + job.schedule(); + waitForEnd(job); + assertTrue("1.0", exception[0] != null); + assertTrue("1.1", exception[0].getMessage().indexOf("does not match outer scope rule") > 0); + } + public void testNestedCase() { ISchedulingRule rule1 = new PathRule("/testNestedCase"); ISchedulingRule rule2 = new PathRule("/testNestedCase/B"); @@ -554,7 +583,7 @@ public class BeginEndRuleTest extends AbstractJobManagerTest { */ private void waitForEnd(Job job) { int i = 0; - while (job.getState() == Job.RUNNING) { + while (job.getState() != Job.NONE) { Thread.yield(); try { Thread.sleep(100); |