This is an automated email from the ASF dual-hosted git repository.
pvillard31 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 28c23caa754 NIFI-16210 Adjusted GetSplunk Time Zone Validator (#11550)
28c23caa754 is described below
commit 28c23caa7545d1aa73c58071d0eb0ee56fe2021c
Author: David Handermann <[email protected]>
AuthorDate: Sat Aug 15 07:05:08 2026 -0500
NIFI-16210 Adjusted GetSplunk Time Zone Validator (#11550)
- Replaced version-dependent allowable values with runtime Validator
---
.../org/apache/nifi/processors/splunk/GetSplunk.java | 19 +++++++++++++++++--
.../apache/nifi/processors/splunk/TestGetSplunk.java | 18 ++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git
a/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
b/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
index e21f76b9b0b..f023e674cbe 100644
---
a/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
+++
b/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
@@ -40,6 +40,7 @@ import
org.apache.nifi.components.ClassloaderIsolationKeyProvider;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
import org.apache.nifi.components.state.Scope;
import org.apache.nifi.components.state.StateMap;
import org.apache.nifi.context.PropertyContext;
@@ -193,10 +194,24 @@ public class GetSplunk extends AbstractProcessor
implements ClassloaderIsolation
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.required(false)
.build();
+
+ private static final Set<String> AVAILABLE_TIME_ZONE_IDS =
Set.of(TimeZone.getAvailableIDs());
+
+ private static final Validator TIME_ZONE_VALIDATOR = (subject, input,
context) -> new ValidationResult.Builder()
+ .subject(subject)
+ .input(input)
+ .valid(input != null && AVAILABLE_TIME_ZONE_IDS.contains(input))
+ .explanation("must be a valid time zone identifier such as UTC or
America/New_York")
+ .build();
+
public static final PropertyDescriptor TIME_ZONE = new
PropertyDescriptor.Builder()
.name("Time Zone")
- .description("The Time Zone to use for formatting dates when
performing a search. Only used with Managed time strategies.")
- .allowableValues(TimeZone.getAvailableIDs())
+ .description("""
+ The Time Zone to use for formatting dates when performing
a search. Only used with Managed time strategies.
+ The value must be a valid Java time zone identifier, such
as UTC or America/New_York.
+ """
+ )
+ .addValidator(TIME_ZONE_VALIDATOR)
.defaultValue("UTC")
.required(true)
.build();
diff --git
a/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/test/java/org/apache/nifi/processors/splunk/TestGetSplunk.java
b/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/test/java/org/apache/nifi/processors/splunk/TestGetSplunk.java
index 8de4e150ded..e7a0e23d9a1 100644
---
a/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/test/java/org/apache/nifi/processors/splunk/TestGetSplunk.java
+++
b/nifi-extension-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/test/java/org/apache/nifi/processors/splunk/TestGetSplunk.java
@@ -84,6 +84,24 @@ public class TestGetSplunk {
runner.assertValid();
}
+ @Test
+ public void testTimeZoneValidation() {
+ runner.setProperty(GetSplunk.QUERY, "search tcp:7879");
+ runner.setProperty(GetSplunk.EARLIEST_TIME, "-1h");
+ runner.setProperty(GetSplunk.LATEST_TIME, "now");
+ runner.setProperty(GetSplunk.OUTPUT_MODE,
GetSplunk.ATOM_VALUE.getValue());
+ runner.assertValid();
+
+ runner.setProperty(GetSplunk.TIME_ZONE, "Not/AValidZone");
+ runner.assertNotValid();
+
+ runner.setProperty(GetSplunk.TIME_ZONE, "America/New_York");
+ runner.assertValid();
+
+ runner.setProperty(GetSplunk.TIME_ZONE, "UTC");
+ runner.assertValid();
+ }
+
@Test
public void testGetWithProvidedTime() {
final String query = "search tcp:7879";