Repository: brooklyn-server
Updated Branches:
  refs/heads/master 24ba999e3 -> f77b9f084


Delete bundle: handle pre-installed karaf bundles


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

Branch: refs/heads/master
Commit: 08d237466eff048c650ebb6b830ce5b1e2dffbcf
Parents: 96c3411
Author: Aled Sage <aled.s...@gmail.com>
Authored: Tue Nov 21 15:29:50 2017 +0000
Committer: Aled Sage <aled.s...@gmail.com>
Committed: Tue Nov 21 15:35:42 2017 +0000

----------------------------------------------------------------------
 .../brooklyn/core/mgmt/ha/OsgiManager.java      | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/08d23746/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
index 34b974a..db0c6b7 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
@@ -472,17 +472,17 @@ public class OsgiManager {
             }
             
             if (!leaveInOsgi) {
-                Bundle bundle = 
framework.getBundleContext().getBundle(bundleMetadata.getOsgiUniqueUrl());
-                result.bundle = bundle;
-                if (bundle==null) {
+                Maybe<Bundle> bundle = findBundle(bundleMetadata);
+                result.bundle = bundle.orNull();
+                if (bundle.isAbsent()) {
                     Exception e = new IllegalStateException("No such bundle 
installed in OSGi when uninstalling: "+bundleMetadata);
                     if (!force) Exceptions.propagate(e);
                     log.warn(e.getMessage());
                     errors.add(e);
                 } else {
                     try {
-                        bundle.stop();
-                        bundle.uninstall();
+                        bundle.get().stop();
+                        bundle.get().uninstall();
                     } catch (BundleException e) {
                         Exceptions.propagateIfFatal(e);
                         if (!force) Exceptions.propagate(e);
@@ -686,6 +686,16 @@ public class OsgiManager {
         }
     }
 
+    protected Maybe<Bundle> findBundle(ManagedBundle managedBundle) {
+        if (managedBundle.getOsgiUniqueUrl() != null) {
+            Bundle bundle = 
framework.getBundleContext().getBundle(managedBundle.getOsgiUniqueUrl());
+            if (bundle != null) {
+                return Maybe.of(bundle);
+            }
+        }
+        return findBundle((OsgiBundleWithUrl)managedBundle);
+    }
+    
     public Maybe<Bundle> findBundle(OsgiBundleWithUrl catalogBundle) {
         // Prefer OSGi Location as URL or the managed bundle recorded URL,
         // not bothering to check name:version if supplied here (eg to forgive 
snapshot version discrepancies);

Reply via email to