Skip to content
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

Avoid possible NPE when searching for event in past blocks #249

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

apancorb
Copy link
Contributor

@apancorb apancorb commented Apr 23, 2024

Summary

The method receiptStore.getInMainChain(transaction.getHash().getBytes(), blockStore) returns an Optional. The code is not currently checking if the value is present in the returned Optional.

There is no reason really for the transaction to not be in the storage, if it’s part of the block then the transaction should exist. But avoiding this check is what’s causing a code smell.

Note: Added minor refactor.

Test Plan

Added unit test, and verified with ./gradlew test

@apancorb apancorb self-assigned this Apr 23, 2024
@apancorb apancorb marked this pull request as ready for review April 23, 2024 16:47
@apancorb apancorb requested a review from a team as a code owner April 23, 2024 16:47
@apancorb
Copy link
Contributor Author

pipeline:run

marcos-iov
marcos-iov previously approved these changes Apr 24, 2024
Copy link
Collaborator

@marcos-iov marcos-iov left a comment

Choose a reason for hiding this comment

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

nice, well done

jeremy-then
jeremy-then previously approved these changes Apr 25, 2024
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.

@jeremy-then
Copy link
Contributor

Remember to rebase with master.

@apancorb apancorb dismissed stale reviews from jeremy-then and marcos-iov via a3f7b6f April 25, 2024 10:19
@apancorb
Copy link
Contributor Author

pipeline:run

marcos-iov
marcos-iov previously approved these changes Apr 25, 2024
@apancorb
Copy link
Contributor Author

pipeline:run

Copy link
Contributor

@nathanieliov nathanieliov left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

sonarcloud bot commented Apr 26, 2024

@marcos-iov marcos-iov merged commit f038446 into master Apr 26, 2024
6 checks passed
@marcos-iov marcos-iov deleted the fix/code_smell branch April 26, 2024 16:34
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.

None yet

4 participants