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

Accidentally adding same TableColumn twice is allowed and causes late and hard to interpret java.lang.UnsupportedOperationException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 8u60
    • Component/s: javafx
    • Environment:

      Java version: 1.8.0_40-ea-b20 - JavaFX: 8.0.40-ea-b20

      Description

      Issue:

      If you create a TableColumn and add it to the list of columns on a TableView twice, the table seems to try to actually render it twice, which at draw-time causes an exception and a stacktrace that doesn't give any hint as to what is the source of the issue.

      Test Code:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.stage.Stage;

      public class SameColumnTwiceTest extends Application {

      public static void main(String[] args) {
      launch(args);
      }

      @Override
      public void start(Stage primaryStage) {
      TableView<DataEntry> table = new TableView<>();
      TableColumn<DataEntry, String> col1 = new TableColumn<>("Foo");

      // add column twice
      table.getColumns().addAll(col1, col1);

      Scene scene = new Scene(table);

      primaryStage.setScene(scene);
      primaryStage.show();
      }

      public static class DataEntry {

      }

      }

      Exception:

      Exception in thread "JavaFX Application Thread" java.lang.UnsupportedOperationException
      at java.util.Collections$UnmodifiableList.add(Collections.java:1314)
      at javafx.collections.ListChangeBuilder.nextRemove(ListChangeBuilder.java:208)
      at javafx.collections.ObservableListBase.nextRemove(ObservableListBase.java:150)
      at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:181)
      at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:171)
      at javafx.scene.control.ContextMenu$2.onChanged(ContextMenu.java:188)
      at com.sun.javafx.collections.TrackableObservableList.lambda$new$19(TrackableObservableList.java:45)
      at com.sun.javafx.collections.TrackableObservableList$$Lambda$54/414848734.onChanged(Unknown Source)
      at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
      at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
      at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
      at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
      at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
      at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
      at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:155)
      at java.util.AbstractList.add(AbstractList.java:108)
      at com.sun.javafx.scene.control.skin.TableHeaderRow.add(TableHeaderRow.java:500)
      at com.sun.javafx.scene.control.skin.TableHeaderRow.updateTableColumnListeners(TableHeaderRow.java:463)
      at com.sun.javafx.scene.control.skin.TableHeaderRow.<init>(TableHeaderRow.java:168)
      at com.sun.javafx.scene.control.skin.TableViewSkinBase.createTableHeaderRow(TableViewSkinBase.java:412)
      at com.sun.javafx.scene.control.skin.TableViewSkinBase.init(TableViewSkinBase.java:187)
      at com.sun.javafx.scene.control.skin.TableViewSkin.<init>(TableViewSkin.java:64)
      at javafx.scene.control.TableView.createDefaultSkin(TableView.java:1473)
      at javafx.scene.control.Control.impl_processCSS(Control.java:859)
      at javafx.scene.Node.processCSS(Node.java:9035)
      at javafx.scene.Scene.doCSSPass(Scene.java:545)
      at javafx.scene.Scene.preferredSize(Scene.java:1643)
      at javafx.scene.Scene.impl_preferredSize(Scene.java:1720)
      at javafx.stage.Window$9.invalidated(Window.java:834)
      at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
      at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
      at javafx.stage.Window.setShowing(Window.java:910)
      at javafx.stage.Window.show(Window.java:925)
      at javafx.stage.Stage.show(Stage.java:256)
      at com.jfxbugs.BadTableTest.start(BadTableTest.java:28)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
      at com.sun.javafx.application.LauncherImpl$$Lambda$53/1075059918.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
      at com.sun.javafx.application.PlatformImpl$$Lambda$45/186276003.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
      at com.sun.javafx.application.PlatformImpl$$Lambda$48/383469907.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
      at com.sun.javafx.application.PlatformImpl$$Lambda$47/237061348.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
      at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:745)

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              ecrumhornjfx Emil Crumhorn (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: