BrooklynYamlLocationResolver: don’t swallow exception

Previously inresolveLocation() we were just getting the “collapseText”
of the exception in the thrown toString, rather than having the
cause set. This meant that the underlying cause (e.g. of an NPE etc)
was never being logged.

Instead, set the cause when throwing the the IllegalStateException,
as well as having the nice toString.


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

Branch: refs/heads/master
Commit: 43beb54c29a093e0c96268c1a9fd6ca16101a231
Parents: 7fd92be
Author: Aled Sage <[email protected]>
Authored: Fri Jun 26 14:49:02 2015 +0100
Committer: Aled Sage <[email protected]>
Committed: Thu Jul 2 17:20:19 2015 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/spi/creation/BrooklynYamlLocationResolver.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/43beb54c/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlLocationResolver.java
----------------------------------------------------------------------
diff --git 
a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlLocationResolver.java
 
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlLocationResolver.java
index d9f7a65..3495687 100644
--- 
a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlLocationResolver.java
+++ 
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlLocationResolver.java
@@ -134,7 +134,9 @@ public class BrooklynYamlLocationResolver {
         
         Maybe<Location> l = mgmt.getLocationRegistry().resolve(spec, null, 
flags);
         if (l.isPresent()) return l.get();
+        
+        RuntimeException exception = ((Absent<?>)l).getException();
         throw new IllegalStateException("Illegal parameter for 'location' 
("+spec+"); not resolvable: "+
-            Exceptions.collapseText( ((Absent<?>)l).getException() ));
+            Exceptions.collapseText( exception ), exception);
     }
 }

Reply via email to