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

DatePicker: NPE in show() when initialized in a background thread

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • jfx23
    • javafx
    • None

      NOTE: the original test will be modified as a part of JDK-8349750 to call show() only in the FX application thread.

      ---

      The newly developed NodeInitializationStressTest fails with DatePicker:

      ```
          @Test
          public void datePicker() {
              test(() -> {
                  DatePicker c = new DatePicker();
                  c.setSkin(new DatePickerSkin(c));
                  return c;
              }, (c) -> {
                  c.show(); // fails here
                  c.setValue(LocalDate.now());
                  c.prefHeight(-1);
                  c.setValue(LocalDate.EPOCH);
                  c.prefWidth(-1);
              });
          }
      ```

      java.lang.NullPointerException: Cannot invoke "com.sun.javafx.scene.InputMethodStateManager.focusOwnerWillChangeForScene(javafx.scene.Scene)" because the return value of "javafx.scene.Scene.getInputMethodStateManager()" is null
      at javafx.graphics/javafx.scene.Scene.setFocusOwner(Scene.java:2353)
      at javafx.graphics/javafx.scene.Scene.requestFocus(Scene.java:2247)
      at javafx.graphics/javafx.scene.Node.requestFocus(Node.java:8520)
      at javafx.controls/com.sun.javafx.scene.control.DatePickerContent.goToDate(DatePickerContent.java:688)
      at javafx.controls/com.sun.javafx.scene.control.DatePickerContent.clearFocus(DatePickerContent.java:715)
      at javafx.controls/javafx.scene.control.skin.DatePickerSkin.show(DatePickerSkin.java:198)
      at javafx.controls/javafx.scene.control.skin.DatePickerSkin.lambda$5(DatePickerSkin.java:146)
      at javafx.controls/com.sun.javafx.scene.control.ListenerHelper$4.changed(ListenerHelper.java:212)
      at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:386)
      at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91)
      at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:78)
      at javafx.base/javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103)
      at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111)
      at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
      at javafx.controls/javafx.scene.control.ComboBoxBase.setShowing(ComboBoxBase.java:187)
      at javafx.controls/javafx.scene.control.ComboBoxBase.show(ComboBoxBase.java:395)
      at test.robot.javafx.scene.NodeInitializationBackgroundThreadTest.lambda$1(NodeInitializationBackgroundThreadTest.java:72)
      at test.robot.javafx.scene.NodeInitializationBackgroundThreadTest$1.run(NodeInitializationBackgroundThreadTest.java:142)
       

      ## Root Cause

      Focus is being requested in show(), even a background thread.

      ## Solution

      Do not request focus if in a background thread.

            angorya Andy Goryachev
            angorya Andy Goryachev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: