bakaid commented on a change in pull request #596: MINIFICPP-925 - Fix TailFile
hang on long lines
URL: https://github.com/apache/nifi-minifi-cpp/pull/596#discussion_r296878375
##########
File path: extensions/standard-processors/processors/LogAttribute.cpp
##########
@@ -137,33 +137,32 @@ void LogAttribute::onTrigger(const
std::shared_ptr<core::ProcessContext> &contex
message << "\n" << "Payload:" << "\n";
ReadCallback callback(flow->getSize());
session->read(flow, &callback);
- for (unsigned int i = 0, j = 0; i < callback.read_size_; i++) {
- message << std::hex << callback.buffer_[i];
- j++;
- if (j == 80) {
- message << '\n';
- j = 0;
- }
+
+ auto payload_hex = utils::StringUtils::to_hex(callback.buffer_.data(),
callback.buffer_.size());
+ for (size_t i = 0; i < payload_hex.size(); i += 80) {
Review comment:
Why would it? std::string::substr will take as much as it can, even if the
specified length is larger than what remains.
If the string is 40 bytes long, it will run one iteration and create a line
of 40 bytes.
If the string is 80 bytes long, it will run one iteration and create a line
of 80 bytes.
If the string is 120 bytes long, it will run two iterations, creating a line
of 80 bytes, and a line of 40 bytes from offset 80.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services