-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
io.grpc.Attributes - reference vs. object equality #3857
Comments
I don't believe that side effect was intended, only the keys were supposed to be compared by reference equality. We could change it back, because it seems like a legit use case. Do you mainly use it in tests or in prod code? |
We should change it back. Yeah, we should use object-equality for the values themselves. |
@carl-mastrangelo @ejona86 - from what I can tell we're only relying on this in tests right now. Thanks for the prompt reply / fix nonetheless! 🙏 |
(ignore my trigger finger on the close button) |
io.grpc.Attributes
was modified in 291f170 to use anIdentityMap
to store the underlying attributes. This map uses reference equality in place of the object equality that was used in prior versions, when the class usedHashMap
.This is more of a question around the expected behavior of
Attributes#equals
and the notion of "attribute equality" as opposed to a bug or an issue. For context, we have some tests internally that are failing in 1.8 as they were written with object equality in mind.For example, the following fails in 1.8 but passes in prior versions, which upon immediate inspection wasn't intuitive, as
InetSocketAddress#equals
returnstrue
when comparing the two different objects:I'm interested in the motivation for the change in semantics (talking with @lukaszx0 in person, he recalls some talk about this previously). If reference equality was the intention, perhaps we could tighten up the javadoc a little to make it more explicit that this class now uses reference equality as opposed to object equality?
Or, perhaps this wasn't the original intention and it would be possible to revert to using a
HashMap
, although the benchmarks seem to indicate this would be slightly slower than the current impl.The text was updated successfully, but these errors were encountered: