Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8315317: Add test for JDK-8262518 #1228

Closed
wants to merge 3 commits into from

Conversation

prsadhuk
Copy link
Collaborator

@prsadhuk prsadhuk commented Sep 1, 2023

Added automated test for 8262518:SwingNode.setContent does not close previous content, resulting in memory leak


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1228/head:pull/1228
$ git checkout pull/1228

Update a local copy of the PR:
$ git checkout pull/1228
$ git pull https://git.openjdk.org/jfx.git pull/1228/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1228

View PR using the GUI difftool:
$ git pr show -t 1228

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1228.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 1, 2023

👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Sep 1, 2023
@mlbridge
Copy link

mlbridge bot commented Sep 1, 2023

Webrevs

long panelCount = panels.stream().filter(ref ->
ref.get() != null).count();
// Sometimes panel count can shoot upto more than 3 once or twice
// due to gc not being guranteed so this check prevents false failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guaranteed

}
System.out.println("iteration " + count + " Panels in memory: "
+ panelCount + " fail " + fail);
assertFalse(fail > 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually seen the number to shoot up to 38 (albeit with Thread.sleep(1)). I wonder if there is a better way to detect failure? May be the fact that the 'panelCount` is ever increasing is the sign of failure, whereas if at least one time it's dropping we have succeeded.
Or perhaps look at the count when the test complete and fail if panelCount < (attempts / 2) or something

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using JMemoryBuddy, which is what we use for all of our newer memory leak tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand the nuances of JMemoryBuddy. I tried using JMemoryBuddy.assertCollectable but it fails with

Exception in thread "Thread-7" java.lang.AssertionError: Content of WeakReference was not collected. content: javax.swing.JPanel[,0,0,0x0,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
	at test.util.memory.JMemoryBuddy.assertCollectable(JMemoryBuddy.java:91)

maybe because the test doesn't cause SwingNode content count to 0.

But I have modified the test to have better way of detecting failure as suggested and check for total count at end which normally increases without fix..I hope that should be good enough to ensure it fails without the fix and pass with it..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any more comments on this test fix after updation @andy-goryachev-oracle ?

while(count < 50) {
//Lets throw in a little sleep so we can read the output
try {
Thread.sleep(100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to use random delay here (random.nextInt(100)).
But make sure to set a random seed at the beginning and print it so it can be reproduced. Although in this test, the outcome depends on many things that the test has no control over.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, let's not. While there may be some rare cases where randomness adds something useful to the test, automated tests should be predictable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they become predictable when the seed is known.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then you would need to modify the test to rerun it with the same seed as the time it failed. If we had a utility that made this easy, then maybe, but I'd still be skeptical. I am not convinced that whatever benefit we might get is worth the effort or the unpredictability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main benefit is that every new run effectively extends the test coverage.
however, in this particular case, the test won't be reproducible because it depends on many other factors like the platform load.

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good 🕶
even with Thread.sleep(1);

@openjdk
Copy link

openjdk bot commented Sep 8, 2023

@prsadhuk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8315317: Add test for JDK-8262518

Reviewed-by: angorya

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 7 new commits pushed to the master branch:

  • ed92171: 8315870: icu fails to compile with Visual Studio 2022 17.6.5
  • 8fcd6e5: 8308608: [testbug] Use Util::waitForIdle instead of Toolkit::firePulse in system tests
  • 3bfede8: 8314779: [testbug] Add test to all the XYCharts to check if chart components are removed when series is cleared
  • 668e4b9: 8315728: [testbug] SystemMenuBarTest prints "FAILED IS: false"
  • e8491ba: 8283675: Line not removed from LineChart when series cleared
  • 84aad81: 8314064: Enable building JavaFX on native Windows AArch64 (ARM64)
  • 82f2774: 8311097: Synchron XMLHttpRequest not receiving data

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Sep 8, 2023
@prsadhuk
Copy link
Collaborator Author

prsadhuk commented Sep 8, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Sep 8, 2023

Going to push as commit eb7de72.
Since your change was applied there have been 7 commits pushed to the master branch:

  • ed92171: 8315870: icu fails to compile with Visual Studio 2022 17.6.5
  • 8fcd6e5: 8308608: [testbug] Use Util::waitForIdle instead of Toolkit::firePulse in system tests
  • 3bfede8: 8314779: [testbug] Add test to all the XYCharts to check if chart components are removed when series is cleared
  • 668e4b9: 8315728: [testbug] SystemMenuBarTest prints "FAILED IS: false"
  • e8491ba: 8283675: Line not removed from LineChart when series cleared
  • 84aad81: 8314064: Enable building JavaFX on native Windows AArch64 (ARM64)
  • 82f2774: 8311097: Synchron XMLHttpRequest not receiving data

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 8, 2023
@openjdk openjdk bot closed this Sep 8, 2023
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels Sep 8, 2023
@openjdk
Copy link

openjdk bot commented Sep 8, 2023

@prsadhuk Pushed as commit eb7de72.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
3 participants