-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8283660: Convert com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java finalizer to Cleaner #25242
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
Conversation
…umeration for consistencty ; new instance vars can be final
…ome unneeded comments
|
👋 Welcome back bchristi! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@bchristi-git The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
| this.homeCtx = homeCtx; | ||
| homeCtx.incEnumCount(); | ||
| enumClnt = homeCtx.clnt; // remember | ||
| this.enumCtx.homeCtx.incEnumCount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bchristi-git Would it make sense to increment this in the EnumCtx ctor instead?
| protected final void finalize() { | ||
| cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
| // No reachabilityFence here for now. | ||
| // super() call (aka AbstrctLdapNamingEnumeration ctor) keeps 'this' | ||
| // reachable until end of Cleaner registration. Code after that | ||
| // clearly does not touch cleanable state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bchristi-git I fear this could be a brittle assumption. Would an extra reachabilityFence here hurt?
dfuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. I haven't verified whether all methods that need a reachabilityFence have it. This will require further analysis (from me).
As Alan noted it would be really good if we could use try-with-resource, but I am not expert enough in LDAP search implementation to figure out whether that's feasible.
Your proposed fix preseves the status quo - where a finalizer has been replaced by a cleaner - and asserting that the two are equivalent seems more trackable for now.
| errEx = ne.errEx; | ||
| try { | ||
| // Cleanup previous context first | ||
| getHomeCtx().decEnumCount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for calling getHomeCtx() here when we use enumCtxt.homeCtx a few lines below?
|
@bchristi-git This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
@bchristi-git This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Please review this change to replace the finalizer in
AbstractLdapNamingEnumerationwith Cleaner.(The first PR for this fix started some substantial discussions, leading to, among other things, the 8314480
java.lang.refmemory ordering spec update.)In standard fashion, pieces of state required for cleanup (
LdapCtx homeCtx,LdapResult res, andLdapClient enumClnt) are moved into a Context object. From there, the change is fairly mechanical.Details of note:
update()method is probably the most interesting). Use ofreachabilityFence()ensures memory visibility on the Cleaner thread (per the aforementioned spec update).homeCtx; I added ahomeCtx()method to readhomeCtxfrom the superclass's state.The test case is based on a copy of
com/sun/jndi/ldap/blits/AddTests/AddNewEntry.java. It confirms that the use of Cleaner does not keep anLdapSearchEnumerationobject reachable. The otherAbstractLdapNamingEnumerationsubclasses (LdapNamingEnumerationandLdapBindingEnumeration) can be expected to behave the same.Thanks.
Edit: (Re)viewers: due to there being a lot of indentation changes, you might consider enabling the "Hide whitespace" option on the "Files changed" tab. To my eye, it gives a better view of the changes.
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25242/head:pull/25242$ git checkout pull/25242Update a local copy of the PR:
$ git checkout pull/25242$ git pull https://git.openjdk.org/jdk.git pull/25242/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25242View PR using the GUI difftool:
$ git pr show -t 25242Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25242.diff
Using Webrev
Link to Webrev Comment