FLUME-1430: Exception should be thrown if we cannot instaniate an 
EventSerializer

(Patrick Wendell via Brock Noland)


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

Branch: refs/heads/cdh-1.2.0+24_intuit
Commit: 3a767b23ee2f3e3f8e5b5428da94a659ee219fe4
Parents: ce01ec1
Author: Brock Noland <[email protected]>
Authored: Tue Aug 14 13:48:12 2012 +0100
Committer: Mike Percy <[email protected]>
Committed: Fri Sep 7 14:03:05 2012 -0700

----------------------------------------------------------------------
 .../serialization/EventSerializerFactory.java      |   19 +++++++++-----
 1 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/3a767b23/flume-ng-core/src/main/java/org/apache/flume/serialization/EventSerializerFactory.java
----------------------------------------------------------------------
diff --git 
a/flume-ng-core/src/main/java/org/apache/flume/serialization/EventSerializerFactory.java
 
b/flume-ng-core/src/main/java/org/apache/flume/serialization/EventSerializerFactory.java
index 310f3ac..75853a9 100644
--- 
a/flume-ng-core/src/main/java/org/apache/flume/serialization/EventSerializerFactory.java
+++ 
b/flume-ng-core/src/main/java/org/apache/flume/serialization/EventSerializerFactory.java
@@ -21,6 +21,7 @@ package org.apache.flume.serialization;
 import com.google.common.base.Preconditions;
 import java.io.OutputStream;
 import org.apache.flume.Context;
+import org.apache.flume.FlumeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,12 +54,14 @@ public class EventSerializerFactory {
         if (c != null && EventSerializer.Builder.class.isAssignableFrom(c)) {
           builderClass = (Class<? extends EventSerializer.Builder>) c;
         } else {
-          logger.error("Unable to instantiate Builder from {}", 
serializerType);
-          return null;
+          String errMessage = "Unable to instantiate Builder from " +
+              serializerType;
+          logger.error(errMessage);
+          throw new FlumeException(errMessage);
         }
       } catch (ClassNotFoundException ex) {
         logger.error("Class not found: " + serializerType, ex);
-        return null;
+        throw new FlumeException(ex);
       }
     }
 
@@ -67,11 +70,13 @@ public class EventSerializerFactory {
     try {
       builder = builderClass.newInstance();
     } catch (InstantiationException ex) {
-      logger.error("Cannot instantiate builder: " + serializerType, ex);
-      return null;
+      String errMessage = "Cannot instantiate builder: " + serializerType;
+      logger.error(errMessage, ex);
+      throw new FlumeException(errMessage, ex);
     } catch (IllegalAccessException ex) {
-      logger.error("Cannot instantiate builder: " + serializerType, ex);
-      return null;
+      String errMessage = "Cannot instantiate builder: " + serializerType;
+      logger.error(errMessage, ex);
+      throw new FlumeException(errMessage, ex);
     }
 
     return builder.build(context, out);

Reply via email to