Skip to content

Commit

Permalink
Fix null pointer caused by non-existing library
Browse files Browse the repository at this point in the history
  • Loading branch information
pazi146 authored and azoitl committed Sep 20, 2024
1 parent 5a4d5f9 commit 86b3490
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,9 @@ private static LibraryRecord getLibraryRecord(final Map<String, List<LibraryReco
*/
private static LibraryRecord getLibraryRecord(final Map<String, List<LibraryRecord>> libs,
final String symbolicName, final VersionRange range) {
return libs.get(symbolicName).stream().filter(l -> range.includes(l.version()))
.sorted((o1, o2) -> o2.version().compareTo(o1.version())).findFirst().orElse(null);
return libs.getOrDefault(symbolicName, Collections.emptyList()).stream()
.filter(l -> range.includes(l.version())).sorted((o1, o2) -> o2.version().compareTo(o1.version()))
.findFirst().orElse(null);
}

/**
Expand All @@ -967,7 +968,7 @@ private static LibraryRecord getLibraryRecord(final Map<String, List<LibraryReco
*/
private static LibraryRecord getLibraryRecord(final Map<String, List<LibraryRecord>> libs,
final String symbolicName, final java.net.URI uri) {
return libs.get(symbolicName).stream().filter(l -> l.uri().equals(uri))
return libs.getOrDefault(symbolicName, Collections.emptyList()).stream().filter(l -> l.uri().equals(uri))
.sorted((o1, o2) -> o2.version().compareTo(o1.version())).findFirst().orElse(null);
}

Expand Down

0 comments on commit 86b3490

Please sign in to comment.