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

FXCollections.concat has misleading signature

XMLWordPrintable

    • x86
    • other

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Signature of method (see below) suggest that method concatenate ObservableLists, and it is WRONG.

      Instead, it creates ObservableList with elements from passed lists. This means that changes in original lists are not reflected in result.

      public static <E> ObservableList<E> concat(ObservableList<E>... lists)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -

      Fix method signature so it consumes simple lists.

      I'd be happier to see it really concatenating Observable lists, thus changes in original lists will be reflected, but I understand that this is breaking change :(

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /* package whatever; // don't place package name! */

      import java.util.*;
      import java.lang.*;
      import java.io.*;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;

      /* Name of the class has to be "Main" only if the class is public. */
      class Ideone
      {
      public static void main (String[] args) throws java.lang.Exception
      {
      ObservableList<String> first = FXCollections.observableArrayList("ala");
      ObservableList<String> second = FXCollections.observableArrayList("ma");

      ObservableList<String> third = FXCollections.concat(first, second);

      second.add("kota");
      // third does not contains "kota"
      System.out.println(third);
      }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: