fix: replace bare Option.get in getPortId with descriptive IllegalStateException #4978
Open
Ma77Ball wants to merge 2 commits intoapache:mainfrom
Open
fix: replace bare Option.get in getPortId with descriptive IllegalStateException #4978Ma77Ball wants to merge 2 commits intoapache:mainfrom
Ma77Ball wants to merge 2 commits intoapache:mainfrom
Conversation
aglinxinyuan
approved these changes
May 7, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4978 +/- ##
============================================
- Coverage 42.69% 42.68% -0.01%
Complexity 2186 2186
============================================
Files 1031 1031
Lines 38111 38112 +1
Branches 4004 4004
============================================
Hits 16270 16270
Misses 20825 20825
- Partials 1016 1017 +1
*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?
AmberFIFOChannel.getPortId called this.portId.get on an Option[PortIdentity] that defaults to None. Calling getPortId before setPortId threw a bare NoSuchElementException with no message, giving callers no indication of which channel was misconfigured or what setup step was missed.
Replaced .get with .getOrElse(throw new IllegalStateException(...)) so the exception identifies the channel and points the caller at the missing setPortId call.
Any related issues, documentation, discussions?
Closes: #4818
How was this PR tested?
Updated the existing AmberFIFOChannelSpec test that covered this path — it previously asserted NoSuchElementException and now asserts IllegalStateException with message content checks ("portId has not been set" and the channel ID string). All 13 specs pass.
Was this PR authored or co-authored using generative AI tooling?
Co-Authored with Claude Opus 4.7 in compliance with ASF