summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2012-06-22 15:38:56 (EDT)
committer John Arthorne2012-06-22 15:38:56 (EDT)
commitb8aff109797c8963222f0781daa84cea96e9b5ce (patch)
treee0189d7850a51af68a0e62dfb4eb44374445f041
parent12d0e833f1c78613384fdc32bd88cee6831f9fa2 (diff)
downloadeclipse.platform.runtime-b8aff109797c8963222f0781daa84cea96e9b5ce.zip
eclipse.platform.runtime-b8aff109797c8963222f0781daa84cea96e9b5ce.tar.gz
eclipse.platform.runtime-b8aff109797c8963222f0781daa84cea96e9b5ce.tar.bz2
Bug 375631 - [jobs] JobManager allows to schedule a job with invalid
rule
-rw-r--r--bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java7
-rw-r--r--tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF2
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java44
4 files changed, 53 insertions, 2 deletions
diff --git a/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF
index 703d606..ba9ec26 100644
--- a/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.jobs; singleton:=true
-Bundle-Version: 3.5.200.qualifier
+Bundle-Version: 3.5.300.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.core.internal.jobs;x-internal:=true,
diff --git a/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java b/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java
index f48f588..04a6a9f 100644
--- a/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java
+++ b/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java
@@ -1547,6 +1547,13 @@ public class JobManager implements IJobManager {
//null rule always valid
if (rule == null)
return;
+ if (rule instanceof MultiRule) {
+ ISchedulingRule[] children = ((MultiRule) rule).getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Assert.isLegal(children[i] != rule);
+ validateRule(children[i]);
+ }
+ }
//contains method must be reflexive
Assert.isLegal(rule.contains(rule));
//contains method must return false when given an unknown rule
diff --git a/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF b/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF
index 624ff5c..643f906 100644
--- a/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Core Tests Runtime
Bundle-SymbolicName: org.eclipse.core.tests.runtime; singleton:=true
-Bundle-Version: 3.8.0.qualifier
+Bundle-Version: 3.9.0.qualifier
Bundle-ClassPath: runtimetests.jar
Bundle-Activator: org.eclipse.core.tests.runtime.RuntimeTestsPlugin
Bundle-Vendor: Eclipse.org
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
index 414a04e..b8b3837 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java
@@ -1395,6 +1395,50 @@ public class IJobManagerTest extends AbstractJobManagerTest {
waitForCompletion();
}
+ /**
+ * Tests setting various kinds of invalid rules on jobs.
+ */
+ public void testSetInvalidRule() {
+ class InvalidRule implements ISchedulingRule {
+ public boolean isConflicting(ISchedulingRule rule) {
+ return false;
+ }
+
+ public boolean contains(ISchedulingRule rule) {
+ return false;
+ }
+ }
+
+ InvalidRule rule1 = new InvalidRule();
+ InvalidRule rule2 = new InvalidRule();
+ ISchedulingRule multi = MultiRule.combine(rule1, rule2);
+
+ Job job = new Job("job with invalid rule") {
+ protected IStatus run(IProgressMonitor monitor) {
+ return Status.OK_STATUS;
+ }
+ };
+
+ try {
+ job.setRule(rule1);
+ fail("invalid rule");
+ } catch (IllegalArgumentException e) {
+ //expected
+ }
+ try {
+ job.setRule(rule2);
+ fail("invalid rule");
+ } catch (IllegalArgumentException e) {
+ //expected
+ }
+ try {
+ job.setRule(multi);
+ fail("invalid rule");
+ } catch (IllegalArgumentException e) {
+ //expected
+ }
+ }
+
public void testSleep() {
TestJob job = new TestJob("ParentJob", 10, 100);
//sleeping a job that isn't scheduled should have no effect