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

NPE in MenuButtonSkinBase change listener

XMLWordPrintable

      The fix for JDK-8175358 has resulted in an NPE in the newly added MenuButtonSkinBase change listener.

      To reproduce this bug, run the test.javafx.scene.control.MenuButtonSkinBaseNPETest.testMenuButtonNPE test as follows:

      $ gradle -PFULL_TEST=true :systemTests:test --tests MenuButtonSkinBaseNPETest

      test.javafx.scene.control.MenuButtonSkinBaseNPETest > testMenuButtonNPE FAILED
          org.junit.ComparisonFailure: No error should be thrown expected:<[]> but was:<[Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
           at javafx.controls/javafx.scene.control.skin.MenuButtonSkinBase.lambda$new$3(MenuButtonSkinBase.java:151)
           at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
           at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
           at javafx.base/javafx.beans.property.ReadOnlyObjectPropertyBase.fireValueChangedEvent(ReadOnlyObjectPropertyBase.java:74)
           at javafx.base/javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:102)
           at javafx.graphics/javafx.scene.Node$ReadOnlyObjectWrapperManualFire.fireSuperValueChangedEvent(Node.java:1050)
           at javafx.graphics/javafx.scene.Node.invalidatedScenes(Node.java:1121)
           at javafx.graphics/javafx.scene.Node.setScenes(Node.java:1159)
           at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:605)
           at javafx.base/com.sun.javafx.collections.VetoableListDecorator.clear(VetoableListDecorator.java:294)
           at javafx.controls/javafx.scene.control.skin.MenuBarSkin.rebuildUI(MenuBarSkin.java:848)
           at javafx.controls/javafx.scene.control.skin.MenuBarSkin.lambda$new$13(MenuBarSkin.java:359)
           at javafx.base/com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
           at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
           at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
           at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
           at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
           at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
           at javafx.base/com.sun.javafx.collections.ObservableListWrapper.clear(ObservableListWrapper.java:157)
           at test.javafx.scene.control.MenuButtonSkinBaseNPETest.lambda$testMenuButtonNPE$0(MenuButtonSkinBaseNPETest.java:72)
           at test.util.Util.lambda$submit$0(Util.java:96)
           at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
           at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
           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)
           at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
           at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
           at java.base/java.lang.Thread.run(Thread.java:832)
          ]>
              at org.junit.Assert.assertEquals(Assert.java:123)
              at test.javafx.scene.control.MenuButtonSkinBaseNPETest.testMenuButtonNPE(MenuButtonSkinBaseNPETest.java:76)

      The code that is getting the NPE was added as part of the fix for for JDK-8175358 :

                  if (oldValue != null) {
      ==> ControlAcceleratorSupport.removeAcceleratorsFromScene(getSkinnable().getItems(), oldValue);
                  }

      this will get an NPE if getSkinnable() returns null at the time the the listener is called.

            aghaisas Ajit Ghaisas
            kcr Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: