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

Mail's implementations of equals and hashCode are incomplete #718

Open
rupertchen opened this issue Feb 18, 2022 · 1 comment
Open

Mail's implementations of equals and hashCode are incomplete #718

rupertchen opened this issue Feb 18, 2022 · 1 comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@rupertchen
Copy link

Issue Summary

The implementations of Mail#equals and Mail#hashCode are missing fields. Two instances will be considered equal despite having different values in from, to, content, etc. Having a distinct hash code is not a requirement, but could lead to poor performance in some cases.

Steps to Reproduce

  1. Create a first Mail instance as m1.
  2. Create a second Mail instance as 'm2' with the same subject, but different from, to, and content.
  3. Find that m1.equals(m2) is true despite differing in most set fields.

Code Snippet

final var subject = "Hello";
final var m1 = new Mail(
        new Email("[email protected]"),
        subject,
        new Email("[email protected]"),
        new Content(MediaType.TEXT_PLAIN, "Foo"));
final var m2 = new Mail(
        new Email("[email protected]"),
        subject,
        new Email("[email protected]"),
        new Content(MediaType.TEXT_PLAIN, "Bar"));

System.out.println(m1.equals(m2));
System.out.println(m1.hashCode());
System.out.println(m2.hashCode());

Prints

true
1961385645
1961385645

Technical details:

  • sendgrid-java version: 4.8.3
  • java version: 17.0.1 (this what I am using, but this issue is present in all versions)
@childish-sambino childish-sambino added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap labels Feb 18, 2022
@childish-sambino
Copy link
Contributor

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

2 participants