You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2015/05/29 16:53:52 UTC

[3/9] incubator-brooklyn git commit: EffectorUtils rethrows PropagatedRuntimeExceptions where possible

EffectorUtils rethrows PropagatedRuntimeExceptions where possible

Rather than wrapping in more PropagatedRuntimeExceptions


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

Branch: refs/heads/master
Commit: 5031d4f49ace3468db842b82297cd7cef679ad15
Parents: 7519476
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Thu May 14 19:47:34 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Fri May 29 14:38:52 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/management/internal/EffectorUtils.java     | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5031d4f4/core/src/main/java/brooklyn/management/internal/EffectorUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/EffectorUtils.java b/core/src/main/java/brooklyn/management/internal/EffectorUtils.java
index c14b98c..556ca23 100644
--- a/core/src/main/java/brooklyn/management/internal/EffectorUtils.java
+++ b/core/src/main/java/brooklyn/management/internal/EffectorUtils.java
@@ -259,8 +259,16 @@ public class EffectorUtils {
     }
 
     public static void handleEffectorException(Entity entity, Effector<?> effector, Throwable throwable) {
-        log.warn("Error invoking "+effector.getName()+" at "+entity+": "+Exceptions.collapseText(throwable));
-        throw new PropagatedRuntimeException("Error invoking "+effector.getName()+" at "+entity, throwable);
+        String message = "Error invoking " + effector.getName() + " at " + entity;
+        // Avoid throwing a PropagatedRuntimeException that just repeats the last PropagatedRuntimeException.
+        if (throwable instanceof PropagatedRuntimeException &&
+                throwable.getMessage() != null &&
+                throwable.getMessage().startsWith(message)) {
+            throw PropagatedRuntimeException.class.cast(throwable);
+        } else {
+            log.warn(message + ": " + Exceptions.collapseText(throwable));
+            throw new PropagatedRuntimeException(message, throwable);
+        }
     }
 
     public static <T> Task<T> invokeEffectorAsync(Entity entity, Effector<T> eff, Map<String,?> parameters) {