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

    https://github.com/apache/nifi/pull/2816#discussion_r202109378
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/syslog/Syslog5424RecordReader.java
 ---
    @@ -0,0 +1,114 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.nifi.syslog;
    +
    +import org.apache.nifi.serialization.MalformedRecordException;
    +import org.apache.nifi.serialization.RecordReader;
    +import org.apache.nifi.serialization.record.MapRecord;
    +import org.apache.nifi.serialization.record.Record;
    +import org.apache.nifi.serialization.record.RecordSchema;
    +import org.apache.nifi.syslog.attributes.SyslogAttributes;
    +import org.apache.nifi.syslog.events.Syslog5424Event;
    +import org.apache.nifi.syslog.parsers.StrictSyslog5424Parser;
    +import org.apache.nifi.util.StringUtils;
    +
    +import java.io.BufferedReader;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.InputStreamReader;
    +import java.nio.ByteBuffer;
    +import java.sql.Timestamp;
    +import java.time.Instant;
    +import java.time.format.DateTimeFormatter;
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +public class Syslog5424RecordReader implements RecordReader {
    +    private final BufferedReader reader;
    +    private RecordSchema schema;
    +    private final StrictSyslog5424Parser parser;
    +
    +    public Syslog5424RecordReader(StrictSyslog5424Parser parser, 
InputStream in, RecordSchema schema){
    +        this.reader = new BufferedReader(new InputStreamReader(in));
    +        this.schema = schema;
    +        this.parser = parser;
    +    }
    +
    +    @Override
    +    public Record nextRecord(boolean coerceTypes, boolean 
dropUnknownFields) throws IOException, MalformedRecordException {
    +        String line = reader.readLine();
    +
    +        if ( line == null || StringUtils.isBlank(line)) {
    --- End diff --
    
    Yea I also considered the idea of reading until a non-blank line or null, 
but then I thought about the case of something like ListenTCPRecord where the 
InputStream could be an unbounded stream over a socket, and you could 
potentially end up stuck inside the nextRecord method reading blank lines 
forever (unlikely of course).


---

Reply via email to