Mark Payne created NIFI-6923:
--------------------------------
Summary: If FlowFile content is truncated in the Content
Repository, NiFi does not throw Exception when reading the content
Key: NIFI-6923
URL: https://issues.apache.org/jira/browse/NIFI-6923
Project: Apache NiFi
Issue Type: Bug
Components: Core Framework
Reporter: Mark Payne
If the content of a FlowFile is truncated in the Content Repository, whenever
NiFi attempts to read the content, it should throw a ContentNotFoundException
because only part of the content was available. This is handled by the
`FlowFileAccessInputStream` in the `ensureAllContentRead` method.
However, in some cases this doesn't happen. To replicate, create the following
flow:
GenerateFlowFile -> MergeContent.
In GenerateFlowFile, choose to use a batch size of 1000 FlowFiles, each 1 KB in
size. Run the Processor once. Then, use vi to truncate a few bytes from the end
of the file in the content repository. Then, run MergeContent. The processor
*should* throw an Exception but doesn't.
I think the problem is that the `FlowFileAccessInputStream.read(byte[])` calls
`super.read(byte[])`. This, in turn, calls
`FlowFileAccessInputStream.read(byte[], int, int)`, which increments
`bytesConsumed`. This method then returns, as does the super call. Then, the
`FlowFileAccessInputStream.read(byte[])` call increments `bytesConsumed` again.
Instead, the InputStream should just delegate to `read(byte[], int, int)`
directly when `read(byte[])` is called instead of delegating to
`super.read(byte[], int, int)`.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)