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.
---
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.
- blocks
-
JDK-8348987 ☂ Thread safety in Node initialization
-
- In Progress
-
- duplicates
-
JDK-8350048 Enforce threading restrictions for show and hide methods in Window, Control, and Skin
-
- Resolved
-
- relates to
-
JDK-8350048 Enforce threading restrictions for show and hide methods in Window, Control, and Skin
-
- Resolved
-
-
JDK-8349096 Split/MenuButton: exception initializing in a background thread
-
- Closed
-
- links to
-
Review(master) openjdk/jfx/1708