Skip to content

Commit 54092fc

Browse files
authored
Merge pull request #930 from Isira-Seneviratne/Avoid_Comparator_NPE
Avoid possible NullPointerException in MediaCCCRecentKiosk.
2 parents d7c23ef + 0e31c86 commit 54092fc

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1313
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
1414
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
15+
import org.schabi.newpipe.extractor.localization.DateWrapper;
1516
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1617
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1718

@@ -49,12 +50,12 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, Extrac
4950

5051
// Streams in the recent kiosk are not ordered by the release date.
5152
// Sort them to have the latest stream at the beginning of the list.
52-
Comparator<StreamInfoItem> comparator = Comparator.comparing(
53-
streamInfoItem -> streamInfoItem.getUploadDate().offsetDateTime());
54-
comparator = comparator.reversed();
55-
56-
final StreamInfoItemsCollector collector =
57-
new StreamInfoItemsCollector(getServiceId(), comparator);
53+
final Comparator<StreamInfoItem> comparator = Comparator
54+
.comparing(StreamInfoItem::getUploadDate, Comparator
55+
.nullsLast(Comparator.comparing(DateWrapper::offsetDateTime)))
56+
.reversed();
57+
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId(),
58+
comparator);
5859

5960
events.stream()
6061
.filter(JsonObject.class::isInstance)

0 commit comments

Comments
 (0)