On Fri, 17 Apr 2020 12:50:50 GMT, Ambarish Rapte <ara...@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