You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2022/04/27 18:39:02 UTC

[nifi] branch main updated: NIFI-9968 Added null check before System.setProperty() in test methods

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

mattyb149 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 ac2d7d1e54 NIFI-9968 Added null check before System.setProperty() in test methods
ac2d7d1e54 is described below

commit ac2d7d1e54ac729f9e717d9d9e1bb89d02d3276b
Author: exceptionfactory <ex...@apache.org>
AuthorDate: Wed Apr 27 11:16:35 2022 -0500

    NIFI-9968 Added null check before System.setProperty() in test methods
    
    - Resolves build failures on Java 17 where the original user.timezone property returns null from System.getProperty()
    
    Signed-off-by: Matthew Burgess <ma...@apache.org>
    
    This closes #6000
---
 .../src/test/java/org/apache/nifi/record/path/TestRecordPath.java     | 4 +++-
 .../java/org/apache/nifi/processors/standard/TestConvertRecord.java   | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java b/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java
index 100861fd2b..db3b13b786 100644
--- a/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java
+++ b/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java
@@ -79,7 +79,9 @@ public class TestRecordPath {
 
     @AfterAll
     public static void setSystemTimezone() {
-        System.setProperty(USER_TIMEZONE_PROPERTY, SYSTEM_TIMEZONE);
+        if (SYSTEM_TIMEZONE != null) {
+            System.setProperty(USER_TIMEZONE_PROPERTY, SYSTEM_TIMEZONE);
+        }
     }
 
     @Test
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
index a85e61ca81..47477b04ca 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java
@@ -405,7 +405,9 @@ public class TestConvertRecord {
             assertTrue(avroStream.hasNext());
             assertEquals(1, avroStream.next().get("date")); // see https://avro.apache.org/docs/1.10.0/spec.html#Date
         } finally {
-            System.setProperty("user.timezone", timezone);
+            if (timezone != null) {
+                System.setProperty("user.timezone", timezone);
+            }
         }
     }
 }