Merge pull request #4684 from ByteHamster/fix-null-pubdate-crash

Fixed comparator method contract when date is null
This commit is contained in:
ByteHamster 2020-11-15 12:26:52 +01:00 committed by GitHub
commit 97b557a3b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -14,8 +14,12 @@ public class FeedItemPubdateComparator implements Comparator<FeedItem> {
*/
@Override
public int compare(FeedItem lhs, FeedItem rhs) {
if (rhs.getPubDate() == null || lhs.getPubDate() == null) {
if (rhs.getPubDate() == null && lhs.getPubDate() == null) {
return 0;
} else if (rhs.getPubDate() == null) {
return 1;
} else if (lhs.getPubDate() == null) {
return -1;
}
return rhs.getPubDate().compareTo(lhs.getPubDate());
}