Repository: brooklyn-server
Updated Branches:
  refs/heads/master 3bb69b608 -> 3451d4c20


Sanitize effector parameters when reporting an exception


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

Branch: refs/heads/master
Commit: 3c0c8af2d591b6026945dd112f55450dbc752947
Parents: 2f23bd2
Author: Valentin Aitken <bos...@gmail.com>
Authored: Fri Jun 10 17:25:46 2016 +0300
Committer: Valentin Aitken <bos...@gmail.com>
Committed: Fri Jun 10 17:25:46 2016 +0300

----------------------------------------------------------------------
 .../core/mgmt/internal/EffectorUtils.java       | 21 +++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c0c8af2/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java
index d5cde94..f340041 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java
@@ -72,9 +72,9 @@ public class EffectorUtils {
         if (args instanceof Map) {
             return prepareArgsForEffectorFromMap(eff, (Map) args);
         }
-        log.warn("Deprecated effector invocation style for call to "+eff+", 
expecting a map or an array, got: "+args);
+        log.warn("Deprecated effector invocation style for call to "+eff+", 
expecting a map or an array, got: "+sanitizeArgs(args));
         if (log.isDebugEnabled()) {
-            log.debug("Deprecated effector invocation style for call to 
"+eff+", expecting a map or an array, got: "+args,
+            log.debug("Deprecated effector invocation style for call to 
"+eff+", expecting a map or an array, got: "+sanitizeArgs(args),
                 new Throwable("Trace for deprecated effector invocation 
style"));
         }
         return oldPrepareArgsForEffector(eff, args);
@@ -144,16 +144,16 @@ public class EffectorUtils {
                 //finally, default values are used to make up for missing 
parameters
                 v = ((BasicParameterType)it).getDefaultValue();
             } else {
-                throw new IllegalArgumentException("Invalid arguments (missing 
argument "+it+") for effector "+eff+": "+m);
+                throw new IllegalArgumentException("Invalid arguments (missing 
argument "+it+") for effector "+eff+": "+Sanitizer.sanitize(m));
             }
 
             newArgs.add(TypeCoercions.coerce(v, it.getParameterClass()));
             newArgsNeeded--;
         }
         if (newArgsNeeded>0)
-            throw new IllegalArgumentException("Invalid arguments (missing 
"+newArgsNeeded+") for effector "+eff+": "+m);
+            throw new IllegalArgumentException("Invalid arguments (missing 
"+newArgsNeeded+") for effector "+eff+": "+Sanitizer.sanitize(m));
         if (!m.isEmpty()) {
-            log.warn("Unsupported parameter to "+eff+" (ignoring): "+m);
+            log.warn("Unsupported parameter to "+eff+" (ignoring): 
"+Sanitizer.sanitize(m));
         }
         return newArgs.toArray(new Object[newArgs.size()]);
     }
@@ -219,19 +219,19 @@ public class EffectorUtils {
                 //finally, default values are used to make up for missing 
parameters
                 newArgs.add(((BasicParameterType)it).getDefaultValue());
             } else {
-                throw new IllegalArgumentException("Invalid arguments (count 
mismatch) for effector "+eff+": "+args);
+                throw new IllegalArgumentException("Invalid arguments (count 
mismatch) for effector "+eff+": "+sanitizeArgs(args));
             }
 
             newArgsNeeded--;
         }
         if (newArgsNeeded > 0) {
-            throw new IllegalArgumentException("Invalid arguments (missing 
"+newArgsNeeded+") for effector "+eff+": "+args);
+            throw new IllegalArgumentException("Invalid arguments (missing 
"+newArgsNeeded+") for effector "+eff+": "+sanitizeArgs(args));
         }
         if (!l.isEmpty()) {
-            throw new IllegalArgumentException("Invalid arguments 
("+l.size()+" extra) for effector "+eff+": "+args);
+            throw new IllegalArgumentException("Invalid arguments 
("+l.size()+" extra) for effector "+eff+": "+sanitizeArgs(args));
         }
         if (truth(m) && !mapUsed) {
-            throw new IllegalArgumentException("Invalid arguments 
("+m.size()+" extra named) for effector "+eff+": "+args);
+            throw new IllegalArgumentException("Invalid arguments 
("+m.size()+" extra named) for effector "+eff+": "+sanitizeArgs(args));
         }
         return newArgs.toArray(new Object[newArgs.size()]);
     }
@@ -393,4 +393,7 @@ public class EffectorUtils {
                 .build();
     }
 
+    private static Object sanitizeArgs(Object args) {
+        return args instanceof Map ? Sanitizer.sanitize((Map)args) : args;
+    }
 }

Reply via email to