From 0e31c86aee8f81e57233cbaec5c822781cebf906 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 21 Sep 2022 05:40:07 +0530 Subject: [PATCH] Avoid possible NullPointerException in MediaCCCRecentKiosk. --- .../media_ccc/extractors/MediaCCCRecentKiosk.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java index 27c1ce9a1..94d3b0a62 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java @@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; +import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; @@ -49,12 +50,12 @@ public class MediaCCCRecentKiosk extends KioskExtractor { // Streams in the recent kiosk are not ordered by the release date. // Sort them to have the latest stream at the beginning of the list. - Comparator comparator = Comparator.comparing( - streamInfoItem -> streamInfoItem.getUploadDate().offsetDateTime()); - comparator = comparator.reversed(); - - final StreamInfoItemsCollector collector = - new StreamInfoItemsCollector(getServiceId(), comparator); + final Comparator comparator = Comparator + .comparing(StreamInfoItem::getUploadDate, Comparator + .nullsLast(Comparator.comparing(DateWrapper::offsetDateTime))) + .reversed(); + final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId(), + comparator); events.stream() .filter(JsonObject.class::isInstance)