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

Change Blob equals semantics + fix tests #1526

Merged
merged 6 commits into from
May 21, 2024

Conversation

msosnicki
Copy link
Contributor

@msosnicki msosnicki commented May 16, 2024

PR Checklist (not all items are relevant to all PRs)

fixes #1521

  • Added unit-tests (for runtime code)
  • Added bootstrapped code + smoke tests (when the rendering logic is modified)
  • Added build-plugins integration tests (when reflection loading is required at codegen-time)
  • Added alloy compliance tests (when simpleRestJson protocol behaviour is expanded/updated)
  • Updated dynamic module to match generated-code behaviour
  • Added documentation
  • Updated changelog

other.isInstanceOf[ByteBufferBlob] &&
buf.compareTo(other.asInstanceOf[ByteBufferBlob].buf) == 0
}
override def equals(other: Any): Boolean =
Copy link
Contributor

Choose a reason for hiding this comment

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

If the point of the PR is to allow Blob constructed from different manners to be equivalent to one another, then the equals method should be implemented at the level of the trait, not in each component.

Moreover, hashCode and equals should have the same coherence : if you're gonna treat differently structured Blobs are equivalent, then they need to have the same hashCode, therefore the hashCode implementation should also move to the trait.

You can have a look at fs2.Chunk, which the Blob datatype is largely inspired from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about having equals in the trait, but never seen such definition and felt something might be off with it. The implementations are the same though, so it makes sense: if I define those two as top level methods, it will automatically eliminate the hashCode issue that I missed here.

@Baccata Baccata merged commit 947034e into disneystreaming:series/0.18 May 21, 2024
11 checks passed
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.

Blob equals issue
2 participants