szaszm commented on code in PR #1595: URL: https://github.com/apache/nifi-minifi-cpp/pull/1595#discussion_r1279657260
########## libminifi/src/io/InputStream.cpp: ########## @@ -71,18 +67,20 @@ size_t InputStream::read(std::string &str, bool widen) { return length_return; } - std::vector<std::byte> buffer(string_length); - const auto read_return = read(buffer); - if (read_return != string_length) { - return read_return; + str.clear(); + str.reserve(string_length); + + auto bytes_to_read = string_length; + while (bytes_to_read > 0) { + std::vector<std::byte> buffer(bytes_to_read); + const auto read_return = read(buffer); + if (io::isError(read_return)) + return read_return; + bytes_to_read -= read_return; + str.append(std::string(reinterpret_cast<const char*>(buffer.data()), read_return)); Review Comment: What made this loop necessary? Aren't partial reads handled inside each stream implementation? We should probably fix the problematic stream class instead. By the way, what if the read syscall keeps returning 0, and it's directly returned by the `InputStream::read` implementation of the stream class? -- 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-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org