You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2024/01/02 17:43:12 UTC

(nifi) branch main updated: NIFI-12531 Parameter references are removed after property migration

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

pvillard 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 1a34208f65 NIFI-12531 Parameter references are removed after property migration
1a34208f65 is described below

commit 1a34208f65681bd13d5450407dcf6719daeeef37
Author: krisztina-zsihovszki <zs...@gmail.com>
AuthorDate: Thu Dec 21 12:24:44 2023 +0100

    NIFI-12531 Parameter references are removed after property migration
    
    Signed-off-by: Pierre Villard <pi...@gmail.com>
    
    This closes #8176.
---
 .../org/apache/nifi/controller/StandardProcessorNode.java    |  2 +-
 .../nifi/controller/reporting/AbstractReportingTaskNode.java |  2 +-
 .../controller/service/StandardControllerServiceNode.java    |  2 +-
 .../apache/nifi/migration/StandardPropertyConfiguration.java |  5 +++++
 .../nifi/migration/TestStandardPropertyConfiguration.java    | 12 ++++++++++++
 .../java/org/apache/nifi/processors/standard/InvokeHTTP.java |  1 -
 6 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
index 28f45cf82c..812b80b29d 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
@@ -2110,7 +2110,7 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
             final List<ControllerServiceCreationDetails> servicesCreated = propertyConfig.getCreatedServices();
             servicesCreated.forEach(serviceFactory::create);
 
-            overwriteProperties(propertyConfig.getProperties());
+            overwriteProperties(propertyConfig.getRawProperties());
         }
     }
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
index 6ea63a26e0..a6fdb84c55 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/reporting/AbstractReportingTaskNode.java
@@ -452,7 +452,7 @@ public abstract class AbstractReportingTaskNode extends AbstractComponentNode im
             final List<ControllerServiceCreationDetails> servicesCreated = propertyConfig.getCreatedServices();
             servicesCreated.forEach(serviceFactory::create);
 
-            overwriteProperties(propertyConfig.getProperties());
+            overwriteProperties(propertyConfig.getRawProperties());
         }
     }
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
index f6231c5e3d..78cad4a151 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
@@ -858,7 +858,7 @@ public class StandardControllerServiceNode extends AbstractComponentNode impleme
             final List<ControllerServiceCreationDetails> servicesCreated = propertyConfig.getCreatedServices();
             servicesCreated.forEach(serviceFactory::create);
 
-            overwriteProperties(propertyConfig.getProperties());
+            overwriteProperties(propertyConfig.getRawProperties());
         }
     }
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardPropertyConfiguration.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardPropertyConfiguration.java
index 8b8b2fd59a..c724707d23 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardPropertyConfiguration.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/migration/StandardPropertyConfiguration.java
@@ -57,6 +57,11 @@ public class StandardPropertyConfiguration implements PropertyConfiguration {
             return false;
         }
 
+        if (Objects.equals(propertyName, newName)) {
+            logger.debug("Will not update property [{}] for [{}] because the new name and the current name are the same", propertyName, componentDescription);
+            return false;
+        }
+
         final String effectivePropertyValue = effectiveProperties.remove(propertyName);
         effectiveProperties.put(newName, effectivePropertyValue);
 
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/migration/TestStandardPropertyConfiguration.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/migration/TestStandardPropertyConfiguration.java
index 664e27d0b6..de4376d212 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/migration/TestStandardPropertyConfiguration.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/migration/TestStandardPropertyConfiguration.java
@@ -107,6 +107,18 @@ public class TestStandardPropertyConfiguration {
         assertEquals(expectedProperties, config.getProperties());
     }
 
+    @Test
+    public void testRenamePropertyToSameName() {
+        assertFalse(config.renameProperty("a", "a"));
+
+        assertFalse(config.isModified());
+        assertTrue(config.hasProperty("a"));
+        assertTrue(config.isPropertySet("a"));
+
+        final Map<String, String> expectedProperties = new HashMap<>(originalProperties);
+        assertEquals(expectedProperties, config.getProperties());
+    }
+
     @Test
     public void testRenameNullProperty() {
         assertTrue(config.renameProperty("c", "X"));
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
index 67eeaab801..fc378e0ce8 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
@@ -597,7 +597,6 @@ public class InvokeHTTP extends AbstractProcessor {
 
     @Override
     public void migrateProperties(final PropertyConfiguration config) {
-        config.renameProperty("Connection Timeout", SOCKET_CONNECT_TIMEOUT.getName());
         config.renameProperty("Read Timeout", SOCKET_READ_TIMEOUT.getName());
         config.renameProperty("Remote URL", HTTP_URL.getName());
         config.renameProperty("disable-http2", HTTP2_DISABLED.getName());