[bisq-network/bisq] Fix invalid comparators (#3251)

Steven Barclay notifications at github.com
Fri Sep 13 00:06:45 UTC 2019


Many of the table column comparators (as well as _PaymentMethod.compareTo_) are invalid, since they immediately return 0 upon encountering a null/missing field. This violates the _Comparator_/_Comparable_ contract, which expects a total order on the objects and, in particular, an equivalence relation given by the result of "_compare(x, y) == 0_".

This PR attemps to fix all the invalid _Comparator_ / _Comparable_ instances (which are almost all table column comparators), by ordering objects with a null/missing (sub)field ahead of the populated ones. In most cases this will probably have no effect, as nulls won't be encountered for that column in practice. However, the current flawed comparators are at least breaking row sorting in the Portfolio/History table, as seen in the following two screenshots:

![Closed Trades with Broken Comparators 1](https://user-images.githubusercontent.com/54855381/64828188-513e0680-d5bf-11e9-9b27-fe816a91aa94.png)
![Closed Trades with Broken Comparators 2](https://user-images.githubusercontent.com/54855381/64828209-5c913200-d5bf-11e9-8882-49ae043aeb42.png)

The ascending/descending sorting of the "Amount in BTC" field does not make sense, due to a broken comparator passed to the underlying FX library insertion sort. After the fix, the rows appear as follows:

![Closed Trades with Fixed Comparators 1](https://user-images.githubusercontent.com/54855381/64828440-68312880-d5c0-11e9-97d5-b229659b5a33.png)
![Closed Trades with Fixed Comparators 2](https://user-images.githubusercontent.com/54855381/64828445-6b2c1900-d5c0-11e9-8806-c3988f69b47b.png)

The missing cells are deemed smaller than all the others in the column, which is consistent with _TableColumnBase.DEFAULT_COMPARATOR_ from the openjfx library.
You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/3251

-- Commit Summary --

  * Remove redundant/invalid null handling from PaymentMethod.compareTo
  * Fix invalid neutral element handling in View comparators

-- File Changes --

    M core/src/main/java/bisq/core/payment/payload/PaymentMethod.java (9)
    M desktop/src/main/java/bisq/desktop/main/disputes/trader/TraderDisputeView.java (2)
    M desktop/src/main/java/bisq/desktop/main/funds/locked/LockedView.java (8)
    M desktop/src/main/java/bisq/desktop/main/funds/reserved/ReservedView.java (8)
    M desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java (23)
    M desktop/src/main/java/bisq/desktop/main/portfolio/closedtrades/ClosedTradesView.java (122)
    M desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java (15)
    M desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java (14)
    M desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java (30)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/3251.patch
https://github.com/bisq-network/bisq/pull/3251.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/3251
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20190912/830beca0/attachment-0001.html>


More information about the bisq-github mailing list