/** * {@inheritDoc} */ @Override public boolean validateObject(final K key, final PooledObject<V> p) { writeLock.lock(); try { return keyedFactory.validateObject(key, p); } finally { writeLock.unlock(); } }
private static <K, V> List<String> invokeEveryMethod(final KeyedPooledObjectFactory<K, V> kpof) throws Exception { kpof.activateObject(null, null); kpof.destroyObject(null, null); kpof.makeObject(null); kpof.passivateObject(null, null); kpof.validateObject(null, null); kpof.toString(); final List<String> expectedMethods = Arrays.asList(new String[] { "activateObject", "destroyObject", "makeObject", "passivateObject", "validateObject", "toString", }); return expectedMethods; }
if (!factory.validateObject(evictionKey, underTest)) { destroy(evictionKey, underTest, true); destroyedByEvictorCount.incrementAndGet();
@Test public void testDefaultMethods() throws Exception { final KeyedPooledObjectFactory<Object,Object> factory = new TestFactory(); factory.activateObject("key",null); // a no-op factory.passivateObject("key",null); // a no-op factory.destroyObject("key",null); // a no-op assertTrue(factory.validateObject("key",null)); // constant true }
Throwable validationThrowable = null; try { validate = factory.validateObject(key, p); } catch (final Throwable t) { PoolUtils.checkRethrow(t);
/** * {@inheritDoc} */ @Override public boolean validateObject(final K key, final PooledObject<V> p) { writeLock.lock(); try { return keyedFactory.validateObject(key, p); } finally { writeLock.unlock(); } }
if (getTestOnReturn() && !factory.validateObject(key, p)) { try { destroy(key, p, true);
@Test public void poolFactoryFullObjectLifecycleTest() throws Exception { PooledObject<TServiceClient> pooledObject = factory.makeObject(thriftClientKey); factory.activateObject(thriftClientKey, pooledObject); factory.validateObject(thriftClientKey, pooledObject); factory.passivateObject(thriftClientKey, pooledObject); }
if (!factory.validateObject(evictionKey, underTest)) { destroy(evictionKey, underTest, true); destroyedByEvictorCount.incrementAndGet();
@Test public void poolFactoryOverlappingObjectLifecyclesTest() throws Exception { PooledObject<TServiceClient> pooledObject1 = factory.makeObject(thriftClientKey); // activateObject leads to tracer.isEnabled() --> true factory.activateObject(thriftClientKey, pooledObject1); factory.validateObject(thriftClientKey, pooledObject1); // Create another pooled object and passivate it right away. // See poolFactoryNonstandardObjectLifecycleTest() for details PooledObject<TServiceClient> pooledObject2 = factory.makeObject(thriftClientKey); factory.passivateObject(thriftClientKey, pooledObject2); } }
Throwable validationThrowable = null; try { validate = factory.validateObject(key, p); } catch (final Throwable t) { PoolUtils.checkRethrow(t);
if (getTestOnReturn() && !factory.validateObject(key, p)) { try { destroy(key, p, true);