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

NPE in MenuButtonSkinBase | OpenJDK 14.0.2

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      A DESCRIPTION OF THE PROBLEM :
      Got NPE when remove the current last item from my ListView.
      I used my customized ListCell, load the view from FXML and my cell contains one label and one MenuButton.

      REGRESSION : Last worked in version 13

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Have a graphic FXML with type of ListCell. It has one Label and one MenuButton(two MenuItems inside) inside an AnchorPane.
      2. Implement ListCell with this graphic FXML and have the updateItem function like the follows, make the button onAction to delete the cell:
          
          public constructor(final HomeController homeController) {
               this.homeController = homeController;
          }
          @Override
          protected void updateItem(String name, boolean empty) {
              super.updateItem(name, empty);

              if (empty || name == null) {
                  setText(null);

                  setContentDisplay(ContentDisplay.TEXT_ONLY);
              } else {
                  profileLabel.setText(name);
                  deleteMenuItem.setOnAction(actionEvent -> {
                      homeController.delete(name);
                  });
                  setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
              }
          }
      3. Create a UI with ListView with this ListCell and feed in some dummy value
      4. Remove the last item in the list.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Item gets removed without exception
      ACTUAL -
      Program still continues, item got removed but NPE is logged in console:

      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
      at java.base/java.util.Objects.requireNonNull(Objects.java:221)
      at javafx.controls/javafx.scene.control.skin.MenuButtonSkinBase.lambda$new$7(MenuButtonSkinBase.java:198)
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
      at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

      ---------- BEGIN SOURCE ----------
      https://github.com/hlf0319/repro-openjdk-jfx-637
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Used JavaFX 13

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pnarayanaswa Praveen Narayanaswamy
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: