-
Bug
-
Resolution: Fixed
-
P4
-
jfx21
-
b01
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8324767 | jfx22.0.1 | Marius Hanl | P4 | Resolved | Fixed | b03 |
JDK-8324227 | jfx22 | Marius Hanl | P4 | Resolved | Fixed | b27 |
When table items are set to null after items were shown first (non-null), a NPE can happen.
Stacktrace:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "javafx.collections.ObservableList.size()" because the return value of "javafx.scene.control.TableView.getItems()" is null
at javafx.controls/javafx.scene.control.skin.TableSkinUtils.getItemCount(TableSkinUtils.java:212)
at javafx.controls/javafx.scene.control.skin.TableViewSkinBase.updateContentWidth(TableViewSkinBase.java:909)
at javafx.controls/javafx.scene.control.skin.TableViewSkinBase.checkContentWidthState(TableViewSkinBase.java:594)
at javafx.controls/javafx.scene.control.skin.TableViewSkinBase.layoutChildren(TableViewSkinBase.java:514)
at javafx.controls/javafx.scene.control.Control.layoutChildren(Control.java:612)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1208)
Technically a regression fromJDK-8137244.
Code:
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class TableViewBug extends Application {
@Override
public void start(Stage stage) {
TableView<String> tableView = new TableView<>();
TableColumn<String, String> col = new TableColumn<>("123");
col.setCellValueFactory(e -> new SimpleStringProperty(e.getValue()));
tableView.getColumns().add(col);
tableView.getItems().addAll("1", "2", "3");
stage.setScene(new Scene(tableView));
stage.show();
tableView.setItems(null);
}
public static void main(String[] args) {
launch(args);
}
}
Stacktrace:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "javafx.collections.ObservableList.size()" because the return value of "javafx.scene.control.TableView.getItems()" is null
at javafx.controls/javafx.scene.control.skin.TableSkinUtils.getItemCount(TableSkinUtils.java:212)
at javafx.controls/javafx.scene.control.skin.TableViewSkinBase.updateContentWidth(TableViewSkinBase.java:909)
at javafx.controls/javafx.scene.control.skin.TableViewSkinBase.checkContentWidthState(TableViewSkinBase.java:594)
at javafx.controls/javafx.scene.control.skin.TableViewSkinBase.layoutChildren(TableViewSkinBase.java:514)
at javafx.controls/javafx.scene.control.Control.layoutChildren(Control.java:612)
at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1208)
Technically a regression from
Code:
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class TableViewBug extends Application {
@Override
public void start(Stage stage) {
TableView<String> tableView = new TableView<>();
TableColumn<String, String> col = new TableColumn<>("123");
col.setCellValueFactory(e -> new SimpleStringProperty(e.getValue()));
tableView.getColumns().add(col);
tableView.getItems().addAll("1", "2", "3");
stage.setScene(new Scene(tableView));
stage.show();
tableView.setItems(null);
}
public static void main(String[] args) {
launch(args);
}
}
- backported by
-
JDK-8324227 NPE when table items are set to null
- Resolved
-
JDK-8324767 NPE when table items are set to null
- Resolved
- links to
-
Commit openjdk/jfx/872dbc8a
-
Commit openjdk/jfx/9587f51e
-
Review openjdk/jfx/1329
-
Review openjdk/jfx/1341
(1 links to)