[Rev 01] RFR: 8241840: Memoryleak: Closed focused Stages are not collected with Monocle.
Florian Kirmaier
fkirmaier at openjdk.java.net
Wed Apr 22 10:58:37 UTC 2020
On Fri, 17 Apr 2020 12:50:50 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:
>> Florian Kirmaier has updated the pull request incrementally with one additional commit since the last revision:
>>
>> JDK-8241840
>> Some code cleanups
>
> tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java line 103:
>
>> 102: assertCollectable(closedFocusedStageWeak);
>> 103: }
>> 104:
>
> The current test does not assure that stage is shown when `close()` is called or it is closed when `requestFocus()` is
> called, I would recommend the test to be as,
> @Test
> public void testClosedFocusedStageLeak() throws Exception {
> CountDownLatch latch = new CountDownLatch(1);
> Util.runAndWait(() -> {
> closedFocusedStage = new Stage();
> closedFocusedStage.setTitle("Focused Stage");
> closedFocusedStageWeak = new WeakReference<>(closedFocusedStage);
> TextField textField = new TextField();
> closedFocusedStage.setScene(new Scene(textField));
> closedFocusedStage.setOnShown(l -> {
> latch.countDown();
> });
> closedFocusedStage.show();
> });
> Assert.assertTrue("Timeout waiting for closedFocusedStage to show`",
> latch.await(15, TimeUnit.MILLISECONDS));
>
> CountDownLatch hideLatch = new CountDownLatch(1);
> closedFocusedStage.setOnHidden(a -> {
> hideLatch.countDown();
> });
> Util.runAndWait(() -> closedFocusedStage.close());
> Assert.assertTrue("Timeout waiting for closedFocusedStage to hide`",
> hideLatch.await(15, TimeUnit.MILLISECONDS));
>
> closedFocusedStage.requestFocus();
> closedFocusedStage = null;
> assertCollectable(closedFocusedStageWeak);
> }
I've changed it accordingly. I've also verified that the new version catches the old leak and works with my suggested
changes.
-------------
PR: https://git.openjdk.java.net/jfx/pull/153
More information about the openjfx-dev
mailing list