spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

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

Open bcc829 opened this issue 2 years ago • 0 comments

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);
    }

bcc829 avatar Jul 25 '22 05:07 bcc829