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.
This commit is contained in:
Mark Owens 2017-10-20 11:54:54 -04:00 committed by Mark Payne
parent c06dee2321
commit 10f27cd5f0
2 changed files with 2 additions and 2 deletions

View File

@ -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) {

View File

@ -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));