Closed
Description
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
Pool should use offer, not add.