RFR: 8264330: Scene MouseHandler is referencing removed nodes

Kevin Rushforth kcr at openjdk.java.net
Wed Mar 31 13:16:09 UTC 2021


On Wed, 31 Mar 2021 05:36:06 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

> Small fix to clear a reference to a removed node left by Scene$MouseHandler.

The fix looks good to me. I haven't run the test yet, but it seems OK except for the handling of GC to check for the leak (I left an inline comment).

modules/javafx.graphics/src/main/java/javafx/scene/Scene.java line 3633:

> 3631:                     ? currentEventTargets.get(0) : null;
> 3632:             pdrEventTarget.clear();
> 3633:             pdrEventTargets.clear();  // clear to remove potentially removed nodes, see JDK-8264330

We generally don't refer to the bug ID unless there is something particularly tricky about the fix (which isn't the case here).

modules/javafx.graphics/src/test/java/test/javafx/scene/SceneTest.java line 1019:

> 1017:         pane = null;
> 1018: 
> 1019:         System.gc();

It is not sufficient to call `System.gc()` only once, since it will make for a fragile test. I recommend using the `JMemoryBuddy::assertCollectable` for this, which is what we are using for new tests.

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

PR: https://git.openjdk.java.net/jfx/pull/448


More information about the openjfx-dev mailing list