You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2019/02/20 13:47:18 UTC

[nifi-minifi-cpp] branch master updated (361184a -> 840610d)

This is an automated email from the ASF dual-hosted git repository.

aldrin pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git.


    from 361184a  MINIFICPP-736 - Add timeout to log matching to fix unstable test cases
     new 0f3ee67  MINIFICPP-739: Resolve json checks for c2 responses
     new 840610d  MINIFICPP-739: Resolve json checks for c2 responses

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libminifi/src/c2/protocols/RESTProtocol.cpp | 30 +++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)


[nifi-minifi-cpp] 02/02: MINIFICPP-739: Resolve json checks for c2 responses

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldrin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit 840610d43e299b33c31df7f42b7cc0b58160ea58
Author: Marc Parisi <ph...@apache.org>
AuthorDate: Tue Feb 19 13:36:51 2019 -0500

    MINIFICPP-739: Resolve json checks for c2 responses
    
    This closes #488.
    
    Signed-off-by: Aldrin Piri <al...@apache.org>
---
 libminifi/src/c2/protocols/RESTProtocol.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libminifi/src/c2/protocols/RESTProtocol.cpp b/libminifi/src/c2/protocols/RESTProtocol.cpp
index 3463407..6eb91cb 100644
--- a/libminifi/src/c2/protocols/RESTProtocol.cpp
+++ b/libminifi/src/c2/protocols/RESTProtocol.cpp
@@ -43,7 +43,6 @@ const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, const
   try {
     rapidjson::ParseResult ok = root.Parse(response.data(), response.size());
     if (ok) {
-
       std::string requested_operation = getOperation(payload);
 
       std::string identifier;
@@ -140,8 +139,6 @@ const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, const
       return new_payload;
       // }
     }
-  } catch (const std::exception &e) {
-
   } catch (...) {
   }
   return C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE, true);


[nifi-minifi-cpp] 01/02: MINIFICPP-739: Resolve json checks for c2 responses

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldrin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit 0f3ee67746386ca8a92a0875b955108b85ea2cce
Author: Marc Parisi <ph...@apache.org>
AuthorDate: Tue Feb 19 13:34:53 2019 -0500

    MINIFICPP-739: Resolve json checks for c2 responses
---
 libminifi/src/c2/protocols/RESTProtocol.cpp | 33 ++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/libminifi/src/c2/protocols/RESTProtocol.cpp b/libminifi/src/c2/protocols/RESTProtocol.cpp
index d081510..3463407 100644
--- a/libminifi/src/c2/protocols/RESTProtocol.cpp
+++ b/libminifi/src/c2/protocols/RESTProtocol.cpp
@@ -33,16 +33,21 @@ namespace nifi {
 namespace minifi {
 namespace c2 {
 
+#ifdef WIN32
+#pragma push_macro("GetObject")
+#undef GetObject
+#endif
 const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, const std::vector<char> &response) {
-#ifndef WIN32
   rapidjson::Document root;
 
   try {
     rapidjson::ParseResult ok = root.Parse(response.data(), response.size());
     if (ok) {
+
       std::string requested_operation = getOperation(payload);
 
       std::string identifier;
+
       if (root.HasMember("operationid")) {
         identifier = root["operationid"].GetString();
       } else if (root.HasMember("operationId")) {
@@ -50,16 +55,25 @@ const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, const
       } else if (root.HasMember("identifier")) {
         identifier = root["identifier"].GetString();
       }
-      if (root["requested_operations"].Size() == 0 && root["requestedOperations"].Size() == 0)
+
+      int size = 0;
+      if (root.HasMember("requested_operations")) {
+        size = root["requested_operations"].Size();
+      }
+      if (root.HasMember("requestedOperations")) {
+        size = root["requestedOperations"].Size();
+      }
+
+      // neither must be there. We don't want assign array yet and cause an assertion error
+      if (size == 0)
         return C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE, true);
 
       C2Payload new_payload(payload.getOperation(), state::UpdateState::NESTED, true);
-
       if (!identifier.empty())
         new_payload.setIdentifier(identifier);
-      auto array = root["requested_operations"].GetArray();
-      if (root["requested_operations"].Size() == 0)
-        array = root["requestedOperations"].GetArray();
+
+      auto array = root.HasMember("requested_operations") ? root["requested_operations"].GetArray() : root["requestedOperations"].GetArray();
+
       for (const rapidjson::Value& request : array) {
         Operation newOp = stringToOperation(request["operation"].GetString());
         C2Payload nested_payload(newOp, state::UpdateState::READ_COMPLETE, true);
@@ -126,9 +140,10 @@ const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, const
       return new_payload;
       // }
     }
+  } catch (const std::exception &e) {
+
   } catch (...) {
   }
-#endif
   return C2Payload(payload.getOperation(), state::UpdateState::READ_COMPLETE, true);
 }
 
@@ -387,7 +402,9 @@ Operation RESTProtocol::stringToOperation(const std::string str) {
   }
   return Operation::HEARTBEAT;
 }
-
+#ifdef WIN32
+#pragma pop_macro("GetObject")
+#endif
 } /* namespace c2 */
 } /* namespace minifi */
 } /* namespace nifi */