Skip to content

Fix broken sliding window logic in SlidingWindowGatherer - #19284

Open
soyeon1806 wants to merge 1 commit into
eugenp:masterfrom
soyeon1806:fix-sliding-window-gatherer-regression
Open

Fix broken sliding window logic in SlidingWindowGatherer#19284
soyeon1806 wants to merge 1 commit into
eugenp:masterfrom
soyeon1806:fix-sliding-window-gatherer-regression

Conversation

@soyeon1806

Copy link
Copy Markdown

SlidingWindowGatherer currently emits one single-element list per input
element instead of overlapping windows of three, which makes its own unit
test fail.

Cause

The state.size() == 3 guard was dropped from the integrator in
aae2714. 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:

Result
SlidingWindowGathererUnitTest expects [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
Current code produces [[1], [2], [3], [4], [5]]

The test asserts a window count of 3, so it fails with 5.

Changes

  • Restore the state.size() == 3 guard in integrator().
  • Remove the finisher() override. It returned an empty BiConsumer,
    which is exactly what Gatherer's default finisher already does. This
    addresses the remaining point of Unnecessary finisher #18683.

Why this went unnoticed

core-java-streams-7 requires JDK 24, so it is commented out in
core-java-modules/pom.xml and only listed under the default-jdk24 and
integration-jdk24 profiles. The module is not part of an ordinary build.

Refs #18683

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant