-
Notifications
You must be signed in to change notification settings - Fork 408
Open
Labels
status: help wantedrequesting help from the communityrequesting help from the communitytype: community enhancementfeature request not on Twilio's roadmapfeature request not on Twilio's roadmap
Description
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
- Create a first
Mailinstance asm1. - Create a second
Mailinstance as 'm2' with the same subject, but differentfrom,to, andcontent. - Find that
m1.equals(m2)istruedespite differing in most set fields.
Code Snippet
final var subject = "Hello";
final var m1 = new Mail(
new Email("a@mail.invalid"),
subject,
new Email("b@mail.invalid"),
new Content(MediaType.TEXT_PLAIN, "Foo"));
final var m2 = new Mail(
new Email("x@mail.invalid"),
subject,
new Email("y@mail.invalid"),
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)
stevenschlansker
Metadata
Metadata
Assignees
Labels
status: help wantedrequesting help from the communityrequesting help from the communitytype: community enhancementfeature request not on Twilio's roadmapfeature request not on Twilio's roadmap