RFR: 8371128: NullPointerException occurs due to double cleanup of SwingNode [v2]
Kevin Rushforth
kcr at openjdk.org
Wed Nov 5 15:51:19 UTC 2025
On Wed, 5 Nov 2025 15:25:23 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> @prsadhuk You are correct. There is no thread switching in that block (it's all on the FX app thread, which creates an event and then sends that created event to the EDT).
>>
>> Go ahead and integrate this PR.
>
> yes, the block is on the fx thread, but the value of lwFrame is modified on the EDT.
> Instead of this code where check and use happens with the volatile lwFrame, it should instead get the value into a temp variable and use that.
>
>
> var lw = lwFrame;
> if(lw != null) {
> use(lw)
> }
>
>
> here is the scenario, the way I see it:
>
> swing fx
> not null
> L557, not null
> (context switch)
> sets to null
> (context switch)
> L559, null
>
>
> unlikely, but possible, I think.
Yes, the scenario you pointed out is possible -- it's different from the (more serious) issue that I was thinking it was. And the solution is exactly as you point out: store it in a temp variable rather than reading it twice since the value can change between successive reads.
@prsadhuk Please file a follow-up bug.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1960#discussion_r2495140272
More information about the openjfx-dev
mailing list