[
https://issues.apache.org/jira/browse/HTRACE-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15605955#comment-15605955
]
Colin P. McCabe commented on HTRACE-392:
----------------------------------------
In tests, we generally just use {{toJson}} to compare two different spans. The
json output is deterministic, so two spans which are equal should have the same
json output.
I had some anxiety about overriding equals and hashCode for Span. It seems
very easy to get it wrong by leaving out a field (especially when people are
adding new fields)-- or by hashing things in a different order, etc. Since
these functions are inherently public, any change to them affects the public
API on a deep level.
I also wasn't excited about people doing things like putting spans in HashMaps
using a hash function which hashes all fields. For example, I think it makes
more sense to just hash the spanId, rather than hashing every field in the
span, when putting spans into a HashMap.
I'm curious what you guys think about this-- maybe my concerns are misplaced?
In any case, if we do implement these functions, it should be because we're
ready to put them in the public API for all time (and define how they work
there). Unit tests can just use toJson where needed
> MilliSpan does not implement equals and hashcode
> ------------------------------------------------
>
> Key: HTRACE-392
> URL: https://issues.apache.org/jira/browse/HTRACE-392
> Project: HTrace
> Issue Type: Bug
> Components: core
> Affects Versions: 4.2
> Reporter: Mike Drob
>
> MilliSpan does not implement equal and hashcode, which can make test fixtures
> unnecessarily brittle when doing comparisons.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)