mirror of https://github.com/apache/nifi.git
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:
parent
c06dee2321
commit
10f27cd5f0
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue