Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b105
-
Verified
Description
The following line
Collections.emptyList().sort((Comparator)null);
Leads to
Exception in thread "main" java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Collections$EmptyList.sort(Collections.java:4523)
While the spec on j.u.List.sort(Comparator) says:
"A null value indicates that the elements' natural ordering should be used"
In the implementation this looks like a result of a copy-paste mistake.
The following JCK test will fail:
api/java_util/Collections/empty/EmptyListSort.html#EmptyListSort[elementSettingNotSupported_naturalSorting]
Collections.emptyList().sort((Comparator)null);
Leads to
Exception in thread "main" java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Collections$EmptyList.sort(Collections.java:4523)
While the spec on j.u.List.sort(Comparator) says:
"A null value indicates that the elements' natural ordering should be used"
In the implementation this looks like a result of a copy-paste mistake.
The following JCK test will fail:
api/java_util/Collections/empty/EmptyListSort.html#EmptyListSort[elementSettingNotSupported_naturalSorting]
Attachments
Issue Links
- relates to
-
JDK-8001647 default methods for Collections - forEach, removeIf, replaceAll, sort
- Closed