Collections.emptyList().sort() does nothing
aph at redhat.com
Wed Nov 15 10:06:16 UTC 2017
On 15/11/17 10:03, Andrej Golovnin wrote:
> I think we would need to write ugly code in any case as Java 9 has now
> two empty list implementations: Collections.emptyList() and List.of().
> Collections.emptyList().sort() does not throw an exception.
> List.of().sort() throws an exception.
Well, that's a bug. Sorting an empty list is perfectly valid, and application
programmers shouldn't have to special-case it.
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the core-libs-dev