RFR: 8255248: NullPointerException in JFXPanel due to race condition in HostContainer
Andy Goryachev
angorya at openjdk.org
Mon Nov 10 18:44:25 UTC 2025
On Mon, 10 Nov 2025 10:37:25 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
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 215:
> 213:
> 214: debugPrint = "true".equalsIgnoreCase(debugStr);
> 215: }
suggestion:
private static final boolean DEBUG = Boolean.getBoolean("jfxpanel.debug");
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 217:
> 215: }
> 216:
> 217: protected static void debug_println(String str) {
javadoc complains about this new public API. Or is it a temporary debugging thing? Can it be declared `private`?
If it is a permanent thing, it incurs a string concatenation overhead even when disabled. Use lambdas instead? Alternatively (and faster), one needs to check if debug printout is enabled on each use inline:
if(DEBUG) {
debug_println("JFXPanel Thread " + Thread.currentThread().getName() + " isFXUserThread " + Toolkit.getToolkit().isFxUserThread());
}
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2511593814
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2511576430
More information about the openjfx-dev
mailing list