Details
-
Bug
-
Resolution: Fixed
-
Medium
-
3.7, 3.7.1
-
3.07
-
Description
Fix implementation of CustomFieldImpl.compare(Issue, Issue) method (around line 1294)
... SortableCustomField sortable = (SortableCustomField) customFieldType; FieldConfig c1 = getRelevantConfig(issue1); FieldConfig c2 = getRelevantConfig(issue2); if (c1 != null && c1.equals(c2)) { return sortable.compare(v1, v2, c1); } else { log.info("Sort order for custom field " + this + " for issues " + issue1 + " and " + issue2 + " " + "contexts did not match. Sort order may be incorrect"); return sortable.compare(v1, v2, c1); } ...
Notice that if and else bodies are almost identical (except the extra log info message). The problem is that the contract of
SortableCustomField.compare(Object v1, Object v2, FieldConfig fc)
says that v1 nor v2 should be nulls. The code above does not guarantee that.
The code should make appropriate null checks and only call compare with valid values. Also write tests that will execrise this code comprehensively.