Skip to content

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

Merged
Yicong-Huang merged 12 commits into
apache:mainfrom
Ma77Ball:fix/unifyExceptions
May 19, 2026
Merged

fix: unify DeployStrategy empty-array errors to NoSuchElementException#5029
Yicong-Huang merged 12 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 43.05%. Comparing base (8cf9e79) to head (b2ee2aa).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5029      +/-   ##
============================================
- Coverage     43.19%   43.05%   -0.14%     
- Complexity     2209     2212       +3     
============================================
  Files          1045     1045              
  Lines         40265    40187      -78     
  Branches       4251     4241      -10     
============================================
- Hits          17391    17304      -87     
- Misses        21803    21815      +12     
+ Partials       1071     1068       -3     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 9ba490e
agent-service 33.72% <ø> (ø) Carriedforward from 9ba490e
amber 43.89% <100.00%> (+0.03%) ⬆️
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 9ba490e
config-service 0.00% <ø> (ø) Carriedforward from 9ba490e
file-service 32.18% <ø> (ø) Carriedforward from 9ba490e
frontend 33.87% <ø> (-0.22%) ⬇️ Carriedforward from 9ba490e
python 90.37% <ø> (-0.12%) ⬇️ Carriedforward from 9ba490e
workflow-compiling-service 47.72% <ø> (-9.10%) ⬇️ Carriedforward from 9ba490e

*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.

@Ma77Ball
Copy link
Copy Markdown
Contributor Author

@Yicong-Huang please review

@Ma77Ball
Copy link
Copy Markdown
Contributor Author

@Yicong-Huang please review when you have time

Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

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

LGTM

@Yicong-Huang Yicong-Huang enabled auto-merge (squash) May 19, 2026 07:08
@Yicong-Huang Yicong-Huang merged commit a54518c into apache:main May 19, 2026
14 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.

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

3 participants