RFR: 8255248: NullPointerException in JFXPanel due to race condition in HostContainer [v2]
Andy Goryachev
angorya at openjdk.org
Wed Nov 12 17:03:18 UTC 2025
On Tue, 11 Nov 2025 03:02:01 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:
>
> debug fix
Changes requested by angorya (Reviewer).
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 212:
> 210:
> 211: private static void debug_println(String str) {
> 212: if (DEBUG) {
I am sorry, I was not sufficiently clear.
This method does not need the conditional. The conditionals are needed in **every** place that calls here.
In other words, we don't want to incur the string concatenation overhead if **DEBUG** is false.
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 286:
> 284: super();
> 285:
> 286: debug_println("JFXPanel Thread " + Thread.currentThread().getName() + " isFXUserThread " + Toolkit.getToolkit().isFxUserThread());
Basically, here (and elsewhere debug_println() is called) we should have
if(DEBUG) {
debug_println("JFXPanel Thread " + Thread.currentThread().getName() + " isFXUserThread " + Toolkit.getToolkit().isFxUserThread());
}
As a separate note, you may want to consider removing some noise from debugging output and only print when "unexpected" condition occurs, such as (thread != fx), right?
-------------
PR Review: https://git.openjdk.org/jfx/pull/1968#pullrequestreview-3454498726
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2519095341
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2519105890
More information about the openjfx-dev
mailing list