Skip to content

Commit 4eaa59d

Browse files
Sergey Polovkonormanmaurer
authored andcommitted
Improve SctpMessage.hashCode method
Motivation: Not all fields of SctpMessage which used to check message equality are used to generate hashcode. Modifications: Use value of 'unordered' field in hashCode method. Result: Better hash function of SctpMessage.
1 parent a157528 commit 4eaa59d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

transport-sctp/src/main/java/io/netty/channel/sctp/SctpMessage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ public boolean equals(Object o) {
142142
public int hashCode() {
143143
int result = streamIdentifier;
144144
result = 31 * result + protocolIdentifier;
145+
// values 1231 and 1237 are referenced in the javadocs of Boolean#hashCode()
146+
result = 31 * result + (unordered ? 1231 : 1237);
145147
result = 31 * result + content().hashCode();
146148
return result;
147149
}

0 commit comments

Comments
 (0)