@Override public Record nextRecord(boolean coerceTypes, boolean dropUnknownFields) throws IOException, MalformedRecordException { String line = reader.readLine(); if ( line == null ) { // a null return from readLine() signals the end of the stream return null; } if (StringUtils.isBlank(line)) { // while an empty string is an error throw new MalformedRecordException("Encountered a blank message!"); } final MalformedRecordException malformedRecordException; Syslog5424Event event = parser.parseEvent(ByteBuffer.wrap(line.getBytes(parser.getCharsetName()))); if (!event.isValid()) { if (event.getException() != null) { malformedRecordException = new MalformedRecordException( String.format("Failed to parse %s as a Syslog message: it does not conform to any of the RFC "+ "formats supported", line), event.getException()); } else { malformedRecordException = new MalformedRecordException( String.format("Failed to parse %s as a Syslog message: it does not conform to any of the RFC" + " formats supported", line)); } throw malformedRecordException; } Map<String,Object> modifiedMap = new HashMap<>(event.getFieldMap()); modifiedMap.put(SyslogAttributes.TIMESTAMP.key(),convertTimeStamp((String)event.getFieldMap().get(SyslogAttributes.TIMESTAMP.key()))); return new MapRecord(schema,modifiedMap); }
if (syslogEvent == null || !syslogEvent.isValid()) { getLogger().error("Failed to parse {} as a Syslog message: it does not conform to any of the RFC formats supported; routing to failure", new Object[] {flowFile}); session.transfer(flowFile, REL_FAILURE);
if (syslogEvent == null || !syslogEvent.isValid()) { getLogger().error("Failed to parse {} as a Syslog message: it does not conform to any of the RFC formats supported; routing to failure", new Object[] {flowFile}); session.transfer(flowFile, REL_FAILURE);