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 <mattyb149@apache.org>

This closes #6000
This commit is contained in:
exceptionfactory 2022-04-27 11:16:35 -05:00 committed by Matthew Burgess
parent 8b08795e18
commit ac2d7d1e54
No known key found for this signature in database
GPG Key ID: 05D3DEB8126DAD24
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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);
}
}
}
}