fix: unify DeployStrategy empty-array errors to NoSuchElementException#5029
Open
Ma77Ball wants to merge 3 commits into
Open
fix: unify DeployStrategy empty-array errors to NoSuchElementException#5029Ma77Ball wants to merge 3 commits into
Ma77Ball wants to merge 3 commits into
Conversation
Contributor
Author
|
/request-review @Yicong-Huang |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
What changes were proposed in this PR?
OneOnEach,RoundRobinDeployment, andRandomDeploymenteach leaked a different implementation-detail exception whennext()was called on an emptyavailablearray (IndexOutOfBoundsException,ArithmeticException,and
IllegalArgumentExceptionrespectively), so callers had no single contract to handle. Eachnext()now guardsavailable.isEmptyand throwsNoSuchElementException("no available addresses"), the standard Scala/Javacontract for "no element to return". For
OneOnEach, the post-iteration "exhausted" branch was also switched toNoSuchElementException, so both empty-init and exhausted paths agree.Any related issues, documentation, or discussions?
Closes: #4732
How was this PR tested?
DeployStrategiesSpec(previously asserting the divergent exception types) to assertNoSuchElementExceptionfor:OneOnEachempty-init,OneOnEachexhausted-after-iteration,OneOnEachcursor-preserved-across-reinit,RoundRobinDeploymentempty, andRandomDeploymentempty.sbt scalafmtAllno formatting changes to the modified files.sbt testOnlyfor 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