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

[SortedList] add() to underlying list throws IndexOutOfBoundsException if item not successfully added

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8
    • javafx
    • Windows 7 Professional SP1 x64, JavaFX 8 EA b128

      1. Create your own List implementation including iterators and make sure it works with ObservableList as a wrapper.
      2. Make the add* methods not actually add anything.
      3. Create a new instance of the list and wrap it in ObservableList, store it in "list" variable.
      4. Wrap the ObservableList in SortedList.
      5. Perform list.add(...).

      I use my own List+Set implementation (ArrayHashList, LinkedHashList), whose instance is a list with no duplicates in it. Very useful thing. It however does not work with the SortedList wrapper because if I do this, I get the IndexOutOfBoundsException:

      final ObservableList<String> list = FXCollections.observableList(new ArrayHashList<String>());
      final ObservableList<String> sortedList = new SortedList<String>(list, String.CASE_INSENSITIVE_ORDER);
      list.add("a");
      list.add("a"); // Does not change the list

            msladecek Martin Sládeček
            jsmucrjfx Jan Smucr (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: