8283660: Convert com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java finalizer to Cleaner#8311
8283660: Convert com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java finalizer to Cleaner#8311bchristi-git wants to merge 29 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back bchristi! A progress list of the required criteria for merging this PR into |
|
@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 class maintains the pieces of state that need (or are needed for) | ||
| * cleanup, which happens by calling cleanup(), or is done by the Cleaner. | ||
| */ | ||
| private static class CleaningAction implements Runnable { |
There was a problem hiding this comment.
This nested class might be more aptly named EnumCtx since it is used during the enumeration process.
The mention of the cleanup() method in the nested class javadoc is a bit ambiguous, it seems there should be a cleanup() method in the class, but it is in AbstractLdapNamingEnumeration.
The state field might also be renamed enumCtx.
| this.homeCtx = homeCtx; | ||
| homeCtx.incEnumCount(); | ||
| enumClnt = homeCtx.clnt; // remember | ||
| this.state.homeCtx.incEnumCount(); |
There was a problem hiding this comment.
Readability might be improved by using the new homeCtx() method instead of state.homeCtx in this file.
It would then be consistent with how subclasses access it.
It depends which style you prefer to be more consistent with.
dfuch
left a comment
There was a problem hiding this comment.
I also agree with Roger's suggestions.
| @Override | ||
| public void run() { | ||
| if (enumClnt != null) { | ||
| enumClnt.clearSearchReply(res, homeCtx.reqCtls); |
There was a problem hiding this comment.
It's a bit strange to see that there is no guard here to verify that homeCtx != null, when line 76 implies that it might. My reading is that homeCtxt is not supposed to be null when enumClnt is not null. That could be explained in a comment, or alternatively asserted just before line 73 (assert homeCtx != null;)
There was a problem hiding this comment.
Yes, it is strange -- that code came from the finalizer. I will add an assert.
There was a problem hiding this comment.
It appears that the update() method can set 'homeCtx' for 'ne' to null while leaving 'enumClnt' non-null (~L410).
Perhaps here, the clearSearchReply() call should only happen if both are non-null.
| } | ||
| } | ||
|
|
||
| private CleaningAction state; |
There was a problem hiding this comment.
I wonder if state should be final?
There was a problem hiding this comment.
Makes sense to me. cleanable can be final, too.
…umeration for consistencty ; new instance vars can be final
|
Since synchronization may now happen on the cleaner thread, I've changed The added |
| try { | ||
| LdapResult newRes = homeCtx().getSearchReply(enumCtx.enumClnt, enumCtx.res); | ||
| enumCtx.setRes(newRes); | ||
| if (enumCtx.res == null) { |
There was a problem hiding this comment.
This looks odd, setting the value using synchronized, but reading it without.
There was a problem hiding this comment.
I've added getters to EnumCtx, and a comment explaining why only setters are synchronized.
src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
Show resolved
Hide resolved
src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
Show resolved
Hide resolved
src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
Show resolved
Hide resolved
|
Mailing list message from Hans Boehm on core-libs-dev: On Wed, Jun 1, 2022 at 2:47 PM Roger Riggs <rriggs at openjdk.java.net> wrote:
I agree that this is true with the right implementation assumptions, which tmp = a.field; Consider the full moon case. The reachabilityFence spec says: "the And indeed, a compiler could conceivably rewrite this to if (moon_phase() != FULL) { in which case this might, on very rare occasions, actually fail in the Hans |
|
Hans, thank for the detailed example. I had not fully considered the flow of control in the throwing case. |
| } | ||
| ncp.setNameInNamespace(dn); | ||
| return ncp; | ||
| } finally { |
There was a problem hiding this comment.
let's remove one redundant space after }
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Not today, PullrequestCloserBot |
|
@bchristi-git this pull request can not be integrated into git checkout remove-finalizers
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Thanks for the reminder, bridgekeeper |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Keepalive |
|
|
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
ever diligent, |
|
Oh darn, looks like |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
|
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
[Presses Snooze] |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Not yet |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Let's hang on to this for a bit longer |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
July already! |
|
@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 add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@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 |
|
Your persistence finally paid off, bridgekeeper - well played. |
|
"Who reviewth the PR of Death |
Please review this change to replace the finalizer in
AbstractLdapNamingEnumerationwith a Cleaner.The pieces of state required for cleanup (
LdapCtx homeCtx,LdapResult res, andLdapClient enumClnt) are moved to a static inner class . From there, the change is fairly mechanical.Details of note:
homeCtx; I added ahomeCtx()method to readhomeCtxfrom the superclass'sstate.The test case is based on a copy of
com/sun/jndi/ldap/blits/AddTests/AddNewEntry.java. A more minimal test case might be possible, but this was done for expediency.The test only confirms that the new Cleaner use does not keep the object reachable. It only tests
LdapSearchEnumeration(notLdapNamingEnumerationorLdapBindingEnumeration, though all are subclasses ofAbstractLdapNamingEnumeration).Thanks.
Progress
Integration blocker
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/8311/head:pull/8311$ git checkout pull/8311Update a local copy of the PR:
$ git checkout pull/8311$ git pull https://git.openjdk.org/jdk.git pull/8311/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8311View PR using the GUI difftool:
$ git pr show -t 8311Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/8311.diff
Webrev
Link to Webrev Comment