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/11/26 14:34:43 UTC

[GitHub] [nifi-minifi-cpp] szaszm opened a new pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

szaszm opened a new pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943


   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:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [x] 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.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [x] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [x] 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)?
   - [x] If applicable, have you updated the LICENSE file?
   - [x] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [x] 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532572893



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};

Review comment:
       I see, I just glanced over it and missed the part where it stores the factory




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532415163



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};

Review comment:
       I kind of get the reason behind this `onSchedule` overload, but shouldn't we overload the raw-pointer-taking `onSchedule` (unless the processor wants to store the context or factory) and leave the `onSchedule(shared_ptr<ProcessContext>, shared_ptr<ProcessSessionFactory>)` alone (defaulting to forwarding to the raw-pointer-taking `onSchedule` in `Processor`), then we wouldn't have to throw at all




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] arpadboda closed pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
arpadboda closed pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943


   


----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532581458



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};
   }
   /**
    * Execution trigger for the GetTCP Processor
    * @param context processor context
    * @param session processor session reference.
    */
-  virtual void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session);
+  void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) override;
 
-  virtual void onTrigger(core::ProcessContext *context, core::ProcessSession *session) {
-    throw std::exception();
+  void onTrigger(core::ProcessContext *context, core::ProcessSession *session) override {
+    throw std::logic_error{"GetTCP::onTrigger(ProcessContext*, ProcessSession*) is unimplemented"};

Review comment:
       [MINIFICPP-1415 Use raw pointer overloads of onTrigger and onSchedule when possible](https://issues.apache.org/jira/browse/MINIFICPP-1415)




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532418781



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};
   }
   /**
    * Execution trigger for the GetTCP Processor
    * @param context processor context
    * @param session processor session reference.
    */
-  virtual void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session);
+  void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) override;
 
-  virtual void onTrigger(core::ProcessContext *context, core::ProcessSession *session) {
-    throw std::exception();
+  void onTrigger(core::ProcessContext *context, core::ProcessSession *session) override {
+    throw std::logic_error{"GetTCP::onTrigger(ProcessContext*, ProcessSession*) is unimplemented"};

Review comment:
       the same reasoning applies here I believe, that we should move the `onTrigger` implementation to this method and leave the smart-pointer-taking `onTrigger` to its default behavior




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532428911



##########
File path: libminifi/test/TestBase.cpp
##########
@@ -140,7 +140,7 @@ std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::string &proce
 
   auto ptr = core::ClassLoader::getDefaultClassLoader().instantiate(processor_name, uuid);
   if (nullptr == ptr) {
-    throw std::exception();
+    throw std::runtime_error{fmt::format("Failed to instantiate processor name: {0} uuid: {1}", processor_name, uuid.to_string().c_str())};

Review comment:
       why the `.c_str()`?




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532576416



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};

Review comment:
       I also missed it until the compilation errors popped up. :smile: 




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532575479



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};
   }
   /**
    * Execution trigger for the GetTCP Processor
    * @param context processor context
    * @param session processor session reference.
    */
-  virtual void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session);
+  void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) override;
 
-  virtual void onTrigger(core::ProcessContext *context, core::ProcessSession *session) {
-    throw std::exception();
+  void onTrigger(core::ProcessContext *context, core::ProcessSession *session) override {
+    throw std::logic_error{"GetTCP::onTrigger(ProcessContext*, ProcessSession*) is unimplemented"};

Review comment:
       I agree that the symmetry is nice, I think we can leave it be for now, and then take a look at these (not just this processor but others as well) in a separate PR to override the raw-pointer-taking method wherever 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



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532570466



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};

Review comment:
       Ideally yes, but at the moment GetTCP creates flow files as data arrives meaning that it needs to be able to create a ProcessSession whenever needed and shared ownership of ProcessSessionFactory is the way it achieves this.




----------------------------------------------------------------
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



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #943: MINIFICPP-1413 avoid empty std::exception, improve logging

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #943:
URL: https://github.com/apache/nifi-minifi-cpp/pull/943#discussion_r532570892



##########
File path: extensions/standard-processors/processors/GetTCP.h
##########
@@ -212,29 +207,29 @@ class GetTCP : public core::Processor, public state::response::MetricsNodeSource
    * @param sessionFactory process session factory that is used when creating
    * ProcessSession objects.
    */
-  virtual void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory);
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &processContext, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
 
-  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) {
-    throw std::exception();
+  void onSchedule(core::ProcessContext *processContext, core::ProcessSessionFactory *sessionFactory) override {
+    throw std::logic_error{"GetTCP::onSchedule(ProcessContext*, ProcessSessionFactory*) is unimplemented"};
   }
   /**
    * Execution trigger for the GetTCP Processor
    * @param context processor context
    * @param session processor session reference.
    */
-  virtual void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session);
+  void onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) override;
 
-  virtual void onTrigger(core::ProcessContext *context, core::ProcessSession *session) {
-    throw std::exception();
+  void onTrigger(core::ProcessContext *context, core::ProcessSession *session) override {
+    throw std::logic_error{"GetTCP::onTrigger(ProcessContext*, ProcessSession*) is unimplemented"};

Review comment:
       I could change onTrigger but prefer not to for symmetry with onSchedule.




----------------------------------------------------------------
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