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

fix: change == to .equals for Bytes.EMPTY and other non-primitive types #17213

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

kimbor
Copy link
Member

@kimbor kimbor commented Jan 4, 2025

Description:
This PR updates all object comparisons to use equals instead of == except for a few instances where reference comparisons are per design.

Related issue(s):
Fixes #16639

Notes for reviewer:
A zero-length PBJ Bytes is not necessarily Bytes.EMPTY so nothing should depend on object equality with Bytes.EMPTY. Using == for comparing objects is an anti-pattern in Java.

@kimbor kimbor self-assigned this Jan 4, 2025
@kimbor kimbor added this to the v0.59 milestone Jan 4, 2025
@kimbor kimbor changed the title Change == to .equals for Bytes.EMPTY and other non-primitive types fix: Change == to .equals for Bytes.EMPTY and other non-primitive types Jan 4, 2025
@kimbor kimbor changed the title fix: Change == to .equals for Bytes.EMPTY and other non-primitive types fix: change == to .equals for Bytes.EMPTY and other non-primitive types Jan 4, 2025
Signed-off-by: Kim Rader <[email protected]>
Copy link

codecov bot commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 64.34%. Comparing base (f3ec5d1) to head (a0580f2).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...service/networkadmin/impl/WritableFreezeStore.java 0.00% 0 Missing and 2 partials ⚠️
...ontracts/hts/create/CreateSyntheticTxnFactory.java 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main   #17213   +/-   ##
=========================================
  Coverage     64.33%   64.34%           
- Complexity    20942    20945    +3     
=========================================
  Files          2555     2555           
  Lines         96169    96169           
  Branches      10054    10054           
=========================================
+ Hits          61873    61876    +3     
  Misses        30655    30655           
+ Partials       3641     3638    -3     
Files with missing lines Coverage Δ
...om/hedera/node/app/hapi/utils/ByteStringUtils.java 100.00% <100.00%> (ø)
...com/hedera/node/app/hapi/utils/fee/FeeBuilder.java 92.56% <100.00%> (ø)
...ontracts/hts/create/CreateSyntheticTxnFactory.java 60.29% <0.00%> (ø)
...service/networkadmin/impl/WritableFreezeStore.java 86.66% <0.00%> (ø)

... and 11 files with indirect coverage changes

Impacted file tree graph

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 80.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (f3ec5d1) 95932 65322 68.09%
Head commit (a0580f2) 95932 (+0) 65322 (+0) 68.09% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#17213) 5 4 80.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@kimbor kimbor marked this pull request as ready for review January 4, 2025 04:10
@kimbor kimbor requested review from tinker-michaelj and a team as code owners January 4, 2025 04:10
Copy link
Member

@lukelee-sl lukelee-sl left a comment

Choose a reason for hiding this comment

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

LGTM

@kimbor kimbor merged commit 602f625 into main Jan 6, 2025
61 of 62 checks passed
@kimbor kimbor deleted the 16639-object-equality-checks branch January 6, 2025 23:47
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.

No Bytes.EMPTY object equality checks should be used
3 participants