Github user mmiklavc commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/136#discussion_r64726176
  
    --- Diff: 
metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/bolt/ParserBolt.java
 ---
    @@ -61,18 +62,32 @@ public void prepare(Map stormConf, TopologyContext 
context, OutputCollector coll
         this.collector = collector;
         parser.init();
         writer.init();
    +    SensorParserConfig config = 
getConfigurations().getSensorParserConfig(sensorType);
    +    if(config != null) {
    +      config.init();
    +    }
       }
     
       @SuppressWarnings("unchecked")
       @Override
       public void execute(Tuple tuple) {
         byte[] originalMessage = tuple.getBinary(0);
    +    SensorParserConfig sensorParserConfig = 
configurations.getSensorParserConfig(sensorType);
         try {
           List<JSONObject> messages = parser.parse(originalMessage);
           for(JSONObject message: messages) {
             if (parser.validate(message)) {
               if (filter != null && filter.emitTuple(message)) {
                 message.put(Constants.SENSOR_TYPE, sensorType);
    +            List<MappingHandler> fieldMappings = sensorParserConfig == 
null?null:sensorParserConfig.getFieldMappings();
    --- End diff --
    
    If I'm interpreting correctly, 
org.apache.metron.common.configuration.SensorParserConfig won't vary with this 
implementation (i.e. not a user-provided impl). That said, I believe 
`sensorParserConfig.getFieldMappings()` should always return a non-null 
`List<MappingHandler>` (per the default init in that class -> `fieldMappings = 
new ArrayList<>()`)
    Maybe simplify line 82-84 to this?
    ```
    if(sensorParserConfig != null) {
      for(MappingHandler handler: sensorParserConfig.getFieldMappings()) {
    ...
      }
    }
    ```
    Also, might be worth a small test to see if line 85 handler null check can 
also go away.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to