On Fri, 30 Jun 2023 09:34:26 GMT, Daniel Fuchs <[email protected]> wrote:
> > `return Set.of(that.addrs).containsAll(Set.of(this.addrs));`
>
> Since it's been checked before that the arrays have the same length it could
> even be:
>
> ```
> return Set.of(that.addrs).equals(Set.of(this.addrs));
> ```
While this would be clearer and likely as intended, it wouldn't be equivalent.
It would only be equivalent, if we could guarantee that there are no duplicates
in `this.addrs`.
On the other hand, if there are duplicates in `this.addrs` then there should
also be the same duplicates in `that.addrs`, or else `equals` will not be
symmetric, which it is required to be, and hence will be a bug:
this.addrs.equals(that.addrs) != that.addrs.equals(this.addrs)
So with that it mind, do you want me to change to what you proposed and see if
the tests are still okay?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14726#issuecomment-1614482760