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

UnsupportedOperation thrown by NestedTableColumnHeader



      The code inside NestedTableColumnHeader has a flaw by design that can lead to an unsupportedOperation.

      In the updateTableColumnHeaders() method, you have this particular code :
      // switch out to be a TableColumn instead, if we have a parent header
                  NestedTableColumnHeader parentHeader = getParentHeader();
                  if (parentHeader != null) {
                      List<TableColumnHeader> parentColumnHeaders = parentHeader.getColumnHeaders();
                      int index = parentColumnHeaders.indexOf(this);
                      if (index >= 0 && index < parentColumnHeaders.size()) {
                          parentColumnHeaders.set(index, createColumnHeader(getTableColumn()));
                  } else {
                      // otherwise just remove all the columns

      As you can see, we are trying to modify the "parentColumnHeaders" list obtained by calling "getColumnHeaders()". And here is the method :

           * Returns an unmodifiable list of the {@link TableColumnHeader} instances
           * that are children of this NestedTableColumnHeader.
           * @return the unmodifiable list of TableColumnHeader of this NestedTableColumnHeader
          public final ObservableList<TableColumnHeader> getColumnHeaders() {
              if (columnHeaders == null) {
                  columnHeaders = FXCollections.<TableColumnHeader>observableArrayList();
                  unmodifiableColumnHeaders = FXCollections.unmodifiableObservableList(columnHeaders);
              return unmodifiableColumnHeaders;

      As you can see, the method returns an Unmodifiable list, therefore any attempt to modify it (like I've shown above) will fail.

      With the given code line of NestedTableColumnHeader, this cannot happen. But someone overriding "createTableColumnHeader" in another way could fall back in this code and trigger this exception.

      Regression has appeared in this huge commit : http://hg.openjdk.java.net/openjfx/9/rt/rev/5023330f0526




            • Assignee:
              aghaisas Ajit Ghaisas
              shadzic Samir Hadzic
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: