Slightly deceiving error message on Collectors.toMap

Michael Nascimento misterm at gmail.com
Thu Apr 17 19:37:37 UTC 2014


First of all, the bug:

https://bugs.openjdk.java.net/browse/JDK-8040892

On Thu, Apr 17, 2014 at 3:51 PM, Peter Levart <peter.levart at gmail.com> wrote:
> Or, more generaly: "two elements of resulting stream, which I can't tell
> you, mapped to the same key, which I can't tell you either, but they also
> mapped to values V1 and V2", ...

Exactly...

> Original elements are lost by the time two maps get merged together, but the
> duplicate key could be retrieved with a little trickery:
>
>
> http://cr.openjdk.java.net/~plevart/jdk9-dev/Collectors.duplicateKey/webrev.01/

Hmmm, if Brian approves using this spare Exception subclass, I suggest
extracting the creation of the accumulator into its own method.

Regards,
Michael


More information about the lambda-dev mailing list