-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Annotate the parameter of
List.sort
as @Nullable
.
* Annotate the parameter of `List.sort` as `@Nullable`. This has always struck me as a weird feature, but people use it, and it "works" in the sense of "does not cause NPE" (though it may cause CCE...). I see both calls to `sort(null)` and calls like `sort(priorityQueue.comparator())` (which _might_ be `null`; [example](https://github.com/google/guava/blob/e82e2a2c07c68108f318958ee0355cc835c97743/guava-testlib/src/com/google/common/collect/testing/testers/SortedSetNavigationTester.java#L57)). And while I prefer a world in which methods like `comparator()` never return `null`, as we arranged for [in `SortedMultiset`](https://guava.dev/SortedMultiset#comparator()), there are apparently [downsides](google/guava#6187) to using a `Comparator` that implements natural order rather than using `null`. Also, Werner points us to `Arrays.sort`. (#13)
- Loading branch information
Showing
4 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters