Updated Branches:
  refs/heads/trunk 716b1e2d3 -> e01403004

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/e0140300
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/e0140300
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/e0140300

Branch: refs/heads/trunk
Commit: e01403004af5aa5964f1df3312549c7bb9e2c686
Parents: 716b1e2
Author: Brock Noland <[email protected]>
Authored: Tue Aug 14 13:48:12 2012 +0100
Committer: Brock Noland <[email protected]>
Committed: Tue Aug 14 13:48:12 2012 +0100

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


http://git-wip-us.apache.org/repos/asf/flume/blob/e0140300/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