You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ph...@apache.org on 2019/06/26 23:20:31 UTC
[nifi-minifi-cpp] branch master updated: MINIFICPP-936: Add
canonical name check back into processor utils
This is an automated email from the ASF dual-hosted git repository.
phrocker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 581a9b6 MINIFICPP-936: Add canonical name check back into processor utils
581a9b6 is described below
commit 581a9b65432ec89cf6edfdd80dbfa165d7627100
Author: Marc Parisi <ph...@apache.org>
AuthorDate: Wed Jun 26 19:00:02 2019 -0400
MINIFICPP-936: Add canonical name check back into processor utils
This closes #600.
Signed-off-by: Marc Parisi <ph...@apache.org>
---
libminifi/include/processors/ProcessorUtils.h | 29 ++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/libminifi/include/processors/ProcessorUtils.h b/libminifi/include/processors/ProcessorUtils.h
index d6ad3e3..40b87c2 100644
--- a/libminifi/include/processors/ProcessorUtils.h
+++ b/libminifi/include/processors/ProcessorUtils.h
@@ -22,20 +22,31 @@ class ProcessorUtils {
static inline std::shared_ptr<core::Processor> createProcessor(const std::string &class_short_name, const std::string &canonicalName, utils::Identifier &uuid,
const std::shared_ptr<minifi::io::StreamFactory> &stream_factory) {
auto ptr = core::ClassLoader::getDefaultClassLoader().instantiate(class_short_name, uuid);
+ // fallback to the canonical name if the short name does not work, then attempt JNI bindings if they exist
if (ptr == nullptr) {
- ptr = core::ClassLoader::getDefaultClassLoader().instantiate("ExecuteJavaClass", uuid);
- if (ptr != nullptr) {
- std::shared_ptr<core::Processor> processor = std::static_pointer_cast<core::Processor>(ptr);
- processor->initialize();
- processor->setProperty("NiFi Processor", canonicalName);
- processor->setStreamFactory(stream_factory);
- return processor;
+ ptr = core::ClassLoader::getDefaultClassLoader().instantiate(canonicalName, uuid);
+ if (ptr == nullptr) {
+ ptr = core::ClassLoader::getDefaultClassLoader().instantiate("ExecuteJavaClass", uuid);
+ if (ptr != nullptr) {
+ std::shared_ptr<core::Processor> processor = std::dynamic_pointer_cast<core::Processor>(ptr);
+ if (processor == nullptr) {
+ throw std::runtime_error("Invalid return from the classloader");
+ }
+ processor->initialize();
+ processor->setProperty("NiFi Processor", canonicalName);
+ processor->setStreamFactory(stream_factory);
+ return processor;
+ }
}
}
- if (nullptr == ptr) {
+ if (ptr == nullptr) {
return nullptr;
}
- auto returnPtr = std::static_pointer_cast<core::Processor>(ptr);
+ auto returnPtr = std::dynamic_pointer_cast<core::Processor>(ptr);
+
+ if (returnPtr == nullptr) {
+ throw std::runtime_error("Invalid return from the classloader");
+ }
returnPtr->initialize();