Change in ovirt-engine[master]: webadmin: Fix ClusterNetworkModelComparator

Code Review gerrit at ovirt.org
Fri Mar 31 18:31:34 UTC 2017


>From Allon Mureinik <amureini at redhat.com>:

Allon Mureinik has submitted this change and it was merged.

Change subject: webadmin: Fix ClusterNetworkModelComparator
......................................................................


webadmin: Fix ClusterNetworkModelComparator

A Comparator's general contract states that:

```
The implementor must ensure that
sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y.
```

ClusterNetworkModelComparator breaks this assumption for the case of
comparing two models where isManagement() returns true. While this
may not currently be possible, it's a bad practice to implement a
Comparator in a way that blatantly breaks Java's contract.

This patch remimplements this Comparator in a way that adheres to
Java's contract and still upholds the intended logic:
1. Management Networks(s) come first
2. Within each class of "is [not] management network", the networks
   are sorted lexonumerically by their name.

Change-Id: Ifedfa7c6cd6b19fbd5126d2174a37740b5738714
Signed-off-by: Allon Mureinik <amureini at redhat.com>
---
M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
1 file changed, 3 insertions(+), 4 deletions(-)

Approvals:
  Martin Mucha: Looks good to me, but someone else must approve
  Jenkins CI: Passed CI tests
  Allon Mureinik: Verified
  Vojtech Szocs: Looks good to me, approved



-- 
To view, visit https://gerrit.ovirt.org/74940
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifedfa7c6cd6b19fbd5126d2174a37740b5738714
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Alona Kaplan <alkaplan at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Mucha <mmucha at redhat.com>
Gerrit-Reviewer: Tal Nisan <tnisan at redhat.com>
Gerrit-Reviewer: Vojtech Szocs <vszocs at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>


More information about the Engine-commits mailing list