brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [22/50] brooklyn-server git commit: Use FrameworkLookup class to get the bundle context.
Date Wed, 30 Mar 2016 13:59:59 GMT
Use FrameworkLookup class to get the bundle context.

Necessary to avoid NPE at line 135 and 160 if the class being looked up is in a bundle that
hasn't started yet.
We don't really need to get the bundle context from that class, any suitable one will do,
and we know that
the bundle we live in has started!


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/71d5a108
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/71d5a108
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/71d5a108

Branch: refs/heads/master
Commit: 71d5a1083f250ac419cdb34b139ba62abef1bd4d
Parents: 630eb64
Author: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Authored: Fri Mar 18 16:41:26 2016 +0000
Committer: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Committed: Fri Mar 18 16:41:26 2016 +0000

----------------------------------------------------------------------
 .../java/org/apache/brooklyn/api/framework/FrameworkLookup.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/71d5a108/api/src/main/java/org/apache/brooklyn/api/framework/FrameworkLookup.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/framework/FrameworkLookup.java b/api/src/main/java/org/apache/brooklyn/api/framework/FrameworkLookup.java
index 898f043..c2d68c4 100644
--- a/api/src/main/java/org/apache/brooklyn/api/framework/FrameworkLookup.java
+++ b/api/src/main/java/org/apache/brooklyn/api/framework/FrameworkLookup.java
@@ -129,7 +129,7 @@ public class FrameworkLookup {
 
     private static <T> Iterable<T> lookupAllInOsgi(Class<T> clazz) {
         final List<T> result = new ArrayList<>();
-        final Bundle bundle = FrameworkUtil.getBundle(clazz);
+        final Bundle bundle = FrameworkUtil.getBundle(FrameworkLookup.class);
         if (bundle != null) {
             LOG.debug("Looking up all " + clazz.getSimpleName() + " in OSGI");
             BundleContext ctx = bundle.getBundleContext();
@@ -154,7 +154,7 @@ public class FrameworkLookup {
     private static <T> Maybe<T> lookupInOsgi(Class<T> clazz) {
         Maybe<T> result = Maybe.absent("No class " + clazz.getSimpleName() + " found
with OSGI");
 
-        final Bundle bundle = FrameworkUtil.getBundle(clazz);
+        final Bundle bundle = FrameworkUtil.getBundle(FrameworkLookup.class);
         if (bundle != null) {
             LOG.debug("Looking up " + clazz.getSimpleName() + " in OSGI");
             BundleContext ctx = bundle.getBundleContext();


Mime
View raw message