Skip to content

fix: unify DeployStrategy empty-array errors to NoSuchElementException#5029

Open
Ma77Ball wants to merge 3 commits into
apache:mainfrom
Ma77Ball:fix/unifyExceptions
Open

fix: unify DeployStrategy empty-array errors to NoSuchElementException#5029
Ma77Ball wants to merge 3 commits into
apache:mainfrom
Ma77Ball:fix/unifyExceptions

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

@Ma77Ball Ma77Ball commented May 12, 2026

What changes were proposed in this PR?

OneOnEach, RoundRobinDeployment, and RandomDeployment each leaked a different implementation-detail exception when next() was called on an empty available array (IndexOutOfBoundsException, ArithmeticException,
and IllegalArgumentException respectively), so callers had no single contract to handle. Each next() now guards available.isEmpty and throws NoSuchElementException("no available addresses"), the standard Scala/Java
contract for "no element to return". For OneOnEach, the post-iteration "exhausted" branch was also switched to NoSuchElementException, so both empty-init and exhausted paths agree.

Any related issues, documentation, or discussions?

Closes: #4732

How was this PR tested?

  • Updated the three pinning specs in DeployStrategiesSpec (previously asserting the divergent exception types) to assert NoSuchElementException for: OneOnEach empty-init, OneOnEach exhausted-after-iteration,
    OneOnEach cursor-preserved-across-reinit, RoundRobinDeployment empty, and RandomDeployment empty.
  • Ran sbt scalafmtAll no formatting changes to the modified files.
  • Local sbt testOnly for the spec could not run due to a pre-existing build.sbt load error (AddMetaInfLicenseFiles not found), unrelated to this change; CI is expected to run the spec.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.7 in compliance with ASF

@Ma77Ball
Copy link
Copy Markdown
Contributor Author

/request-review @Yicong-Huang

@github-actions github-actions Bot requested a review from Yicong-Huang May 13, 2026 02:39
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.77%. Comparing base (5bff1b4) to head (8d0d941).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5029      +/-   ##
============================================
- Coverage     42.78%   42.77%   -0.01%     
+ Complexity     2197     2196       -1     
============================================
  Files          1045     1045              
  Lines         39985    39989       +4     
  Branches       4217     4217              
============================================
- Hits          17109    17107       -2     
- Misses        21818    21821       +3     
- Partials       1058     1061       +3     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 1497806
agent-service 33.72% <ø> (ø) Carriedforward from 1497806
amber 43.49% <100.00%> (-0.02%) ⬇️
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 1497806
config-service 0.00% <ø> (ø) Carriedforward from 1497806
file-service 32.18% <ø> (ø) Carriedforward from 1497806
frontend 34.04% <ø> (ø) Carriedforward from 1497806
python 88.87% <ø> (-0.03%) ⬇️ Carriedforward from 1497806
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 1497806

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

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.

Deploy strategies use three different exception types for empty-array fault

2 participants