In Java Map, you can have null key and null values as well.
But when you are using Collectors.toMap() be wary not to have a KeyMapper and ValueMapper that will give null keys or null values.
Internally it uses Map.merge which will throw NPE if key or value is null. This is an open bug at JDK
Reference :
https://stackoverflow.com/questions/24630963/java-8-nullpointerexception-in-collectors-tomap
But when you are using Collectors.toMap() be wary not to have a KeyMapper and ValueMapper that will give null keys or null values.
Internally it uses Map.merge which will throw NPE if key or value is null. This is an open bug at JDK
Reference :
https://stackoverflow.com/questions/24630963/java-8-nullpointerexception-in-collectors-tomap
No comments:
Post a Comment