Slightly deceiving error message on Collectors.toMap
misterm at gmail.com
Wed Apr 16 20:18:53 UTC 2014
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
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?
More information about the lambda-dev