On Fri, 25 Jul 2025 22:32:36 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
> Fixed an NPE in the ToolBar, looks like a corner case. > Is this unit-testable? > Any minimal test case? Github ate my previous response! Restoring from memory. The bug came out of testing JDK-8364049. I could not create a headless unit test: it looks like the focus subsystem is involved which is not easily reproducible with a headless test. I don't want to create a headful test for this particular scenario. For the record, the test I tried to write: @Test public void testNPE_8364088() { BorderPane bp = new BorderPane(); Button b = new Button("Create Schema Overflow"); bp.setTop(new HBox(new ToolBar(b))); Stage stage = new Stage(); stage.setScene(new Scene(bp, 600, 400)); stage.setTitle(getClass().getSimpleName()); stage.show(); runLater(() -> { b.requestFocus(); runLater(() -> { stage.setWidth(50); runLater(() -> { stage.setWidth(40); System.out.println(stage.getWidth()); stage.hide(); }); }); }); } private static void runLater(Runnable r) { AtomicInteger counter = new AtomicInteger(10); Platform.runLater(new Runnable() { @Override public void run() { if (counter.decrementAndGet() > 0) { Platform.runLater(this); } else { r.run(); } } }); } ------------- PR Comment: https://git.openjdk.org/jfx/pull/1857#issuecomment-3132918888