This is an automated email from the ASF dual-hosted git repository.
chriss 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 244691edfe NIFI-14279 - StandardFlowDifference hashCode should include
fieldName
244691edfe is described below
commit 244691edfef0015ebca7bedebb4fa8f09a9f5f43
Author: Pierre Villard <[email protected]>
AuthorDate: Wed Feb 19 14:43:45 2025 +0100
NIFI-14279 - StandardFlowDifference hashCode should include fieldName
Signed-off-by: Chris Sampson <[email protected]>
This closes #9729.
---
.../registry/flow/diff/StandardFlowDifference.java | 18 ++++++++++-----
.../flow/diff/TestStandardFlowComparator.java | 27 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java
index c03480126e..6f37b5c164 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java
@@ -89,11 +89,16 @@ public class StandardFlowDifference implements
FlowDifference {
@Override
public int hashCode() {
- return 31 + 17 * (componentA == null ? 0 :
Objects.hashCode(componentA.getIdentifier())) +
- 17 * (componentB == null ? 0 :
Objects.hashCode(componentB.getIdentifier())) +
- 15 * (componentA == null ? 0 :
Objects.hash(componentA.getInstanceIdentifier())) +
- 15 * (componentB == null ? 0 :
Objects.hash(componentB.getInstanceIdentifier())) +
- Objects.hash(description, type, valueA, valueB);
+ return Objects.hash(
+ type,
+ componentA == null ? null : componentA.getIdentifier(),
+ componentA == null ? null : componentA.getInstanceIdentifier(),
+ componentB == null ? null : componentB.getIdentifier(),
+ componentB == null ? null : componentB.getInstanceIdentifier(),
+ fieldName.orElse(null),
+ valueA,
+ valueB,
+ description);
}
@Override
@@ -128,6 +133,7 @@ public class StandardFlowDifference implements
FlowDifference {
return Objects.equals(componentAId, otherComponentAId) &&
Objects.equals(componentBId, otherComponentBId)
&& Objects.equals(description, other.description) &&
Objects.equals(type, other.type)
- && Objects.equals(valueA, other.valueA) && Objects.equals(valueB,
other.valueB);
+ && Objects.equals(valueA, other.valueA) && Objects.equals(valueB,
other.valueB)
+ && fieldName.orElse("").equals(other.fieldName.orElse(""));
}
}
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
index 9bc40497b6..75206ad55d 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/test/java/org/apache/nifi/registry/flow/diff/TestStandardFlowComparator.java
@@ -149,6 +149,33 @@ public class TestStandardFlowComparator {
assertEquals(contextB.getIdentifier(),
difference.getComponentB().getIdentifier());
}
+ @Test
+ public void testMultipleParametersNamesChanged() {
+ final Set<FlowDifference> differences = new HashSet<>();
+
+ final Set<VersionedParameter> parametersA = new HashSet<>();
+ parametersA.add(createParameter("Param 1", "ABC", true));
+ parametersA.add(createParameter("Param 2", "XYZ", true));
+
+ final Set<VersionedParameter> parametersB = new HashSet<>();
+ parametersB.add(createParameter("New Param 1", "ABC", true));
+ parametersB.add(createParameter("New Param 2", "XYZ", true));
+
+ final VersionedParameterContext contextA = new
VersionedParameterContext();
+ contextA.setIdentifier("id");
+ contextA.setInstanceIdentifier("instanceId");
+ contextA.setParameters(parametersA);
+
+ final VersionedParameterContext contextB = new
VersionedParameterContext();
+ contextB.setIdentifier("id");
+ contextB.setInstanceIdentifier("instanceId");
+ contextB.setParameters(parametersB);
+
+ comparator.compare(contextA, contextB, differences);
+
+ assertEquals(4, differences.size());
+ }
+
private VersionedParameter createParameter(final String name, final String
value, final boolean sensitive) {
return createParameter(name, value, sensitive, null);
}