You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by tu...@apache.org on 2021/12/17 17:06:59 UTC

[nifi] branch main updated: NIFI-9461: Correcting equality comparison in Parameter update test

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

turcsanyi 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 66f36ea  NIFI-9461: Correcting equality comparison in Parameter update test
66f36ea is described below

commit 66f36eaf5ab5798d60cba59b0a7b1a758671f3c7
Author: Joe Gresock <jg...@gmail.com>
AuthorDate: Fri Dec 17 06:38:45 2021 -0500

    NIFI-9461: Correcting equality comparison in Parameter update test
    
    This closes #5609.
    
    Signed-off-by: Peter Turcsanyi <tu...@apache.org>
---
 .../java/org/apache/nifi/parameter/StandardParameterContext.java   | 3 ++-
 .../org/apache/nifi/parameter/TestStandardParameterContext.java    | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/parameter/StandardParameterContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/parameter/StandardParameterContext.java
index d17d31f..201ea6b 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/parameter/StandardParameterContext.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/parameter/StandardParameterContext.java
@@ -16,6 +16,7 @@
  */
 package org.apache.nifi.parameter;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.authorization.AccessDeniedException;
 import org.apache.nifi.authorization.Authorizer;
 import org.apache.nifi.authorization.RequestAction;
@@ -546,7 +547,7 @@ public class StandardParameterContext implements ParameterContext {
             if (currentEffectiveParameters.containsKey(proposedParameterDescriptor)) {
                 final Parameter currentParameter = currentEffectiveParameters.get(proposedParameterDescriptor);
                 if (!currentParameter.equals(proposedParameter) || currentParameter.getDescriptor().isSensitive() != proposedParameter.getDescriptor().isSensitive()
-                        || currentParameter.getDescriptor().getDescription() != proposedParameter.getDescriptor().getDescription()) {
+                        || !StringUtils.equals(currentParameter.getDescriptor().getDescription(), proposedParameter.getDescriptor().getDescription())) {
                     // The parameter has been updated in some way
                     effectiveParameterUpdates.put(proposedParameterDescriptor.getName(), proposedParameter);
                 }
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/parameter/TestStandardParameterContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/parameter/TestStandardParameterContext.java
index 4ad1650..0e826b7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/parameter/TestStandardParameterContext.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/parameter/TestStandardParameterContext.java
@@ -145,6 +145,13 @@ public class TestStandardParameterContext {
         final Parameter updatedParameter = new Parameter(xyzDescriptor2, "123");
         updates.put("xyz", updatedParameter);
         assertEquals(1, context.getEffectiveParameterUpdates(updates, Collections.emptyList()).size());
+
+        // Now there is no change, since the description is the same
+        final Map<String, Parameter> updates2 = new HashMap<>();
+        final ParameterDescriptor xyzDescriptor3 = new ParameterDescriptor.Builder().from(xyzDescriptor).description("changed").build();
+        final Parameter updatedParameter2 = new Parameter(xyzDescriptor3, "123");
+        updates.put("xyz", updatedParameter2);
+        assertEquals(0, context.getEffectiveParameterUpdates(updates2, Collections.emptyList()).size());
     }
 
     @Test