Review Board 1.7.22


FLUME-1389: Flume gives opaque error if interceptor type not specified

Review Request #6086 - Created July 23, 2012 and submitted

Patrick Wendell
FLUME-1389
Reviewers
Flume
flume-git
This checks for an unspecified interceptor type and returns a clear exception. Prior to this patch, an NPE is thrown if an interceptor is not specified.

I'm not sure if this is the right place to do this type of validation or if interceptors should be included in the existing validation framework somehow.
I re-built flume and tested with a bad config and ensure the error was thrown.
flume-ng-core/src/main/java/org/apache/flume/channel/ChannelProcessor.java
Revision 53bfac1 New Change
[20] 97 lines
[+20] [+] private void configureInterceptors(Context context) {
98
    InterceptorBuilderFactory factory = new InterceptorBuilderFactory();
98
    InterceptorBuilderFactory factory = new InterceptorBuilderFactory();
99
    for (String interceptorName : interceptorNames) {
99
    for (String interceptorName : interceptorNames) {
100
      Context interceptorContext = new Context(
100
      Context interceptorContext = new Context(
101
          interceptorContexts.getSubProperties(interceptorName + "."));
101
          interceptorContexts.getSubProperties(interceptorName + "."));
102
      String type = interceptorContext.getString("type");
102
      String type = interceptorContext.getString("type");

    
   
103
      if (type == null) {

    
   
104
        LOG.error("Type not specified for interceptor " + interceptorName);

    
   
105
        throw new FlumeException("Interceptor.Type not specified for " +

    
   
106
          interceptorName);

    
   
107
      }
103
      try {
108
      try {
104
        Interceptor.Builder builder = factory.newInstance(type);
109
        Interceptor.Builder builder = factory.newInstance(type);
105
        builder.configure(interceptorContext);
110
        builder.configure(interceptorContext);
106
        interceptors.add(builder.build());
111
        interceptors.add(builder.build());
107
      } catch (ClassNotFoundException e) {
112
      } catch (ClassNotFoundException e) {
[+20] [20] 197 lines
  1. flume-ng-core/src/main/java/org/apache/flume/channel/ChannelProcessor.java: Loading...