RFR: 8255248: NullPointerException in JFXPanel due to race condition in HostContainer [v9]
Kevin Rushforth
kcr at openjdk.org
Wed Nov 19 18:30:42 UTC 2025
On Wed, 19 Nov 2025 17:14:51 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> NPE is seen while accessing transient "scenePeer" variable between reads..
>> Fix is made to store it in a temp variable rather than reading it twice since the value can change between successive reads in many places it is accessed.
>> Also some debug logs added to be enabled via `jfxpanel.debug` property
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Review comment + OutputRedirect
Updated test looks good with one additional suggestion.
tests/system/src/test/java/test/javafx/embed/swing/JFXPanelNPETest.java line 99:
> 97: Platform.runLater(() -> contentPane.setScene(webView.getScene()));
> 98: Thread.sleep(1);
> 99: }
The calls in the loop to the FX and AWT threads are asynchronous, so I recommend adding the following after the loop to ensure that both threads are finished with the work submitted in the loops:
// Wait for both threads to process the earlier runnables
SwingUtilities.invokeAndWait(() -> {});
Util.runAndWait(() -> {});
-------------
PR Review: https://git.openjdk.org/jfx/pull/1968#pullrequestreview-3484177788
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2543122814
More information about the openjfx-dev
mailing list