Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-08-11 16:10:42 +0000
committerThomas Watson2016-08-11 16:15:32 +0000
commit4d483b30c4fd75279878065b2bf72d0b1256a2b1 (patch)
tree4f95bbd64d006eccd8f7584c83b67affc703497a
parent79ffdde918f9fd9527bb4fa465fa7991f4736dea (diff)
downloadrt.equinox.bundles-4d483b30c4fd75279878065b2bf72d0b1256a2b1.tar.gz
rt.equinox.bundles-4d483b30c4fd75279878065b2bf72d0b1256a2b1.tar.xz
rt.equinox.bundles-4d483b30c4fd75279878065b2bf72d0b1256a2b1.zip
Bug 499552 - [region] NPE can happen in RegionServiceFindHook when
ServiceEvent points to a SerivceReference that has been unregistered Change-Id: Ia73d822f1d082868dda72f2c4c116c7c343ae93b Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/internal/tests/hook/RegionServiceFindHookTests.java45
-rw-r--r--bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.region/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java5
-rw-r--r--bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionServiceFindHook.java5
5 files changed, 53 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/internal/tests/hook/RegionServiceFindHookTests.java b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/internal/tests/hook/RegionServiceFindHookTests.java
index dfe0fce5..91f87964 100644
--- a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/internal/tests/hook/RegionServiceFindHookTests.java
+++ b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/internal/tests/hook/RegionServiceFindHookTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 VMware Inc.
+ * Copyright (c) 2011, 2015 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
@@ -105,6 +105,49 @@ public class RegionServiceFindHookTests {
}
@Test
+ public void testFindUnregisteredService() throws InvalidSyntaxException, BundleException {
+ ServiceReference<Object> ref = new ServiceReference<Object>() {
+
+ @Override
+ public Object getProperty(String key) {
+ return null;
+ }
+
+ @Override
+ public String[] getPropertyKeys() {
+ return new String[0];
+ }
+
+ @Override
+ public Bundle getBundle() {
+ return null;
+ }
+
+ @Override
+ public Bundle[] getUsingBundles() {
+ return null;
+ }
+
+ @Override
+ public boolean isAssignableTo(Bundle bundle, String className) {
+ return false;
+ }
+
+ @Override
+ public int compareTo(Object reference) {
+ return 1;
+ }
+ };
+ this.candidates.add(ref);
+
+ RegionFilter filter = createFilter(BUNDLE_B);
+ region(REGION_A).connectRegion(region(REGION_B), filter);
+
+ this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
+ assertFalse(this.candidates.contains(ref));
+ }
+
+ @Test
public void testFindInDisconnectedRegion() {
this.candidates.add(serviceReference(BUNDLE_B));
this.bundleFindHook.find(bundleContext(BUNDLE_A), "", "", false, this.candidates);
diff --git a/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF
index 2166381e..222964e6 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.3.0.qualifier
+Bundle-Version: 1.3.100.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Fragment-Host: system.bundle
ExtensionBundle-Activator: org.eclipse.equinox.internal.region.RegionManager
diff --git a/bundles/org.eclipse.equinox.region/pom.xml b/bundles/org.eclipse.equinox.region/pom.xml
index e2009a77..6a9a84de 100644
--- a/bundles/org.eclipse.equinox.region/pom.xml
+++ b/bundles/org.eclipse.equinox.region/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.region</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.3.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java
index 9b99faf6..ab8a6186 100644
--- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java
+++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 VMware Inc and others.
+ * Copyright (c) 2011, 2016 VMware Inc and others.
* 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
@@ -35,6 +35,9 @@ public final class StandardRegionFilter implements RegionFilter {
}
public boolean isAllowed(Bundle bundle) {
+ if (bundle == null) {
+ return false;
+ }
HashMap<String, Object> attrs = new HashMap<String, Object>(4);
String bsn = bundle.getSymbolicName();
if (bsn != 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 c8fb1c4a..e12175a5 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) 2015 VMware Inc.
+ * Copyright (c) 2015, 2016 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
@@ -74,7 +74,8 @@ public final class RegionServiceFindHook implements FindHook {
*/
@Override
protected boolean contains(Region region, ServiceReference<?> candidate) {
- return region.contains(candidate.getBundle());
+ Bundle b = candidate.getBundle();
+ return b == null ? false : region.contains(b);
}
/**

Back to the top