Fix broken sliding window logic in SlidingWindowGatherer - #19284
Open
soyeon1806 wants to merge 1 commit into
Open
Fix broken sliding window logic in SlidingWindowGatherer#19284soyeon1806 wants to merge 1 commit into
soyeon1806 wants to merge 1 commit into
Conversation
Commit aae2714 removed the `state.size() == 3` guard from the integrator. Without it, every element is pushed downstream and then immediately dropped, so the gatherer emits one single-element list per input instead of overlapping windows of three. For the stream 1..5, SlidingWindowGathererUnitTest expects [[1, 2, 3], [2, 3, 4], [3, 4, 5]], but the current code produces [[1], [2], [3], [4], [5]] and fails on the window-count assertion. Restoring the guard also lets the finisher() override go away: it returned an empty BiConsumer, which is exactly what the default finisher of Gatherer already does. Refs eugenp#18683
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SlidingWindowGatherercurrently emits one single-element list per inputelement instead of overlapping windows of three, which makes its own unit
test fail.
Cause
The
state.size() == 3guard was dropped from the integrator inaae2714. Without the guard, each element is pushed downstream and then
immediately removed from the state, so the window never grows past one.
For the stream
1..5:SlidingWindowGathererUnitTestexpects[[1, 2, 3], [2, 3, 4], [3, 4, 5]][[1], [2], [3], [4], [5]]The test asserts a window count of 3, so it fails with 5.
Changes
state.size() == 3guard inintegrator().finisher()override. It returned an emptyBiConsumer,which is exactly what
Gatherer's default finisher already does. Thisaddresses the remaining point of Unnecessary finisher #18683.
Why this went unnoticed
core-java-streams-7requires JDK 24, so it is commented out incore-java-modules/pom.xmland only listed under thedefault-jdk24andintegration-jdk24profiles. The module is not part of an ordinary build.Refs #18683