Skip to content

Conversation

@julianlen
Copy link
Contributor

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

@julianlen julianlen requested a review from a team as a code owner December 19, 2025 17:59
@github-actions
Copy link

github-actions bot commented Dec 19, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@julianlen julianlen requested a review from Copilot December 19, 2025 18:03
Copy link

Copilot AI left a 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 getRetiringFederationCreationTime method to return an Optional<Instant> instead of a nullable Instant, improving null safety and making the API more explicit about the possibility of no retiring federation existing.

Key Changes:

  • Changed return type from Instant to Optional<Instant> for getRetiringFederationCreationTime across the interface and implementation layers
  • Updated test cases to verify Optional.isEmpty() instead of null checks
  • Refactored the Bridge class to use functional programming patterns with Optional.map() and Optional.orElse()

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
rskj-core/src/main/java/co/rsk/peg/federation/FederationSupport.java Updated interface method signature to return Optional<Instant>
rskj-core/src/main/java/co/rsk/peg/federation/FederationSupportImpl.java Changed implementation to return Optional directly instead of .orElse(null)
rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java Updated method signature to match interface change
rskj-core/src/main/java/co/rsk/peg/Bridge.java Refactored to use Optional and extracted epoch time logic into a private method
rskj-core/src/test/java/co/rsk/peg/federation/FederationSupportImplTest.java Updated test assertions to check isEmpty() instead of null values
rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java Updated mock returns and assertions to use Optional
rskj-core/src/test/java/co/rsk/peg/BridgeTest.java Updated mock to return Optional value
rskj-core/src/test/java/co/rsk/peg/BridgeSupportIT.java Updated integration test to unwrap Optional before assertions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@julianlen julianlen force-pushed the getRetiringFederationCreationTime-optional branch from 343dbbb to 8e4e700 Compare December 19, 2025 18:05
Copy link
Contributor

@jeremy-then jeremy-then left a comment

Choose a reason for hiding this comment

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

LGTM.

@julianlen julianlen force-pushed the getRetiringFederationCreationTime-optional branch from 8e4e700 to ae2226b Compare December 19, 2025 19:30
.orElse((long) FederationChangeResponseCode.FEDERATION_NON_EXISTENT.getCode());
}

private Long getEpochTimeBasedOnActivation(Instant retiringFederationCreationTime) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private Long getEpochTimeBasedOnActivation(Instant retiringFederationCreationTime) {
private Long getFederationCreationTiimeEpochBasedOnActivation(Instant federationCreationTime) {

Make it clear that it applies to federation creation time, not to any epoch. Can/should this be re-used when getting active federation creation time?

Copy link
Contributor

Choose a reason for hiding this comment

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

marcos is right, this same logic is being applied for getFederationCreationTime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@julianlen julianlen force-pushed the getRetiringFederationCreationTime-optional branch from ae2226b to 94f1ade Compare December 22, 2025 12:54
…hBasedOnActivation and reuse the method in getFederationCreationTime
@sonarqubecloud
Copy link

@julianlen julianlen merged commit 408c03b into mtmu-integration Dec 22, 2025
9 checks passed
@marcos-iov marcos-iov deleted the getRetiringFederationCreationTime-optional branch December 22, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants