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

NPE in charts when data is modified

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      b100

      Description

      To reproduce click 'Permute' twice and you will get:

      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
      at javafx.scene.chart.XYChart$Series$1.onChanged(XYChart.java:1507)
      at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:158)
      at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:72)
      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)
      ...


      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.chart.LineChart;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.XYChart;
      import javafx.scene.control.Button;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class TestApp extends Application {


          @Override
          public void start(Stage stage) throws Exception {

              NumberAxis xAxis = new NumberAxis();
              NumberAxis yAxis = new NumberAxis();

              final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);

              XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
              series.setData(list);

              lineChart.getData().add(series);

              Button permuteList = new Button("Permute list");
              permuteList.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      list.add(list.remove(0));
                  }
              });

              Scene scene = new Scene(new HBox(4, lineChart, permuteList));
              stage.setScene(scene);
              stage.show();
          }

          private ObservableList<XYChart.Data<Number, Number>> list
                  = FXCollections.observableArrayList(
                      new XYChart.Data<Number, Number>(4, 1),
                      new XYChart.Data<Number, Number>(1, 1),
                      new XYChart.Data<Number, Number>(2, 2),
                      new XYChart.Data<Number, Number>(3, 3));

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psomashe Parvathi Somashekar (Inactive)
                Reporter:
                dzinkevi Dmitry Zinkevich (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved:
                  Imported: