This is an automated email from the ASF dual-hosted git repository.
exceptionfactory 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 6ab2b15b29 NIFI-14985 Fixed Dynamic Property determination for
filtering differences as environmental changes (#10326)
6ab2b15b29 is described below
commit 6ab2b15b29547eea840bafab9807989e15ea10f0
Author: Pierre Villard <[email protected]>
AuthorDate: Fri Sep 19 15:25:51 2025 +0200
NIFI-14985 Fixed Dynamic Property determination for filtering differences
as environmental changes (#10326)
Signed-off-by: David Handermann <[email protected]>
---
.../org/apache/nifi/util/FlowDifferenceFilters.java | 9 ++-------
.../apache/nifi/util/TestFlowDifferenceFilters.java | 19 +++++++++++++------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
index 8e917a9058..8e07238e84 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
@@ -112,12 +112,7 @@ public class FlowDifferenceFilters {
}
- private static boolean supportsDynamicProperties(final
ConfigurableComponent component, final String propertyName) {
- final PropertyDescriptor descriptor =
component.getPropertyDescriptor(propertyName);
- if (descriptor != null && descriptor.isDynamic()) {
- return true;
- }
-
+ private static boolean supportsDynamicProperties(final
ConfigurableComponent component) {
final Class<?> componentClass = component.getClass();
return componentClass.isAnnotationPresent(DynamicProperty.class) ||
componentClass.isAnnotationPresent(DynamicProperties.class);
}
@@ -474,7 +469,7 @@ public class FlowDifferenceFilters {
return false;
}
- if (supportsDynamicProperties(configurableComponent, propertyName)) {
+ if (supportsDynamicProperties(configurableComponent)) {
return false;
}
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
index 88679e74b5..78c53065ba 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java
@@ -16,6 +16,7 @@
*/
package org.apache.nifi.util;
+import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.components.ConfigurableComponent;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ProcessorNode;
@@ -26,6 +27,9 @@ import org.apache.nifi.flow.VersionedControllerService;
import org.apache.nifi.flow.VersionedPort;
import org.apache.nifi.flow.VersionedProcessor;
import org.apache.nifi.flow.VersionedRemoteGroupPort;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.registry.flow.diff.DifferenceType;
import org.apache.nifi.registry.flow.diff.FlowDifference;
import org.apache.nifi.registry.flow.diff.StandardFlowDifference;
@@ -220,17 +224,13 @@ public class TestFlowDifferenceFilters {
public void
testIsStaticPropertyRemovedFromDefinitionWhenDynamicSupported() {
final FlowManager flowManager = Mockito.mock(FlowManager.class);
final ProcessorNode processorNode = Mockito.mock(ProcessorNode.class);
- final ConfigurableComponent configurableComponent =
Mockito.mock(ConfigurableComponent.class);
+ final ConfigurableComponent configurableComponent = new
DynamicAnnotationProcessor();
final String propertyName = "Dynamic Property";
final String instanceId = "processor-instance";
- final PropertyDescriptor dynamicDescriptor = new
PropertyDescriptor.Builder().name(propertyName).dynamic(true).build();
-
Mockito.when(flowManager.getProcessorNode(instanceId)).thenReturn(processorNode);
Mockito.when(processorNode.getComponent()).thenReturn(configurableComponent);
-
Mockito.when(configurableComponent.getPropertyDescriptors()).thenReturn(List.of());
-
Mockito.when(configurableComponent.getPropertyDescriptor(propertyName)).thenReturn(dynamicDescriptor);
final InstantiatedVersionedProcessor localProcessor = new
InstantiatedVersionedProcessor(instanceId, "group-id");
final FlowDifference difference = new StandardFlowDifference(
@@ -241,7 +241,14 @@ public class TestFlowDifferenceFilters {
"old",
null,
"Dynamic property removed");
-
assertFalse(FlowDifferenceFilters.isStaticPropertyRemoved(difference,
flowManager));
}
+
+ @DynamicProperty(name = "Dynamic Property", value = "Value", description =
"Allows dynamic properties")
+ private static class DynamicAnnotationProcessor extends AbstractProcessor {
+ @Override
+ public void onTrigger(final ProcessContext context, final
ProcessSession session) {
+ // No-op for testing
+ }
+ }
}