martinzink commented on code in PR #1843:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1843#discussion_r1689532202
##########
extensions/lua/LuaProcessSession.cpp:
##########
@@ -43,78 +39,58 @@ std::shared_ptr<LuaScriptFlowFile> LuaProcessSession::get()
{
return result;
}
-void LuaProcessSession::transfer(const std::shared_ptr<LuaScriptFlowFile>
&script_flow_file,
+void LuaProcessSession::transfer(const std::shared_ptr<LuaScriptFlowFile>&
script_flow_file,
const core::Relationship& relationship) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been
released");
- }
-
- auto flow_file = script_flow_file->getFlowFile();
+ const auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->transfer(flow_file, relationship);
+ session_.transfer(flow_file, relationship);
}
void LuaProcessSession::read(const std::shared_ptr<LuaScriptFlowFile>
&script_flow_file,
sol::table input_stream_callback) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been
released");
- }
-
- auto flow_file = script_flow_file->getFlowFile();
+ const auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->read(flow_file, [&input_stream_callback](const
std::shared_ptr<io::InputStream>& input_stream) -> int64_t {
+ session_.read(flow_file, [&input_stream_callback](const
std::shared_ptr<io::InputStream>& input_stream) -> int64_t {
sol::function callback = input_stream_callback["process"];
return callback(input_stream_callback,
std::make_shared<LuaInputStream>(input_stream));
});
}
void LuaProcessSession::write(const std::shared_ptr<LuaScriptFlowFile>
&script_flow_file,
sol::table output_stream_callback) {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been
released");
- }
-
auto flow_file = script_flow_file->getFlowFile();
if (!flow_file) {
throw std::runtime_error("Access of FlowFile after it has been released");
}
- session_->write(flow_file, [&output_stream_callback](const
std::shared_ptr<io::OutputStream>& output_stream) -> int64_t {
+ session_.write(flow_file, [&output_stream_callback](const
std::shared_ptr<io::OutputStream>& output_stream) -> int64_t {
sol::function callback = output_stream_callback["process"];
return callback(output_stream_callback,
std::make_shared<LuaOutputStream>(output_stream));
});
}
std::shared_ptr<LuaScriptFlowFile> LuaProcessSession::create() {
- if (!session_) {
- throw std::runtime_error("Access of ProcessSession after it has been
released");
- }
-
- auto result = std::make_shared<LuaScriptFlowFile>(session_->create());
+auto result = std::make_shared<LuaScriptFlowFile>(session_.create());
Review Comment:
good catch
https://github.com/apache/nifi-minifi-cpp/pull/1843/commits/434975b6341f9ba04e35e07d2b0559ca7b87846f#diff-f980ccede23f6ad9af2a715b01315fabe0b5dcb06d2f75b948123453e4fe6634R82
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]