public synchronized void returnObject()

in src/main/java/org/apache/commons/pool3/impl/SoftReferenceObjectPool.java [376:409]


    public synchronized void returnObject(final T obj) throws E {
        boolean success = !isClosed();
        final PooledSoftReference<T> ref = findReference(obj);
        if (ref == null) {
            throw new IllegalStateException("Returned object not currently part of this pool");
        }
        if (!factory.validateObject(ref)) {
            success = false;
        } else {
            try {
                factory.passivateObject(ref);
            } catch (final Exception e) {
                success = false;
            }
        }

        final boolean shouldDestroy = !success;
        numActive--;
        if (success) {

            // Deallocate and add to the idle instance pool
            ref.deallocate();
            idleReferences.add(ref);
        }
        notifyAll(); // numActive has changed

        if (shouldDestroy) {
            try {
                destroy(ref);
            } catch (final Exception ignored) {
                // ignored
            }
        }
    }