Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master de67eb0cd -> 9c120ac79


Include invalid bundle URL in exception


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4acb6ea8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4acb6ea8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4acb6ea8

Branch: refs/heads/master
Commit: 4acb6ea817d25b04b217b6bee258602e258c1e82
Parents: d0cbcf3
Author: Svetoslav Neykov <[email protected]>
Authored: Fri May 8 22:40:41 2015 +0300
Committer: Svetoslav Neykov <[email protected]>
Committed: Mon May 11 09:36:11 2015 +0300

----------------------------------------------------------------------
 .../src/main/java/brooklyn/management/ha/OsgiManager.java | 10 +++++-----
 core/src/main/java/brooklyn/util/osgi/Osgis.java          |  3 +++
 .../camp/brooklyn/catalog/CatalogYamlEntityTest.java      |  6 +++---
 3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4acb6ea8/core/src/main/java/brooklyn/management/ha/OsgiManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/OsgiManager.java 
b/core/src/main/java/brooklyn/management/ha/OsgiManager.java
index d699da3..6444439 100644
--- a/core/src/main/java/brooklyn/management/ha/OsgiManager.java
+++ b/core/src/main/java/brooklyn/management/ha/OsgiManager.java
@@ -124,9 +124,9 @@ public class OsgiManager {
             Bundle b = Osgis.install(framework, bundle.getUrl());
 
             checkCorrectlyInstalled(bundle, b);
-        } catch (BundleException e) {
-            log.debug("Bundle from "+bundle+" failed to install (rethrowing): 
"+e);
-            throw Throwables.propagate(e);
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            throw new IllegalStateException("Bundle from "+bundle.getUrl()+" 
failed to install: " + e.getMessage(), e);
         }
     }
 
@@ -134,7 +134,7 @@ public class OsgiManager {
         String nv = b.getSymbolicName()+":"+b.getVersion().toString();
 
         if (!isBundleNameEqualOrAbsent(bundle, b)) {
-            throw new IllegalStateException("Bundle from "+bundle.getUrl()+" 
already installed as "+nv+" but user explicitly requested "+bundle);
+            throw new IllegalStateException("Bundle already installed as 
"+nv+" but user explicitly requested "+bundle);
         }
 
         List<Bundle> matches = Osgis.bundleFinder(framework)
@@ -161,7 +161,7 @@ public class OsgiManager {
                 Bundle b = installedBundle.get();
                 String nv = b.getSymbolicName()+":"+b.getVersion().toString();
                 if (!isBundleNameEqualOrAbsent(bundle, b)) {
-                    throw new IllegalStateException("Bundle from 
"+bundle.getUrl()+" already installed as "+nv+" but user explicitly requested 
"+bundle);
+                    throw new IllegalStateException("User requested bundle " + 
bundle + " but already installed as "+nv);
                 } else {
                     log.trace("Bundle from "+bundleUrl+" already installed as 
"+nv+"; not re-registering");
                 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4acb6ea8/core/src/main/java/brooklyn/util/osgi/Osgis.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/osgi/Osgis.java 
b/core/src/main/java/brooklyn/util/osgi/Osgis.java
index 4fe25f9..de49b2d 100644
--- a/core/src/main/java/brooklyn/util/osgi/Osgis.java
+++ b/core/src/main/java/brooklyn/util/osgi/Osgis.java
@@ -593,6 +593,9 @@ public class Osgis {
         }
         Manifest manifest = stream.getManifest();
         Streams.closeQuietly(stream);
+        if (manifest == null) {
+            throw new IllegalStateException("Missing manifest file in bundle 
or not a jar file.");
+        }
         String versionedId = getVersionedId(manifest);
         for (Bundle installedBundle : 
framework.getBundleContext().getBundles()) {
             if (versionedId.equals(getVersionedId(installedBundle))) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4acb6ea8/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
index 1e321dc..b0afede 100644
--- 
a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
+++ 
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
@@ -399,7 +399,7 @@ public class CatalogYamlEntityTest extends AbstractYamlTest 
{
                 "- type: " + SIMPLE_ENTITY_TYPE);
             fail();
         } catch (IllegalStateException e) {
-            Assert.assertEquals(e.getMessage(), "Bundle 
CatalogBundleDto{symbolicName=" + nonExistentId + ", version=" + 
nonExistentVersion + ", url=null} not previously registered, but URL is 
empty.");
+            Assert.assertEquals(e.getMessage(), "Bundle from null failed to 
install: Bundle CatalogBundleDto{symbolicName=" + nonExistentId + ", version=" 
+ nonExistentVersion + ", url=null} not previously registered, but URL is 
empty.");
         }
     }
 
@@ -479,8 +479,8 @@ public class CatalogYamlEntityTest extends AbstractYamlTest 
{
                 "- type: " + SIMPLE_ENTITY_TYPE);
             fail();
         } catch (IllegalStateException e) {
-            assertEquals(e.getMessage(), "Bundle from " + 
OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL + " already " +
-                    "installed as " + 
OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_NAME + ":" +
+            assertEquals(e.getMessage(), "Bundle from " + 
OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL + " failed to install: " +
+                    "Bundle already installed as " + 
OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_NAME + ":" +
                     OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_VERSION + " 
but user explicitly requested " +
                     "CatalogBundleDto{symbolicName=" + nonExistentId + ", 
version=" + nonExistentVersion + ", url=" +
                     OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL + "}");

Reply via email to