lordgamez commented on a change in pull request #1232:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1232#discussion_r778803404
##########
File path: extensions/script/ExecuteScript.cpp
##########
@@ -89,40 +113,30 @@ void ExecuteScript::onTrigger(const
std::shared_ptr<core::ProcessContext> &conte
const std::shared_ptr<core::ProcessSession>
&session) {
std::shared_ptr<script::ScriptEngine> engine;
- // Use an existing engine, if one is available
- if (script_engine_q_.try_dequeue(engine)) {
- logger_->log_debug("Using available %s script engine instance",
script_engine_);
- } else {
- logger_->log_info("Creating new %s script instance", script_engine_);
- logger_->log_info("Approximately %d %s script instances created for this
processor",
- script_engine_q_.size_approx(),
- script_engine_);
-
- if (script_engine_ == "python") {
+ if (script_engine_ == "python") {
#ifdef PYTHON_SUPPORT
- engine = createEngine<python::PythonScriptEngine>();
+ engine = python_script_engine_;
#else
- throw std::runtime_error("Python support is disabled in this build.");
+ throw std::runtime_error("Python support is disabled in this build.");
#endif // PYTHON_SUPPORT
- } else if (script_engine_ == "lua") {
+ } else if (script_engine_ == "lua") {
#ifdef LUA_SUPPORT
- engine = createEngine<lua::LuaScriptEngine>();
+ engine = script_engine_q_->getScriptEngine<lua::LuaScriptEngine>();
#else
- throw std::runtime_error("Lua support is disabled in this build.");
+ throw std::runtime_error("Lua support is disabled in this build.");
#endif // LUA_SUPPORT
- }
-
- if (engine == nullptr) {
- throw std::runtime_error("No script engine available");
- }
-
- if (!script_body_.empty()) {
- engine->eval(script_body_);
- } else if (!script_file_.empty()) {
- engine->evalFile(script_file_);
- } else {
- throw std::runtime_error("Neither Script Body nor Script File is
available to execute");
- }
+ }
+
+ if (engine == nullptr) {
+ throw std::runtime_error("No script engine available");
+ }
+
+ if (!script_body_.empty()) {
+ engine->eval(script_body_);
+ } else if (!script_file_.empty()) {
Review comment:
Good point, I added additional checks and tests for misconfiguration use
cases in fb9b4e78d3762de139ca065b3044f572ca399a14
--
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]