You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/09/30 07:25:32 UTC

[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1181: MINIFICPP-1650: ProcessSession::append sets the flowfile size

martinzink commented on a change in pull request #1181:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1181#discussion_r719129867



##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -269,14 +269,15 @@ void ProcessSession::append(const std::shared_ptr<core::FlowFile> &flow, OutputS
     }
     // Call the callback to write the content
 
-    size_t oldPos = stream->size();
+    size_t flow_file_size = flow->getSize();
+    size_t stream_size_before_callback = stream->size();
     // this prevents an issue if we write, above, with zero length.
-    if (oldPos > 0)
-      stream->seek(oldPos + 1);
+    if (stream_size_before_callback > 0)
+      stream->seek(stream_size_before_callback + 1);
     if (callback->process(stream) < 0) {
       throw Exception(FILE_OPERATION_EXCEPTION, "Failed to process flowfile content");
     }
-    flow->setSize(stream->size());
+    flow->setSize(flow_file_size - stream_size_before_callback + stream->size());

Review comment:
       The problem was that ContentSession::write with WriteMode::APPEND can give back a new stream which it will merge with the original stream later. However the flowfile size is only changed here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org