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

mthomsen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 9d8b395  NIFI-9596: Fix newline bug in JythonScriptRunner NIFI-9596: 
Added comment to indicate why the Apache header is missing
9d8b395 is described below

commit 9d8b39529ef5f877e5e8790973ca43ac049be85a
Author: Matthew Burgess <[email protected]>
AuthorDate: Wed Jan 19 13:00:36 2022 -0500

    NIFI-9596: Fix newline bug in JythonScriptRunner
    NIFI-9596: Added comment to indicate why the Apache header is missing
    
    This closes #5682
    
    Signed-off-by: Mike Thomsen <[email protected]>
---
 .../nifi-scripting-processors/pom.xml              | 16 ++++++++++++++-
 .../nifi/script/impl/JythonScriptRunner.java       |  2 +-
 .../src/test/resources/jython/test_compress.py     | 23 ++--------------------
 3 files changed, 18 insertions(+), 23 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/pom.xml 
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/pom.xml
index 9c287aa..2a8c3f9 100644
--- a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/pom.xml
+++ b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/pom.xml
@@ -13,7 +13,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -153,4 +154,17 @@
             <version>${scripting.groovy.version}</version>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes combine.children="append">
+                        
<exclude>src/test/resources/jython/test_compress.py</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git 
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptRunner.java
 
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptRunner.java
index da315b0..e178bb9 100644
--- 
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptRunner.java
+++ 
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptRunner.java
@@ -38,7 +38,7 @@ public class JythonScriptRunner extends BaseScriptRunner {
         // Add prefix for import sys and all jython modules
         String prefix = "import sys\n"
                 + Arrays.stream(modulePaths).map((modulePath) -> 
"sys.path.append(" + PyString.encode_UnicodeEscape(modulePath, true) + ")")
-                .collect(Collectors.joining("\n"));
+                .collect(Collectors.joining("\n")) + "\n";
         compiledScript = ((Compilable) engine).compile(prefix + scriptBody);
     }
 
diff --git 
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/jython/test_compress.py
 
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/jython/test_compress.py
index b189cf5..bc74f9a 100755
--- 
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/jython/test_compress.py
+++ 
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/jython/test_compress.py
@@ -1,25 +1,6 @@
-#! /usr/bin/python
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-import sys
 import traceback
+# There is no Apache header on this file in order to reproduce the issue in 
NIFI-9596
+#  where the first line gets appended to the last line of the additional 
modules
 from callbacks import Compress, Decompress
 from org.apache.nifi.processor import Processor
 from org.apache.nifi.processor import Relationship

Reply via email to