gerrit/gerrit-extension-api/src
Dave Borowitz 0b3affa4e2 IdString: Don't compare equal to strings
Object#equals is supposed to define an equivalence relation[1][2]. This
includes the property of symmetry: a.equals(b) if and only if
b.equals(a). The old implementation of IdString#equals was asymmetrical:
it returned true when comparing to a String with the same urlencoded
value, but of course String#equals will always return false when
comparing to an IdString.

Fix IdString#equals to only compare equal to other IdStrings. It's
trivial and readable to fix the few usages in Gerrit core.

Since this method is part of the extension API, it's possible (though
personally I think highly unlikely) that plugins in the wild are
depending upon the current behavior, similar to how core was. Breakages
may be subtle, if for example callers were trying to look up Strings in
a Map<IdString, V>. However, it's worth noting that the asymmetric
behavior of equals meant that plugins were _already_ in for subtly
confusing or broken behavior.

At a minimum need to mention this behavior change in release notes.

[1] https://en.wikipedia.org/wiki/Equivalence_relation
[2] Effective Java, Item 8: "Obey the general contract when overriding
    equals"

Change-Id: I9d79b90640ea095b71803185d581cda77b93964e
(cherry picked from commit e24bb8be8d)
2018-09-19 18:22:11 +00:00
..
main/java/com/google/gerrit/extensions IdString: Don't compare equal to strings 2018-09-19 18:22:11 +00:00
test/java/com/google/gerrit/extensions Upgrade to google-java-format 1.5 2018-04-18 09:06:49 +02:00