Skip to content

Pool.free throws illegalState if queue exceeds #642

Closed
@sramkumar76

Description

@sramkumar76

The current implementation of free (of Pool class) uses the add method of underlying queue which throws illegal state if the queue size exceeds. Ideally it should use offer as per the implementation logic of not adding to the pool if size increases.

public void free (T object) {
	if (object == null) throw new IllegalArgumentException("object cannot be null.");
	if (!**freeObjects.add(object)** && freeObjects instanceof SoftReferenceQueue) {
		((SoftReferenceQueue)freeObjects).cleanOne();
		freeObjects.add(object);
	}
	peak = Math.max(peak, freeObjects.size());
	reset(object);
}

Activity

added a commit that references this issue on Feb 10, 2025
4db5a3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sramkumar76

        Issue actions

          Pool.free throws illegalState if queue exceeds · Issue #642 · EsotericSoftware/kryo