-
Notifications
You must be signed in to change notification settings - Fork 268
turn getRetiringFederationSize to return an optional #3424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
turn getRetiringFederationSize to return an optional #3424
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
e5368e8 to
ff847bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the getRetiringFederationSize() method to return an Optional<Integer> instead of a primitive int, eliminating the need to use magic number -1 to represent a non-existent retiring federation. The change improves type safety and makes the API more explicit about the possibility of absent values.
Key Changes:
- Modified the return type of
getRetiringFederationSize()frominttoOptional<Integer>across the interface and implementation layers - Updated all test cases to verify optional emptiness instead of checking for the magic number response code
- Added proper unwrapping of the Optional at the Bridge layer boundary, converting back to the magic number for backward compatibility
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
FederationSupport.java |
Updated interface signature to return Optional<Integer> |
FederationSupportImpl.java |
Simplified implementation to return Optional directly instead of falling back to error code |
BridgeSupport.java |
Updated return type to propagate Optional<Integer> |
Bridge.java |
Added unwrapping logic with fallback to FEDERATION_NON_EXISTENT code for backward compatibility |
FederationSupportImplTest.java |
Updated assertions to check for empty Optional instead of error code |
BridgeSupportTest.java |
Updated mock setup to return Optional |
BridgeSupportIT.java |
Updated integration test assertions to verify Optional presence/absence |
BridgeIT.java |
Updated mock to return Optional.of(1234) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rskj-core/src/main/java/co/rsk/peg/federation/FederationSupport.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/peg/federation/FederationSupportImpl.java
Outdated
Show resolved
Hide resolved
86510d2 to
05a40f5
Compare
jeremy-then
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
julia-zack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left one super minor comment
d2eaf0e to
c196617
Compare
|



Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: