Slightly deceiving error message on Collectors.toMap
Michael Nascimento
misterm at gmail.com
Wed Apr 16 20:18:53 UTC 2014
Hi folks,
For this very short test case:
Stream.of(1, 1).collect(toMap(identity(), Integer::reverse));
The following exception is produced:
java.lang.IllegalStateException: Duplicate key -2147483648
at java.util.stream.Collectors.lambda$throwingMerger$90(Collectors.java:133)
Obviously, the value being printed is not a key, but a value of the
map. Since capturing the actual key does not seem possible, I suggest
changing this message to something like:
Duplicate values for a key %s %s
And include both of them in the error message.
Should I file a bug for this?
Regards,
Michael
More information about the lambda-dev
mailing list