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

Remove clear() call to release method of WeakEntryReference and SoftEntryReference #28863

Conversation

bcc829
Copy link
Contributor

@bcc829 bcc829 commented Jul 25, 2022

Remove clear() call to release method of WeakEntryReference and SoftEntryReference.

The code of the same behavior as the clear method is included inside the enqueue method.

java.lang.ref.Reference

    /**
     * Clears this reference object.  Invoking this method will not cause this
     * object to be enqueued.
     *
     * <p> This method is invoked only by Java code; when the garbage collector
     * clears references it does so directly, without invoking this method.
     */
    public void clear() {
        this.referent = null;
    }

    /**
     * Clears this reference object and adds it to the queue with which
     * it is registered, if any.
     *
     * <p> This method is invoked only by Java code; when the garbage collector
     * enqueues references it does so directly, without invoking this method.
     *
     * @return   <code>true</code> if this reference object was successfully
     *           enqueued; <code>false</code> if it was already enqueued or if
     *           it was not registered with a queue when it was created
     */
    public boolean enqueue() {
        this.referent = null;
        return this.queue.enqueue(this);
    }

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 25, 2022
@bcc829 bcc829 changed the title Remove clear() call to release method of WeakEntry Reference and SoftEntry Reference Remove clear() call to release method of WeakEntryReference and SoftEntryReference Jul 25, 2022
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jul 27, 2022
@sbrannen sbrannen added this to the Triage Queue milestone Jul 27, 2022
@bclozel bclozel self-assigned this Jan 17, 2023
@bclozel bclozel modified the milestones: Triage Queue, 6.0.5 Jan 17, 2023
@bclozel bclozel removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 17, 2023
@bclozel bclozel closed this in 37217a6 Jan 17, 2023
mdeinum pushed a commit to mdeinum/spring-framework that referenced this pull request Jun 29, 2023
Prior to this commit, `ConcurrentReferenceHashMap` subclasses extending
`Reference` would call `Reference::clear` right next to
`Reference::enqueue`; this is not needed as the latter calls it already.

Closes spring-projectsgh-28863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants