Joe Witt created NIFI-16311:
-------------------------------
Summary: ParseSyslog initializes SyslogParser unsafely under
concurrent tasks
Key: NIFI-16311
URL: https://issues.apache.org/jira/browse/NIFI-16311
Project: Apache NiFi
Issue Type: Bug
Components: Extensions
Reporter: Joe Witt
Assignee: Joe Witt
ParseSyslog keeps a SyslogParser in a non-volatile instance field and lazily
constructs it inside onTrigger:
if (parser == null || !parser.getCharsetName().equals(charsetName)) {
parser = new SyslogParser(Charset.forName(charsetName));
}
NiFi uses a single processor instance for all concurrent tasks, so this is an
unsynchronized check-then-act. A second thread can observe a non-null parser
whose charset has not been published, or two threads can replace the field
while parseEvent is running.
The Character Set property does not support Expression Language, so its value
cannot change between triggers. The per-trigger re-init is unnecessary.
ParseSyslog5424 already does this correctly: it builds the parser in
@OnScheduled and stores it in a volatile field.
This ticket is only that lifecycle/concurrency fix. It does not change parsing,
relationships, or how FlowFile content is read.
Expected:
- SyslogParser is created once when the processor is scheduled
- Concurrent tasks share a safely published, immutable-for-the-run parser
- Existing RFC3164/RFC5424 parse tests still pass
- A TestRunner test with concurrent tasks succeeds
Actual:
- Parser construction races in onTrigger when Concurrent Tasks > 1
--
This message was sent by Atlassian Jira
(v8.20.10#820010)