Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8299526

Bindings bindContentBidirectional (all variants) should reject circular and duplicate bindings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx20
    • javafx
    • None

      The bindContentBidirectional method is completely unaware of previous content bindings and allows situations that cause the bindings to be broken or even log exceptions.

      For example:

          public static void main(String[] args) {
              ObservableList<String> a = FXCollections.observableArrayList();
              ObservableList<String> b = FXCollections.observableArrayList();
              Bindings.bindContentBidirectional(a, b);
              Bindings.bindContentBidirectional(a, b);
              a.add("A");
              System.out.println(a + " : " + b);
          }

      Will print:

          [A, A, A, A] : [A, A, A]

      When there are 3 or more lists involved, the problem can get so bad that `IndexOutOfBoundsException` is thrown somewhere in the code handling the syncing of the lists (which is caught and only logged to the console while leaving the list contents badly unsynced).

      I've made a PoC that rejects circular bindings and overlapping bindings when they're detected.

            jhendrikx John Hendrikx
            jhendrikx John Hendrikx
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: