On Wed, 1 Nov 2023 15:39:11 GMT, Brian Goetz <briango...@openjdk.org> wrote:

>> src/java.base/share/classes/java/util/stream/AbstractPipeline.java line 223:
>> 
>>> 221:         previousStage.linkedOrConsumed = true;
>>> 222: 
>>> 223:         previousPreviousStage.nextStage = this;
>> 
>> This allows subclasses to replace the "end" of a pipeline with a new "end" 
>> presuming that the previous "end" is not linked nor consumed. As an example, 
>> it allows a GathererOp(gathererA) to be replaced with a 
>> GathererOp(gathererA.andThen(gathererB))
>
> The constraint of "not linked or consumed" should be stated in the spec here, 
> and probably documented with an `@throws` tag.

Since you validate that previous^2.next == previous, you might just omit the 
`previousStage` parameter and derive it in the body.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16420#discussion_r1378968421

Reply via email to