From 10f27cd5f0c077ad99848453ecaa253ca8ee5f9a Mon Sep 17 00:00:00 2001 From: Mark Owens Date: Fri, 20 Oct 2017 11:54:54 -0400 Subject: [PATCH] NIFI-2979 PriorityAttributePrioritizer violates Comparator contract. This closes #2220. Modified the return value when both objects priority values are null to zero to match the expected return value based upon the Comparator contract. --- .../apache/nifi/prioritizer/PriorityAttributePrioritizer.java | 2 +- .../nifi/prioritizer/PriorityAttributePrioritizerTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/main/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/main/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizer.java index 3d27930553..fdd963e65b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/main/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizer.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/main/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizer.java @@ -49,7 +49,7 @@ public class PriorityAttributePrioritizer implements FlowFilePrioritizer { String o1Priority = o1.getAttribute(CoreAttributes.PRIORITY.key()); String o2Priority = o2.getAttribute(CoreAttributes.PRIORITY.key()); if (o1Priority == null && o2Priority == null) { - return -1; // this is not 0 to match FirstInFirstOut + return 0; } else if (o2Priority == null) { return -1; } else if (o1Priority == null) { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/test/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizerTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/test/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizerTest.java index 709855102b..d6ed2dc98c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/test/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizerTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-standard-prioritizers/src/test/java/org/apache/nifi/prioritizer/PriorityAttributePrioritizerTest.java @@ -83,7 +83,7 @@ public class PriorityAttributePrioritizerTest { assertEquals(-1, prioritizer.compare(ffNoPriority, null)); assertEquals(1, prioritizer.compare(null, ffNoPriority)); - assertEquals(-1, prioritizer.compare(ffNoPriority, ffNoPriority)); + assertEquals(0, prioritizer.compare(ffNoPriority, ffNoPriority)); assertEquals(-1, prioritizer.compare(ffPri1, ffNoPriority)); assertEquals(1, prioritizer.compare(ffNoPriority, ffPri1));