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

bejancsaba pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new b95004012b Revert "NIFI-13831: Adding inheritance to versioned 
component synchronizer parameter context synchronization when considering 
referencing components to restart"
b95004012b is described below

commit b95004012b1392dff085bd3e429aeba5fb19f8d7
Author: Csaba Bejan <[email protected]>
AuthorDate: Fri Oct 4 19:56:49 2024 -0400

    Revert "NIFI-13831: Adding inheritance to versioned component synchronizer 
parameter context synchronization when considering referencing components to 
restart"
    
    This reverts commit abc5c328f10451cc4d7cb9d06136477f1d5fdce9.
    The changes contained Java 8 incompatible parts in the test and I validated 
on Java 17 before pushing. Reverting and correcting it.
---
 .../StandardVersionedComponentSynchronizer.java    | 16 +---------
 ...StandardVersionedComponentSynchronizerTest.java | 34 ++++------------------
 2 files changed, 7 insertions(+), 43 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
index a2c702c704..12420e3764 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizer.java
@@ -1656,26 +1656,12 @@ public class StandardVersionedComponentSynchronizer 
implements VersionedComponen
         }
     }
 
-    private void collectValueAndReferences(final ParameterContext 
parameterContext, final Map<String, String> valueAndRef) {
-        parameterContext.getEffectiveParameters()
-                .forEach((pd, param) -> valueAndRef.put(pd.getName(), 
param.getValue()));
-    }
-
     protected Set<String> getUpdatedParameterNames(final ParameterContext 
parameterContext, final VersionedParameterContext proposed) {
         final Map<String, String> originalValues = new HashMap<>();
-        collectValueAndReferences(parameterContext, originalValues);
+        parameterContext.getParameters().values().forEach(param -> 
originalValues.put(param.getDescriptor().getName(), param.getValue()));
 
         final Map<String, String> proposedValues = new HashMap<>();
         if (proposed != null) {
-            if (proposed.getInheritedParameterContexts() != null) {
-                for (int i = proposed.getInheritedParameterContexts().size() - 
1; i >= 0; i--) {
-                    final String name = 
proposed.getInheritedParameterContexts().get(i);
-                    final ParameterContext inheritedContext = 
getParameterContextByName(name);
-                    if (inheritedContext != null) {
-                        collectValueAndReferences(inheritedContext, 
proposedValues);
-                    }
-                }
-            }
             proposed.getParameters().forEach(versionedParam -> 
proposedValues.put(versionedParam.getName(), versionedParam.getValue()));
         }
 
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizerTest.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizerTest.java
index 64dc2dea8d..0ec1e8df66 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizerTest.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/flow/synchronization/StandardVersionedComponentSynchronizerTest.java
@@ -1061,30 +1061,30 @@ public class StandardVersionedComponentSynchronizerTest 
{
 
         // Test no changes
         Map<String, String> parameterMap = new HashMap<>(originalParams);
-        VersionedParameterContext proposed = 
createVersionedParameterContext("Context 1", parameterMap, 
Collections.singleton("secret"));
+        VersionedParameterContext proposed = 
createVersionedParameterContext("Context 2", parameterMap, 
Collections.singleton("secret"));
         assertEquals(Collections.emptySet(), 
synchronizer.getUpdatedParameterNames(existing, proposed));
 
         // Test non-sensitive param change
         parameterMap = new HashMap<>(originalParams);
         parameterMap.put("abc", "hello");
-        proposed = createVersionedParameterContext("Context 1", parameterMap, 
Collections.singleton("secret"));
+        proposed = createVersionedParameterContext("Context 2", parameterMap, 
Collections.singleton("secret"));
         assertEquals(Collections.singleton("abc"), 
synchronizer.getUpdatedParameterNames(existing, proposed));
 
         // Test sensitive param change
         parameterMap = new HashMap<>(originalParams);
         parameterMap.put("secret", "secret");
-        proposed = createVersionedParameterContext("Context 1", parameterMap, 
Collections.singleton("secret"));
+        proposed = createVersionedParameterContext("Context 2", parameterMap, 
Collections.singleton("secret"));
         assertEquals(Collections.singleton("secret"), 
synchronizer.getUpdatedParameterNames(existing, proposed));
 
         // Test removed parameters
         parameterMap.clear();
-        proposed = createVersionedParameterContext("Context 1", parameterMap, 
Collections.singleton("secret"));
+        proposed = createVersionedParameterContext("Context 2", parameterMap, 
Collections.singleton("secret"));
         assertEquals(new HashSet<>(Arrays.asList("abc", "secret")), 
synchronizer.getUpdatedParameterNames(existing, proposed));
 
         // Test added parameter
         parameterMap = new HashMap<>(originalParams);
         parameterMap.put("Added", "Added");
-        proposed = createVersionedParameterContext("Context 1", parameterMap, 
Collections.singleton("secret"));
+        proposed = createVersionedParameterContext("Context 2", parameterMap, 
Collections.singleton("secret"));
         assertEquals(Collections.singleton("Added"), 
synchronizer.getUpdatedParameterNames(existing, proposed));
 
         // Test added, removed, and updated parameters
@@ -1093,30 +1093,8 @@ public class StandardVersionedComponentSynchronizerTest {
         parameterMap.put("Added 2", "Added");
         parameterMap.remove("secret");
         parameterMap.put("abc", "hello");
-        proposed = createVersionedParameterContext("Context 1", parameterMap, 
Collections.singleton("secret"));
+        proposed = createVersionedParameterContext("Context 2", parameterMap, 
Collections.singleton("secret"));
         assertEquals(new HashSet<>(Arrays.asList("abc", "secret", "Added", 
"Added 2")), synchronizer.getUpdatedParameterNames(existing, proposed));
-
-        // Test change value due to inherited parameter context reordering
-        final Map<String, String> inheritedParameters = new HashMap<>();
-        // Context 1: abc = xyz
-        // Context 3: abc = def
-        inheritedParameters.put("abc", "def");
-        final VersionedParameterContext context3 = 
createVersionedParameterContext("Context 3", inheritedParameters, 
Collections.emptySet());
-
-        synchronizer.synchronize(null, context3, synchronizationOptions);
-
-        parameterMap = new HashMap<>();
-        proposed = createVersionedParameterContext("Context 2", parameterMap, 
Collections.emptySet());
-        synchronizer.synchronize(null, proposed, synchronizationOptions);
-
-        ParameterContext context2 = 
parameterContextManager.getParameterContextNameMapping().get("Context 2");
-        proposed.setInheritedParameterContexts(List.of("Context 1", "Context 
3"));
-        synchronizer.synchronize(context2, proposed, synchronizationOptions);
-
-        proposed.setInheritedParameterContexts(List.of("Context 3", "Context 
1"));
-        context2 = 
parameterContextManager.getParameterContextNameMapping().get("Context 2");
-        // The effective value of abc should change here due to the reordering
-        assertEquals(Collections.singleton("abc"), 
synchronizer.getUpdatedParameterNames(context2, proposed));
     }
 
     @Test

Reply via email to