You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/01/08 18:56:19 UTC
[GitHub] [nifi-minifi-cpp] szaszm opened a new pull request #706:
MINIFICPP-1116 - Fix error reporting in C2Agent
szaszm opened a new pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706
- Missing CoapProtocol will now result in a fatal error (exception)
instead of segfault. Error reporting is improved.
- C2Agent::protocol_ is now properly deleted
- remove dead code
- avoid unnecessary string copies in loop
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 master)?
- [ ] 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 travis-ci 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request
#706: MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#discussion_r364757710
##########
File path: libminifi/src/c2/C2Agent.cpp
##########
@@ -154,25 +155,24 @@ void C2Agent::configure(const std::shared_ptr<Configure> &configure, bool reconf
clazz = "CoapProtocol";
}
logger_->log_info("Class is %s", clazz);
- auto protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw(clazz, clazz);
+ auto protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw(clazz, clazz);
if (protocol == nullptr) {
- logger_->log_info("Class %s not found", clazz);
+ logger_->log_warn("Class %s not found", clazz);
protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw("CoapProtocol", "CoapProtocol");
if (!protocol) {
- logger_->log_info("Attempted to load CoapProtocol. To enable C2, please specify an active protocol for this agent.");
- return;
- } else {
- logger_->log_info("Class is CoapProtocol");
+ const char* errmsg = "Attempted to load CoapProtocol. To enable C2, please specify an active protocol for this agent.";
+ logger_->log_error(errmsg);
+ throw std::domain_error{ errmsg };
Review comment:
fixed in e108d27
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request
#706: MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
bakaid commented on a change in pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#discussion_r364712240
##########
File path: libminifi/include/c2/C2Agent.h
##########
@@ -57,7 +57,8 @@ class C2Agent : public state::UpdateController, public state::response::Response
C2Agent(const std::shared_ptr<core::controller::ControllerServiceProvider> &controller, const std::shared_ptr<state::StateMonitor> &updateSink, const std::shared_ptr<Configure> &configure);
- virtual ~C2Agent() {
+ ~C2Agent() noexcept override {
Review comment:
In libminifi code we currently don't use override, as there were some problems with it on older systems and it has not yet been thoroughly verified that it works OK now. (In extensions, it is okay.)
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] szaszm commented on issue #706: MINIFICPP-1116 -
Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
szaszm commented on issue #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#issuecomment-572504655
The AppVeyor failure does not seem to be related to the changes in this PR. Is it unrelated or am I missing something?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request
#706: MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
bakaid commented on a change in pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#discussion_r364714375
##########
File path: libminifi/src/c2/C2Agent.cpp
##########
@@ -154,25 +155,24 @@ void C2Agent::configure(const std::shared_ptr<Configure> &configure, bool reconf
clazz = "CoapProtocol";
}
logger_->log_info("Class is %s", clazz);
- auto protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw(clazz, clazz);
+ auto protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw(clazz, clazz);
if (protocol == nullptr) {
- logger_->log_info("Class %s not found", clazz);
+ logger_->log_warn("Class %s not found", clazz);
protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw("CoapProtocol", "CoapProtocol");
if (!protocol) {
- logger_->log_info("Attempted to load CoapProtocol. To enable C2, please specify an active protocol for this agent.");
- return;
- } else {
- logger_->log_info("Class is CoapProtocol");
+ const char* errmsg = "Attempted to load CoapProtocol. To enable C2, please specify an active protocol for this agent.";
+ logger_->log_error(errmsg);
+ throw std::domain_error{ errmsg };
}
+
+ logger_->log_info("Class is CoapProtocol");
}
- C2Protocol *old_protocol = protocol_.exchange(dynamic_cast<C2Protocol*>(protocol));
- protocol_.load()->initialize(controller_, configuration_);
+ // Since !reconfigure, the call comes from the ctor and protocol_ is null, therefore no delete is necessary
+ protocol_.exchange(dynamic_cast<C2Protocol *>(protocol));
Review comment:
Nice catch!
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] arpadboda closed pull request #706:
MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
arpadboda closed pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request
#706: MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
bakaid commented on a change in pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#discussion_r364713558
##########
File path: libminifi/src/c2/C2Agent.cpp
##########
@@ -232,7 +232,7 @@ void C2Agent::configure(const std::shared_ptr<Configure> &configure, bool reconf
if (configure->get("nifi.c2.agent.heartbeat.reporter.classes", "c2.agent.heartbeat.reporter.classes", heartbeat_reporters)) {
std::vector<std::string> reporters = utils::StringUtils::split(heartbeat_reporters, ",");
std::lock_guard<std::mutex> lock(heartbeat_mutex);
- for (auto reporter : reporters) {
+ for (const auto& reporter : reporters) {
Review comment:
👍
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request
#706: MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#discussion_r364757660
##########
File path: libminifi/include/c2/C2Agent.h
##########
@@ -57,7 +57,8 @@ class C2Agent : public state::UpdateController, public state::response::Response
C2Agent(const std::shared_ptr<core::controller::ControllerServiceProvider> &controller, const std::shared_ptr<state::StateMonitor> &updateSink, const std::shared_ptr<Configure> &configure);
- virtual ~C2Agent() {
+ ~C2Agent() noexcept override {
Review comment:
fixed in e108d27
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request
#706: MINIFICPP-1116 - Fix error reporting in C2Agent
Posted by GitBox <gi...@apache.org>.
bakaid commented on a change in pull request #706: MINIFICPP-1116 - Fix error reporting in C2Agent
URL: https://github.com/apache/nifi-minifi-cpp/pull/706#discussion_r364713372
##########
File path: libminifi/src/c2/C2Agent.cpp
##########
@@ -154,25 +155,24 @@ void C2Agent::configure(const std::shared_ptr<Configure> &configure, bool reconf
clazz = "CoapProtocol";
}
logger_->log_info("Class is %s", clazz);
- auto protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw(clazz, clazz);
+ auto protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw(clazz, clazz);
if (protocol == nullptr) {
- logger_->log_info("Class %s not found", clazz);
+ logger_->log_warn("Class %s not found", clazz);
protocol = core::ClassLoader::getDefaultClassLoader().instantiateRaw("CoapProtocol", "CoapProtocol");
if (!protocol) {
- logger_->log_info("Attempted to load CoapProtocol. To enable C2, please specify an active protocol for this agent.");
- return;
- } else {
- logger_->log_info("Class is CoapProtocol");
+ const char* errmsg = "Attempted to load CoapProtocol. To enable C2, please specify an active protocol for this agent.";
+ logger_->log_error(errmsg);
+ throw std::domain_error{ errmsg };
Review comment:
I think it would be better to use a minifi::Exception here.
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services