storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [1/3] storm git commit: [STORM-1182] - Removing and wrapping some exceptions in ConfigValidation to make code cleaner
Date Fri, 06 Nov 2015 21:50:59 GMT
Repository: storm
Updated Branches:
  refs/heads/master 2ef095e2b -> 14c7defd5


[STORM-1182] - Removing and wrapping some exceptions in ConfigValidation to make code cleaner


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/34c7eb26
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/34c7eb26
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/34c7eb26

Branch: refs/heads/master
Commit: 34c7eb26e06db3d3fbcf7ded6664944c25a46a9e
Parents: 90edd94
Author: Boyang Jerry Peng <jerrypeng@yahoo-inc.com>
Authored: Thu Nov 5 15:57:38 2015 -0600
Committer: Boyang Jerry Peng <jerrypeng@yahoo-inc.com>
Committed: Thu Nov 5 16:12:34 2015 -0600

----------------------------------------------------------------------
 .../storm/validation/ConfigValidation.java      | 30 ++++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/34c7eb26/storm-core/src/jvm/backtype/storm/validation/ConfigValidation.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/validation/ConfigValidation.java b/storm-core/src/jvm/backtype/storm/validation/ConfigValidation.java
index 0190799..4e4a4f4 100644
--- a/storm-core/src/jvm/backtype/storm/validation/ConfigValidation.java
+++ b/storm-core/src/jvm/backtype/storm/validation/ConfigValidation.java
@@ -43,7 +43,7 @@ public class ConfigValidation {
     public static abstract class Validator {
         public Validator(Map<String, Object> params) {}
         public Validator() {}
-        public abstract void validateField(String name, Object o) throws InstantiationException,
IllegalAccessException, NoSuchMethodException, InvocationTargetException;
+        public abstract void validateField(String name, Object o);
     }
 
     /**
@@ -172,11 +172,10 @@ public class ConfigValidation {
     public static class ImpersonationAclUserEntryValidator extends Validator {
 
         @Override
-        public void validateField(String name, Object o) throws InstantiationException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException {
+        public void validateField(String name, Object o) {
             if (o == null) {
                 return;
             }
-            LOG.info("object: {}", o);
             ConfigValidationUtils.NestableFieldValidator validator = ConfigValidationUtils.mapFv(ConfigValidationUtils.fv(String.class,
false),
                     ConfigValidationUtils.listFv(String.class, false), false);
             validator.validateField(name, o);
@@ -319,9 +318,12 @@ public class ConfigValidation {
         }
 
         @Override
-        public void validateField(String name, Object o) throws InstantiationException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException {
-
-            validateField(name, this.entryValidators, o);
+        public void validateField(String name, Object o)  {
+            try {
+                validateField(name, this.entryValidators, o);
+            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
| InstantiationException e) {
+                throw new RuntimeException(e);
+            }
         }
 
         public static void validateField(String name, Class[] validators, Object o) throws
IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException
{
@@ -381,8 +383,12 @@ public class ConfigValidation {
         }
 
         @Override
-        public void validateField(String name, Object o) throws InstantiationException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException {
-            validateField(name, this.keyValidators, this.valueValidators, o);
+        public void validateField(String name, Object o) {
+            try {
+                validateField(name, this.keyValidators, this.valueValidators, o);
+            } catch (IllegalAccessException | InstantiationException | NoSuchMethodException
| InvocationTargetException e) {
+                throw new RuntimeException(e);
+            }
         }
 
         public static void validateField(String name, Class[] keyValidators, Class[] valueValidators,
Object o) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException
{
@@ -454,16 +460,16 @@ public class ConfigValidation {
     public static class MetricRegistryValidator extends Validator {
 
         @Override
-        public void validateField(String name, Object o) throws IllegalAccessException {
+        public void validateField(String name, Object o) {
             if(o == null) {
                 return;
             }
             SimpleTypeValidator.validateField(name, Map.class, o);
             if(!((Map) o).containsKey("class") ) {
-                throw new IllegalAccessException("Field " + name + " must have map entry
with key: class");
+                throw new IllegalArgumentException( "Field " + name + " must have map entry
with key: class");
             }
             if(!((Map) o).containsKey("parallelism.hint") ) {
-                throw new IllegalAccessException("Field " + name + " must have map entry
with key: parallelism.hint");
+                throw new IllegalArgumentException("Field " + name + " must have map entry
with key: parallelism.hint");
             }
 
             SimpleTypeValidator.validateField(name, String.class, ((Map) o).get("class"));
@@ -619,4 +625,4 @@ public class ConfigValidation {
         }
         return true;
     }
-}
+}
\ No newline at end of file


Mime
View raw message