RestComm / jain-sip

Disclaimer: This repository is a git-svn mirror of the project found at http://java.net/projects/jsip whose original repository is developed collaboratively by the Advanced Networking Technologies Division at the National Institute of Standards and Technology (NIST) - an agency of the United States Department of Commerce and by a community of individual and enterprise contributors. TeleStax, Inc. will perform some productization work, new features experimentation branches, etc for its TelScale jSIP product that doesn't concern the community from the main repository hence this git repository.
http://www.restcomm.com/
140 stars 149 forks source link

Revisit SIPHeader equals/hashCode implementation #72

Open jaimecasero opened 8 years ago

jaimecasero commented 8 years ago

Current SIPHeader implementation takes headerName for hashCode, this will certainly creates lots of collisions when added to collections.

While equals implements a deep equals (compare all fields/attributes) logic using reflection. This is much overhead in terms of performance, and could be hiding some incorrect Equals contract on a header subclass, since a deep equal logic is not always the correct impl.

Anyway, hashCode must match Equals logic, which is not honored right now

jaimecasero commented 8 years ago

https://jsip.ci.cloudbees.com/job/jsip/javadoc/javax/sip/header/Header.html#equals(java.lang.Object)

Deep equals should be fine for optional headers. But then hashCode needs to implement a deep hash code logic, to respect Object contract