Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2013-01-08 17:27:36 +0000
committerThomas Watson2013-01-08 17:27:36 +0000
commit24364566a53dd32f6d18a90a9505363c2c1ca5b2 (patch)
tree4476eee03fc40cd94d33b8fcb013167780b5d553
parent9c57652122e9ac8835c5a8d03f0a9fc0260920cb (diff)
downloadrt.equinox.bundles-24364566a53dd32f6d18a90a9505363c2c1ca5b2.tar.gz
rt.equinox.bundles-24364566a53dd32f6d18a90a9505363c2c1ca5b2.tar.xz
rt.equinox.bundles-24364566a53dd32f6d18a90a9505363c2c1ca5b2.zip
-rw-r--r--bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleFindHook.java23
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionServiceFindHook.java20
3 files changed, 27 insertions, 18 deletions
diff --git a/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF
index 5508b232a..ae5f6d3a1 100644
--- a/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.equinox.region
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.1.1.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.management,
org.eclipse.osgi.service.resolver;version="1.5.0";resolution:=optional,
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleFindHook.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleFindHook.java
index 3d09e62e6..f0aa2e139 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleFindHook.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleFindHook.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
+ * Copyright (c) 2013 VMware Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,14 +40,19 @@ public final class RegionBundleFindHook implements FindHook {
*/
@Override
public void find(BundleContext context, Collection<Bundle> bundles) {
- long bundleID = context.getBundle().getBundleId();
-
+ Bundle finderBundle = getBundle(context);
+ if (finderBundle == null) {
+ // invalid finder bundle; clear out result
+ bundles.clear();
+ return;
+ }
+ long bundleID = finderBundle.getBundleId();
if (bundleID == 0 || bundleID == hookImplID) {
// The system bundle and the hook impl bundle can see all bundles
return;
}
- Region finderRegion = getRegion(context);
+ Region finderRegion = this.regionDigraph.getRegion(finderBundle);
if (finderRegion == null) {
bundles.clear();
return;
@@ -81,10 +86,14 @@ public final class RegionBundleFindHook implements FindHook {
protected boolean isAllowed(Bundle candidate, RegionFilter filter) {
return filter.isAllowed(candidate);
}
-
}
- private Region getRegion(BundleContext context) {
- return this.regionDigraph.getRegion(context.getBundle());
+ static Bundle getBundle(BundleContext context) {
+ try {
+ return context.getBundle();
+ } catch (IllegalStateException e) {
+ // happens if the context is invalid
+ return null;
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionServiceFindHook.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionServiceFindHook.java
index 2eb7ea96d..2ee9d3c09 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionServiceFindHook.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionServiceFindHook.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
+ * Copyright (c) 2013 VMware Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,7 @@ package org.eclipse.equinox.internal.region.hook;
import java.util.Collection;
import org.eclipse.equinox.region.*;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
+import org.osgi.framework.*;
import org.osgi.framework.hooks.service.FindHook;
/**
@@ -37,11 +36,17 @@ public final class RegionServiceFindHook implements FindHook {
* {@inheritDoc}
*/
public void find(BundleContext context, String name, String filter, boolean allServices, Collection<ServiceReference<?>> references) {
- if (context.getBundle().getBundleId() == 0L) {
+ Bundle finderBundle = RegionBundleFindHook.getBundle(context);
+ if (finderBundle == null) {
+ // invalid finder bundle; clear out result
+ references.clear();
+ return;
+ }
+ if (finderBundle.getBundleId() == 0L) {
return;
}
- Region finderRegion = getRegion(context);
+ Region finderRegion = this.regionDigraph.getRegion(finderBundle);
if (finderRegion == null) {
references.clear();
return;
@@ -77,9 +82,4 @@ public final class RegionServiceFindHook implements FindHook {
}
}
-
- private Region getRegion(BundleContext context) {
- return this.regionDigraph.getRegion(context.getBundle());
- }
-
}

Back to the top