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

bbende pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new a2edc2a  NIFI-6025: Fixed bug that caused Flows to indicate that they 
have been locally modified (when they hadn't been) when running against 
versions of the registry older than 0.5.0
a2edc2a is described below

commit a2edc2aa870ee465b70d9b5e319548e478e481a9
Author: Mark Payne <[email protected]>
AuthorDate: Tue Sep 3 11:19:47 2019 -0400

    NIFI-6025: Fixed bug that caused Flows to indicate that they have been 
locally modified (when they hadn't been) when running against versions of the 
registry older than 0.5.0
    
    This closes #3687.
    
    Signed-off-by: Bryan Bende <[email protected]>
---
 .../org/apache/nifi/groups/StandardProcessGroup.java     |  1 +
 .../java/org/apache/nifi/util/FlowDifferenceFilters.java | 16 ++++++++++++++++
 .../org/apache/nifi/web/StandardNiFiServiceFacade.java   |  1 +
 .../java/org/apache/nifi/web/api/dto/DtoFactory.java     |  7 +++++++
 4 files changed, 25 insertions(+)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index 858d826..5256552 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -4737,6 +4737,7 @@ public final class StandardProcessGroup implements 
ProcessGroup {
                 
.filter(FlowDifferenceFilters.FILTER_IGNORABLE_VERSIONED_FLOW_COORDINATE_CHANGES)
                 .filter(diff -> 
!FlowDifferenceFilters.isNewPropertyWithDefaultValue(diff, flowManager))
                 .filter(diff -> 
!FlowDifferenceFilters.isNewRelationshipAutoTerminatedAndDefaulted(diff, 
versionedGroup, flowManager))
+                .filter(diff -> 
!FlowDifferenceFilters.isScheduledStateNew(diff))
                 .collect(Collectors.toCollection(HashSet::new));
 
         LOG.debug("There are {} differences between this Local Flow and the 
Versioned Flow: {}", differences.size(), differences);
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
index d594f5f..bc64d5e 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/FlowDifferenceFilters.java
@@ -23,6 +23,7 @@ import org.apache.nifi.controller.flow.FlowManager;
 import org.apache.nifi.controller.service.ControllerServiceNode;
 import org.apache.nifi.processor.Relationship;
 import org.apache.nifi.registry.flow.ComponentType;
+import org.apache.nifi.registry.flow.ScheduledState;
 import org.apache.nifi.registry.flow.VersionedComponent;
 import org.apache.nifi.registry.flow.VersionedConnection;
 import org.apache.nifi.registry.flow.VersionedFlowCoordinates;
@@ -163,6 +164,21 @@ public class FlowDifferenceFilters {
         return false;
     }
 
+    public static boolean isScheduledStateNew(final FlowDifference fd) {
+        if (fd.getDifferenceType() != DifferenceType.SCHEDULED_STATE_CHANGED) {
+            return false;
+        }
+
+        // If Scheduled State transitions from null to ENABLED or ENABLED to 
null, consider it a "new" scheduled state.
+        if (fd.getValueA() == null && 
ScheduledState.ENABLED.equals(fd.getValueB())) {
+            return true;
+        }
+        if (fd.getValueB() == null && "ENABLED".equals(fd.getValueA())) {
+            return true;
+        }
+
+        return false;
+    }
 
     public static boolean isNewRelationshipAutoTerminatedAndDefaulted(final 
FlowDifference fd, final VersionedProcessGroup processGroup, final FlowManager 
flowManager) {
         if (fd.getDifferenceType() != 
DifferenceType.AUTO_TERMINATED_RELATIONSHIPS_CHANGED) {
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index cbc5ec2..8ebeec9 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -4569,6 +4569,7 @@ public class StandardNiFiServiceFacade implements 
NiFiServiceFacade {
             
.filter(FlowDifferenceFilters.FILTER_IGNORABLE_VERSIONED_FLOW_COORDINATE_CHANGES)
             .filter(diff -> 
!FlowDifferenceFilters.isNewPropertyWithDefaultValue(diff, flowManager))
             .filter(diff -> 
!FlowDifferenceFilters.isNewRelationshipAutoTerminatedAndDefaulted(diff, 
proposedFlow.getContents(), flowManager))
+            .filter(diff -> !FlowDifferenceFilters.isScheduledStateNew(diff))
             .map(difference -> {
                 final VersionedComponent localComponent = 
difference.getComponentA();
 
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
index d2d331d..3be7ae7 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
@@ -2454,6 +2454,13 @@ public final class DtoFactory {
                 continue;
             }
 
+            // Ignore differences that are the result of the Versioned Flow 
not having a Scheduled State and the newer flow being "ENABLED". We do this 
because
+            // Scheduled State was not always part of the Versioned Flow - it 
was always assumed to be ENABLED. We don't want flows that were previously 
stored in this
+            // format to now be considered different than the local flow.
+            if (FlowDifferenceFilters.isScheduledStateNew(difference)) {
+                continue;
+            }
+
             // Ignore differences for adding remote ports
             if (FlowDifferenceFilters.isAddedOrRemovedRemotePort(difference)) {
                 continue;

Reply via email to