RFR: 8255248: NullPointerException in JFXPanel due to race condition in HostContainer

Ajit Ghaisas aghaisas at openjdk.org
Tue Jul 18 10:18:06 UTC 2023


On Tue, 18 Jul 2023 06:05:06 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> Due to transient datatype of scenePeer, it can become null which can result in NPE in scenarios where scene is continuously been reset and set, which warrants a null check, as is done in other places for the same variable.

This avoids the NPE.

Overall, I think that we should choose between below options- 
- Option 1 : A null check should be added to every usage of `scenePeer` and `stagePeer` as close to the usage as possible.
- Option 2: The usage of `scenePeer` and `stagePeer` should be `synchronized`.

I am not well versed with this area of the code and hence cannot comment on ramifications of Option 2.

Also, can we add a test? (either automated or manual) - I see that there is a sample in JBS that demonstrates this issue.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1178#issuecomment-1639942140


More information about the openjfx-dev mailing list