/** * Marks the object as returning to the pool. * @param pooledObject instance to return to the keyed pool */ protected void markReturningState(final PooledObject<T> pooledObject) { synchronized(pooledObject) { final PooledObjectState state = pooledObject.getState(); if (state != PooledObjectState.ALLOCATED) { throw new IllegalStateException( "Object has already been returned to this pool or is invalid"); } pooledObject.markReturning(); // Keep from being marked abandoned } }
final PooledObject<T> pooledObject = it.next(); synchronized (pooledObject) { if (pooledObject.getState() == PooledObjectState.ALLOCATED && pooledObject.getLastUsedTime() <= timeout) { pooledObject.markAbandoned();
/** * {@inheritDoc} * <p> * Activation of this method decrements the active count and attempts to * destroy the instance. * * @throws Exception if an exception occurs destroying the * object * @throws IllegalStateException if obj does not belong to this pool */ @Override public void invalidateObject(final T obj) throws Exception { final PooledObject<T> p = allObjects.get(new IdentityWrapper<>(obj)); if (p == null) { if (isAbandonedConfig()) { return; } throw new IllegalStateException( "Invalidated object not currently part of this pool"); } synchronized (p) { if (p.getState() != PooledObjectState.INVALID) { destroy(p); } } ensureIdle(1, false); }
if (p.getState() != PooledObjectState.INVALID) { destroy(key, p, true);
/** * Marks the object as returning to the pool. * @param pooledObject instance to return to the keyed pool */ protected void markReturningState(final PooledObject<T> pooledObject) { synchronized(pooledObject) { final PooledObjectState state = pooledObject.getState(); if (state != PooledObjectState.ALLOCATED) { throw new IllegalStateException( "Object has already been returned to this pool or is invalid"); } pooledObject.markReturning(); // Keep from being marked abandoned } }
final PooledObject<T> pooledObject = it.next(); synchronized (pooledObject) { if (pooledObject.getState() == PooledObjectState.ALLOCATED && pooledObject.getLastUsedTime() <= timeout) { pooledObject.markAbandoned();
/** * {@inheritDoc} * <p> * Activation of this method decrements the active count and attempts to * destroy the instance. * * @throws Exception if an exception occurs destroying the * object * @throws IllegalStateException if obj does not belong to this pool */ @Override public void invalidateObject(final T obj) throws Exception { final PooledObject<T> p = allObjects.get(new IdentityWrapper<>(obj)); if (p == null) { if (isAbandonedConfig()) { return; } throw new IllegalStateException( "Invalidated object not currently part of this pool"); } synchronized (p) { if (p.getState() != PooledObjectState.INVALID) { destroy(p); } } ensureIdle(1, false); }
if (p.getState() != PooledObjectState.INVALID) { destroy(key, p, true);