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

    https://github.com/apache/metron/pull/1213#discussion_r223885124
  
    --- Diff: 
metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/ParserRunnerImpl.java
 ---
    @@ -101,26 +92,28 @@ public void init(Supplier<ParserConfigurations> 
parserConfigSupplier, Context st
       }
     
       @Override
    -  public void execute(String sensorType, RawMessage rawMessage, 
ParserConfigurations parserConfigurations) {
    -    if (onSuccess == null) {
    -      throw new IllegalStateException("An onSuccess function must be set 
before parsing a message.");
    -    }
    -    if (onError == null) {
    -      throw new IllegalStateException("An onError function must be set 
before parsing a message.");
    -    }
    +  public List<ParserResult> execute(String sensorType, RawMessage 
rawMessage, ParserConfigurations parserConfigurations) {
    +    List<ParserResult> parserResults;
         SensorParserConfig sensorParserConfig = 
parserConfigurations.getSensorParserConfig(sensorType);
         if (sensorParserConfig != null) {
           MessageParser<JSONObject> parser = 
sensorToParserComponentMap.get(sensorType).getMessageParser();
           List<JSONObject> messages = 
parser.parseOptional(rawMessage.getMessage()).orElse(Collections.emptyList());
    -      messages.forEach(message -> processMessage(sensorType, message, 
rawMessage, parser, parserConfigurations));
    +      parserResults = messages.stream()
    +              .map(message -> processMessage(sensorType, message, 
rawMessage, parser, parserConfigurations))
    +              .filter(Optional::isPresent)
    --- End diff --
    
    I believe not present means the message was filtered out (our FilterClass 
mechanism).  Otherwise there will either be a message or error in the 
ParserResult.


---

Reply via email to