Skip to content

Fixes a bug in WindmillSet.addIfAbsent. - #40748

Merged
chamikaramj merged 2 commits into
apache:masterfrom
acrites:windmill-set-fix1
Oct 31, 2026
Merged

chamikaramj merged 2 commits into
apache:masterfrom
acrites:windmill-set-fix1

Conversation

@acrites

@acrites acrites commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

putState.read() returns null if the element was newly added, so this method was always returning false.

Added a unit test demonstrating this bug and since there were no basic unit tests for this class, added some as well.

@github-actions github-actions Bot added runners dataflow size/m M: 50-249 lines changed labels Oct 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR fixes a bug in WindmillSet.addIfAbsent where the inverted null check on windmillMap.putIfAbsent's result caused the method to always return false. It also introduces a comprehensive unit test suite in WindmillSetTest covering addIfAbsent as well as core SetState operations.

🔍 General Feedback

  • The fix accurately aligns WindmillSet.addIfAbsent with the SetState.addIfAbsent and MapState.putIfAbsent contracts (putIfAbsent returns null when the key was absent, meaning the element was newly added to the set).
  • The newly added unit tests are clean, well-structured, and thoroughly test the expected behavior.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.97%. Comparing base (76f6e6d) to head (d802c03).
⚠️ Report is 319 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master   #40748       +/-   ##
=============================================
+ Coverage     56.16%   75.97%   +19.80%     
+ Complexity     2288     2273       -15     
=============================================
  Files          1124      259      -865     
  Lines        178336    14377   -163959     
  Branches       1489     1479       -10     
=============================================
- Hits         100170    10923    -89247     
+ Misses        75645     2763    -72882     
+ Partials       2521      691     -1830     
Flag Coverage Δ
go ?
java 75.97% <ø> (+0.18%) ⬆️
python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @chamikaramj added as fallback since no labels match configuration
Backup reviewer: damccorm (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@acrites

acrites commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

In case this helps:

WindmillSet.addIfAbsent() returns true if the element is added to the set as a result of the call and false if it was already in the set.

The implementation calls windmillMap.putIfAbsent(k, true); and putIfAbsent() returns null if the element was not already in the map, otherwise it returns the mapped-to value. We never map keys to anything other than true.

@chamikaramj chamikaramj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@chamikaramj
chamikaramj merged commit aba9e79 into apache:master Oct 31, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants