You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "martinzink (via GitHub)" <gi...@apache.org> on 2026/01/07 16:36:40 UTC
[PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
martinzink opened a new pull request, #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
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
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2672075704
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
Review Comment:
good idea, [review changes](https://github.com/apache/nifi-minifi-cpp/pull/2083/commits/e09d59e3bd3b8f325d070ca8c4bcdc147837c1aa)
--
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
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2672326462
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -44,6 +47,10 @@ std::unique_ptr<core::ContentRepository> createContentRepository(const std::stri
return std::make_unique<core::repository::FileSystemRepository>(repo_name);
}
if (fail_safe) {
Review Comment:
im usually on the side to fail fast and fail hard :D so we might just remove this fail_safe parameter and crash in that case
--
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
Re: [PR] MINIFICPP-2700 Terminate if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm closed pull request #2083: MINIFICPP-2700 Terminate if ContentRepository creation failed
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083
--
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
Re: [PR] MINIFICPP-2700 Terminate if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2721480526
##########
libminifi/include/core/RepositoryFactory.h:
##########
@@ -32,8 +32,11 @@ namespace org::apache::nifi::minifi::core {
* @param configuration_class_name configuration class name
* @param fail_safe determines whether or not to make the default class if configuration_class_name is invalid
Review Comment:
good idea, and since the only nontrivial argument was fail_safe I doubt this documentation style comment add anything useful so I've removed it entirely https://github.com/apache/nifi-minifi-cpp/pull/2083/changes/3812bc5013cb4d3b8c8597e73677870c39e9a210
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -28,33 +28,31 @@ using namespace std::literals::chrono_literals;
namespace org::apache::nifi::minifi::core {
-std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name, bool fail_safe, const std::string& repo_name) {
+std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name,
+ const std::string& repo_name,
+ logging::Logger* logger) {
std::string class_name_lc = configuration_class_name;
std::transform(class_name_lc.begin(), class_name_lc.end(), class_name_lc.begin(), ::tolower);
- try {
- auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
- class_name_lc);
- if (return_obj) {
- return_obj->setName(repo_name);
- return return_obj;
- }
- if (class_name_lc == "volatilecontentrepository") {
- return std::make_unique<core::repository::VolatileContentRepository>(repo_name);
- } else if (class_name_lc == "filesystemrepository") {
- return std::make_unique<core::repository::FileSystemRepository>(repo_name);
- }
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- } else {
- throw std::runtime_error("Support for the provided configuration class could not be found");
- }
- } catch (const std::runtime_error&) {
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- }
+
+ auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
+ class_name_lc);
Review Comment:
👍 https://github.com/apache/nifi-minifi-cpp/pull/2083/changes/3812bc5013cb4d3b8c8597e73677870c39e9a210
--
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
Re: [PR] MINIFICPP-2700 Terminate if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2721474257
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -28,33 +28,31 @@ using namespace std::literals::chrono_literals;
namespace org::apache::nifi::minifi::core {
-std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name, bool fail_safe, const std::string& repo_name) {
+std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name,
+ const std::string& repo_name,
+ logging::Logger* logger) {
std::string class_name_lc = configuration_class_name;
std::transform(class_name_lc.begin(), class_name_lc.end(), class_name_lc.begin(), ::tolower);
- try {
- auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
- class_name_lc);
- if (return_obj) {
- return_obj->setName(repo_name);
- return return_obj;
- }
- if (class_name_lc == "volatilecontentrepository") {
- return std::make_unique<core::repository::VolatileContentRepository>(repo_name);
- } else if (class_name_lc == "filesystemrepository") {
- return std::make_unique<core::repository::FileSystemRepository>(repo_name);
- }
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- } else {
- throw std::runtime_error("Support for the provided configuration class could not be found");
- }
- } catch (const std::runtime_error&) {
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- }
+
+ auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
+ class_name_lc);
+ if (return_obj) {
+ return_obj->setName(repo_name);
+ return return_obj;
}
- throw std::runtime_error("Support for the provided configuration class could not be found");
+ if (class_name_lc == "volatilecontentrepository") {
+ return std::make_unique<core::repository::VolatileContentRepository>(repo_name);
+ }
+ if (class_name_lc == "filesystemrepository") {
+ return std::make_unique<core::repository::FileSystemRepository>(repo_name);
+ }
+
+ logger->log_critical("Could not create the configured content repository ({})", configuration_class_name);
Review Comment:
👍 https://github.com/apache/nifi-minifi-cpp/pull/2083/changes/3812bc5013cb4d3b8c8597e73677870c39e9a210
--
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
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2669429450
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
Review Comment:
It may be better to inject a logger as a function parameter instead of creating one locally for a semi-related 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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2672323446
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -44,6 +47,10 @@ std::unique_ptr<core::ContentRepository> createContentRepository(const std::stri
return std::make_unique<core::repository::FileSystemRepository>(repo_name);
}
if (fail_safe) {
Review Comment:
yeah thats a valid point, prior to this PR we dont even notified the user via the logs, but we might want to be more strict thats true
--
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
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2685467340
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -28,33 +28,31 @@ using namespace std::literals::chrono_literals;
namespace org::apache::nifi::minifi::core {
-std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name, bool fail_safe, const std::string& repo_name) {
+std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name,
+ const std::string& repo_name,
+ logging::Logger* logger) {
std::string class_name_lc = configuration_class_name;
std::transform(class_name_lc.begin(), class_name_lc.end(), class_name_lc.begin(), ::tolower);
- try {
- auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
- class_name_lc);
- if (return_obj) {
- return_obj->setName(repo_name);
- return return_obj;
- }
- if (class_name_lc == "volatilecontentrepository") {
- return std::make_unique<core::repository::VolatileContentRepository>(repo_name);
- } else if (class_name_lc == "filesystemrepository") {
- return std::make_unique<core::repository::FileSystemRepository>(repo_name);
- }
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- } else {
- throw std::runtime_error("Support for the provided configuration class could not be found");
- }
- } catch (const std::runtime_error&) {
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- }
+
+ auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
+ class_name_lc);
+ if (return_obj) {
+ return_obj->setName(repo_name);
+ return return_obj;
}
- throw std::runtime_error("Support for the provided configuration class could not be found");
+ if (class_name_lc == "volatilecontentrepository") {
+ return std::make_unique<core::repository::VolatileContentRepository>(repo_name);
+ }
+ if (class_name_lc == "filesystemrepository") {
+ return std::make_unique<core::repository::FileSystemRepository>(repo_name);
+ }
+
+ logger->log_critical("Could not create the configured content repository ({})", configuration_class_name);
Review Comment:
If we allow `logger` to be null, then please check it before dereferencing. It may be better to force it to be non-null?
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -28,33 +28,31 @@ using namespace std::literals::chrono_literals;
namespace org::apache::nifi::minifi::core {
-std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name, bool fail_safe, const std::string& repo_name) {
+std::unique_ptr<core::ContentRepository> createContentRepository(const std::string& configuration_class_name,
+ const std::string& repo_name,
+ logging::Logger* logger) {
std::string class_name_lc = configuration_class_name;
std::transform(class_name_lc.begin(), class_name_lc.end(), class_name_lc.begin(), ::tolower);
- try {
- auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
- class_name_lc);
- if (return_obj) {
- return_obj->setName(repo_name);
- return return_obj;
- }
- if (class_name_lc == "volatilecontentrepository") {
- return std::make_unique<core::repository::VolatileContentRepository>(repo_name);
- } else if (class_name_lc == "filesystemrepository") {
- return std::make_unique<core::repository::FileSystemRepository>(repo_name);
- }
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- } else {
- throw std::runtime_error("Support for the provided configuration class could not be found");
- }
- } catch (const std::runtime_error&) {
- if (fail_safe) {
- return std::make_unique<core::repository::VolatileContentRepository>("fail_safe");
- }
+
+ auto return_obj = core::ClassLoader::getDefaultClassLoader().instantiate<core::ContentRepository>(class_name_lc,
+ class_name_lc);
Review Comment:
this indentation looks bad; it may be better to keep this on one line
##########
libminifi/include/core/RepositoryFactory.h:
##########
@@ -32,8 +32,11 @@ namespace org::apache::nifi::minifi::core {
* @param configuration_class_name configuration class name
* @param fail_safe determines whether or not to make the default class if configuration_class_name is invalid
Review Comment:
the documentation of the `fail_safe` parameter should be removed (also below, before the `createRepository` function)
--
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
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2682676030
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -44,6 +47,10 @@ std::unique_ptr<core::ContentRepository> createContentRepository(const std::stri
return std::make_unique<core::repository::FileSystemRepository>(repo_name);
}
if (fail_safe) {
Review Comment:
removed the fail_safe option, [remove fail_safe option](https://github.com/apache/nifi-minifi-cpp/pull/2083/commits/68da2bfc0e38b37f2f13a886529ef4c9ff7ba2d9)
--
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
Re: [PR] MINIFICPP-2700 Log errors if ContentRepository creation failed [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #2083:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2083#discussion_r2672103460
##########
libminifi/src/core/RepositoryFactory.cpp:
##########
@@ -44,6 +47,10 @@ std::unique_ptr<core::ContentRepository> createContentRepository(const std::stri
return std::make_unique<core::repository::FileSystemRepository>(repo_name);
}
if (fail_safe) {
Review Comment:
I am wondering if this is a good idea (not the change itself) if the user requests some persistent content repo and we log an error, store stuff in-memory then it gets wiped, the user might not check the error or even if they do there might have already been some processing happening and we have no way of getting to the data
--
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