diff --git a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java index d5172be8a7..5cc4d65861 100644 --- a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java +++ b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java @@ -282,11 +282,14 @@ public class InvokeScriptedProcessor extends AbstractSessionFactoryProcessor { * @return true if the script was loaded successfully; false otherwise */ private boolean reloadScriptFile(final String scriptPath) { + if (StringUtils.isEmpty(scriptPath)) { + return false; + } + final Collection results = new HashSet<>(); try (final FileInputStream scriptStream = new FileInputStream(scriptPath)) { return reloadScript(IOUtils.toString(scriptStream, Charset.defaultCharset())); - } catch (final Exception e) { final ComponentLog logger = getLogger(); final String message = "Unable to load script: " + e; @@ -314,10 +317,13 @@ public class InvokeScriptedProcessor extends AbstractSessionFactoryProcessor { * @return true if the script was loaded successfully; false otherwise */ private boolean reloadScriptBody(final String scriptBody) { + if (StringUtils.isEmpty(scriptBody)) { + return false; + } + final Collection results = new HashSet<>(); try { return reloadScript(scriptBody); - } catch (final Exception e) { final ComponentLog logger = getLogger(); final String message = "Unable to load script: " + e; diff --git a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/AbstractScriptedControllerService.java b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/AbstractScriptedControllerService.java index 1cdcb809e2..71157cae74 100644 --- a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/AbstractScriptedControllerService.java +++ b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/AbstractScriptedControllerService.java @@ -27,6 +27,7 @@ import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.logging.ComponentLog; import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processors.script.ScriptRunner; +import org.apache.nifi.util.StringUtils; import java.io.FileInputStream; import java.nio.charset.Charset; @@ -158,11 +159,14 @@ public abstract class AbstractScriptedControllerService extends AbstractControll * @return true if the script was loaded successfully; false otherwise */ protected boolean reloadScriptFile(final String scriptPath) { + if (StringUtils.isEmpty(scriptPath)) { + return false; + } + final Collection results = new HashSet<>(); try (final FileInputStream scriptStream = new FileInputStream(scriptPath)) { return reloadScript(IOUtils.toString(scriptStream, Charset.defaultCharset())); - } catch (final Exception e) { final ComponentLog logger = getLogger(); final String message = "Unable to load script: " + e; @@ -190,10 +194,13 @@ public abstract class AbstractScriptedControllerService extends AbstractControll * @return true if the script was loaded successfully; false otherwise */ protected boolean reloadScriptBody(final String scriptBody) { + if (StringUtils.isEmpty(scriptBody)) { + return false; + } + final Collection results = new HashSet<>(); try { return reloadScript(scriptBody); - } catch (final Exception e) { final ComponentLog logger = getLogger(); final String message = "Unable to load script: " + e;