On Sun, 5 Nov 2023 16:43:33 GMT, Tagir F. Valeev <tval...@openjdk.org> wrote:
>> This Pull-Request implements [JEP-461](https://openjdk.org/jeps/461) > > src/java.base/share/classes/java/util/stream/GathererOp.java line 162: > >> 160: * consideration at this point doesn't yield any >> performance gains. >> 161: */ >> 162: proceed &= integrator.integrate(state, t, this); > > Note that you are exposing the `GatherSink` object to the clients, and it > implements a public `Consumer` interface. Clients may use > `((Consumer<T>)downstream).accept(something)`, which may produce > unpredictable results. Not sure if this is considered to be a problem, but > somebody will certainly try to do this! @amaembo Sorry, I completely missed this comment. I did some research before this and, in fact, this already happens for `mapMulti` (https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/stream/ReferencePipeline.java#L450) and blind-casting to implementation details is not advisable. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16420#discussion_r1387106067