aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-11-02 05:39:59 (EDT)
committerGlyn Normington2011-11-02 05:39:59 (EDT)
commitd744d90b5565ac676fcccf3d5fdd35b7f057b3f4 (patch)
tree7dd641f9405d32b7fd615f72c7f3737b44e8a7fc
parent2c6cb5cd228abbce56e05f437e3132be4e92f19e (diff)
downloadrt.equinox.bundles-d744d90b5565ac676fcccf3d5fdd35b7f057b3f4.zip
rt.equinox.bundles-d744d90b5565ac676fcccf3d5fdd35b7f057b3f4.tar.gz
rt.equinox.bundles-d744d90b5565ac676fcccf3d5fdd35b7f057b3f4.tar.bz2
bug 361905: fix thread safety bug in setDefaultRegion and add synch block to getRegion(long) for symmetry with other methods which delegate to StandardBundleIdToRegionMapping
-rw-r--r--bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java2
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java11
2 files changed, 8 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java
index 170c6a0..1c13b2b 100644
--- a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java
+++ b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java
@@ -584,7 +584,7 @@ public class RegionSystemTests extends AbstractRegionSystemTest {
try {
digraph.setDefaultRegion(pp1Region);
assertFalse("IllegalArgumentException not thrown for setting non-existing region as default", true);
- } catch (IllegalArgumentException iae) {
+ } catch (IllegalStateException _) {
assertNull("DefaultRegion is not null", digraph.getDefaultRegion());
}
}
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java
index 80dabc3..4aaa2b1 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionDigraph.java
@@ -247,7 +247,9 @@ public final class StandardRegionDigraph implements BundleIdToRegionMapping, Reg
* {@inheritDoc}
*/
public Region getRegion(long bundleId) {
- return this.bundleIdToRegionMapping.getRegion(bundleId);
+ synchronized (this.monitor) {
+ return this.bundleIdToRegionMapping.getRegion(bundleId);
+ }
}
/**
@@ -484,10 +486,11 @@ public final class StandardRegionDigraph implements BundleIdToRegionMapping, Reg
*/
@Override
public void setDefaultRegion(Region defaultRegion) {
- if (this.regions.contains(defaultRegion) || defaultRegion == null) {
+ synchronized (this.monitor) {
+ if (defaultRegion != null) {
+ checkRegionExists(defaultRegion);
+ }
this.defaultRegion = defaultRegion;
- } else {
- throw new IllegalArgumentException("Can't set " + defaultRegion.toString() + " as default region. It isn't contained in this digraph."); //$NON-NLS-1$//$NON-NLS-2$
}
}