http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java b/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java index 26536b0..b837300 100644 --- a/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java +++ b/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java @@ -44,8 +44,8 @@ public class ProxiedKeyedObjectPool<K,V> implements KeyedObjectPool<K,V> { * @param pool The object pool to wrap * @param proxySource The source of the proxy objects */ - public ProxiedKeyedObjectPool(KeyedObjectPool<K,V> pool, - ProxySource<V> proxySource) { + public ProxiedKeyedObjectPool(final KeyedObjectPool<K,V> pool, + final ProxySource<V> proxySource) { this.pool = pool; this.proxySource = proxySource; } @@ -53,7 +53,7 @@ public class ProxiedKeyedObjectPool<K,V> implements KeyedObjectPool<K,V> { @SuppressWarnings("unchecked") @Override - public V borrowObject(K key) throws Exception, NoSuchElementException, + public V borrowObject(final K key) throws Exception, NoSuchElementException, IllegalStateException { UsageTracking<V> usageTracking = null; if (pool instanceof UsageTracking) { @@ -65,30 +65,30 @@ public class ProxiedKeyedObjectPool<K,V> implements KeyedObjectPool<K,V> { } @Override - public void returnObject(K key, V proxy) throws Exception { + public void returnObject(final K key, final V proxy) throws Exception { final V pooledObject = proxySource.resolveProxy(proxy); pool.returnObject(key, pooledObject); } @Override - public void invalidateObject(K key, V proxy) throws Exception { + public void invalidateObject(final K key, final V proxy) throws Exception { final V pooledObject = proxySource.resolveProxy(proxy); pool.invalidateObject(key, pooledObject); } @Override - public void addObject(K key) throws Exception, IllegalStateException, + public void addObject(final K key) throws Exception, IllegalStateException, UnsupportedOperationException { pool.addObject(key); } @Override - public int getNumIdle(K key) { + public int getNumIdle(final K key) { return pool.getNumIdle(key); } @Override - public int getNumActive(K key) { + public int getNumActive(final K key) { return pool.getNumActive(key); } @@ -108,7 +108,7 @@ public class ProxiedKeyedObjectPool<K,V> implements KeyedObjectPool<K,V> { } @Override - public void clear(K key) throws Exception, UnsupportedOperationException { + public void clear(final K key) throws Exception, UnsupportedOperationException { pool.clear(key); }
http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/main/java/org/apache/commons/pool2/proxy/ProxiedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/pool2/proxy/ProxiedObjectPool.java b/src/main/java/org/apache/commons/pool2/proxy/ProxiedObjectPool.java index 59c5402..5496342 100644 --- a/src/main/java/org/apache/commons/pool2/proxy/ProxiedObjectPool.java +++ b/src/main/java/org/apache/commons/pool2/proxy/ProxiedObjectPool.java @@ -43,7 +43,7 @@ public class ProxiedObjectPool<T> implements ObjectPool<T> { * @param pool The object pool to wrap * @param proxySource The source of the proxy objects */ - public ProxiedObjectPool(ObjectPool<T> pool, ProxySource<T> proxySource) { + public ProxiedObjectPool(final ObjectPool<T> pool, final ProxySource<T> proxySource) { this.pool = pool; this.proxySource = proxySource; } @@ -66,14 +66,14 @@ public class ProxiedObjectPool<T> implements ObjectPool<T> { @Override - public void returnObject(T proxy) throws Exception { + public void returnObject(final T proxy) throws Exception { final T pooledObject = proxySource.resolveProxy(proxy); pool.returnObject(pooledObject); } @Override - public void invalidateObject(T proxy) throws Exception { + public void invalidateObject(final T proxy) throws Exception { final T pooledObject = proxySource.resolveProxy(proxy); pool.invalidateObject(pooledObject); } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/MethodCall.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/MethodCall.java b/src/test/java/org/apache/commons/pool2/MethodCall.java index bb8fe02..7b56c79 100644 --- a/src/test/java/org/apache/commons/pool2/MethodCall.java +++ b/src/test/java/org/apache/commons/pool2/MethodCall.java @@ -71,7 +71,7 @@ public class MethodCall { this.returned = returned; } - public MethodCall returned(Object obj) { + public MethodCall returned(final Object obj) { setReturned(obj); return this; } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java b/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java index 3125993..0b71c1a 100644 --- a/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java +++ b/src/test/java/org/apache/commons/pool2/TestBaseKeyedPoolableObjectFactory.java @@ -39,11 +39,11 @@ public class TestBaseKeyedPoolableObjectFactory { private static class TestFactory extends BaseKeyedPooledObjectFactory<Object,Object> { @Override - public Object create(Object key) throws Exception { + public Object create(final Object key) throws Exception { return null; } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java b/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java index fc81213..12cbc93 100644 --- a/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/TestBaseObjectPool.java @@ -34,7 +34,7 @@ public class TestBaseObjectPool extends TestObjectPool { * * @return A newly created empty pool */ - protected ObjectPool<String> makeEmptyPool(int mincapacity) { + protected ObjectPool<String> makeEmptyPool(final int mincapacity) { if (this.getClass() != TestBaseObjectPool.class) { fail("Subclasses of TestBaseObjectPool must reimplement this method."); } @@ -284,10 +284,10 @@ public class TestBaseObjectPool extends TestObjectPool { return null; } @Override - public void returnObject(Object obj) { + public void returnObject(final Object obj) { } @Override - public void invalidateObject(Object obj) { + public void invalidateObject(final Object obj) { } } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java b/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java index 82eb630..00633a6 100644 --- a/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java +++ b/src/test/java/org/apache/commons/pool2/TestBasePoolableObjectFactory.java @@ -42,7 +42,7 @@ public class TestBasePoolableObjectFactory { return null; } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java index 809ebb4..4c646cc 100644 --- a/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java @@ -674,7 +674,7 @@ public abstract class TestKeyedObjectPool { return new Object(); } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } @@ -717,7 +717,7 @@ public abstract class TestKeyedObjectPool { return makeObjectFail; } - public void setMakeObjectFail(boolean makeObjectFail) { + public void setMakeObjectFail(final boolean makeObjectFail) { this.makeObjectFail = makeObjectFail; } @@ -725,7 +725,7 @@ public abstract class TestKeyedObjectPool { return destroyObjectFail; } - public void setDestroyObjectFail(boolean destroyObjectFail) { + public void setDestroyObjectFail(final boolean destroyObjectFail) { this.destroyObjectFail = destroyObjectFail; } @@ -733,7 +733,7 @@ public abstract class TestKeyedObjectPool { return validateObjectFail; } - public void setValidateObjectFail(boolean validateObjectFail) { + public void setValidateObjectFail(final boolean validateObjectFail) { this.validateObjectFail = validateObjectFail; } @@ -741,7 +741,7 @@ public abstract class TestKeyedObjectPool { return activateObjectFail; } - public void setActivateObjectFail(boolean activateObjectFail) { + public void setActivateObjectFail(final boolean activateObjectFail) { this.activateObjectFail = activateObjectFail; } @@ -749,7 +749,7 @@ public abstract class TestKeyedObjectPool { return passivateObjectFail; } - public void setPassivateObjectFail(boolean passivateObjectFail) { + public void setPassivateObjectFail(final boolean passivateObjectFail) { this.passivateObjectFail = passivateObjectFail; } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/TestObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/TestObjectPool.java b/src/test/java/org/apache/commons/pool2/TestObjectPool.java index 8a679b4..fe737af 100644 --- a/src/test/java/org/apache/commons/pool2/TestObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/TestObjectPool.java @@ -417,7 +417,7 @@ public abstract class TestObjectPool { pool.close(); } - static void removeDestroyObjectCall(List<MethodCall> calls) { + static void removeDestroyObjectCall(final List<MethodCall> calls) { final Iterator<MethodCall> iter = calls.iterator(); while (iter.hasNext()) { final MethodCall call = iter.next(); http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/TestPoolUtils.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java index 0667be1..5d6da2b 100644 --- a/src/test/java/org/apache/commons/pool2/TestPoolUtils.java +++ b/src/test/java/org/apache/commons/pool2/TestPoolUtils.java @@ -563,7 +563,7 @@ public class TestPoolUtils { final ObjectPool<Object> internalPool = createProxy(ObjectPool.class, new InvocationHandler() { @Override - public Object invoke(Object arg0, Method arg1, Object[] arg2) + public Object invoke(final Object arg0, final Method arg1, final Object[] arg2) throws Throwable { return null; } @@ -694,7 +694,7 @@ public class TestPoolUtils { final KeyedObjectPool<Object, Object> internalPool = createProxy(KeyedObjectPool.class, new InvocationHandler() { @Override - public Object invoke(Object arg0, Method arg1, Object[] arg2) + public Object invoke(final Object arg0, final Method arg1, final Object[] arg2) throws Throwable { return null; } @@ -801,7 +801,7 @@ public class TestPoolUtils { assertNotNull(PoolUtils.TimerHolder.MIN_IDLE_TIMER); } - private static List<String> invokeEveryMethod(ObjectPool<Object> op) throws Exception { + private static List<String> invokeEveryMethod(final ObjectPool<Object> op) throws Exception { op.addObject(); op.borrowObject(); op.clear(); @@ -820,7 +820,7 @@ public class TestPoolUtils { return expectedMethods; } - private static List<String> invokeEveryMethod(KeyedObjectPool<Object,Object> kop) throws Exception { + private static List<String> invokeEveryMethod(final KeyedObjectPool<Object,Object> kop) throws Exception { kop.addObject(null); kop.borrowObject(null); kop.clear(); @@ -842,7 +842,7 @@ public class TestPoolUtils { return expectedMethods; } - private static <T> List<String> invokeEveryMethod(PooledObjectFactory<T> pof) throws Exception { + private static <T> List<String> invokeEveryMethod(final PooledObjectFactory<T> pof) throws Exception { pof.activateObject(null); pof.destroyObject(null); pof.makeObject(); @@ -857,7 +857,7 @@ public class TestPoolUtils { return expectedMethods; } - private static <K,V> List<String> invokeEveryMethod(KeyedPooledObjectFactory<K,V> kpof) throws Exception { + 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); http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/VisitTracker.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/VisitTracker.java b/src/test/java/org/apache/commons/pool2/VisitTracker.java index ea3617a..9fc4f58 100644 --- a/src/test/java/org/apache/commons/pool2/VisitTracker.java +++ b/src/test/java/org/apache/commons/pool2/VisitTracker.java @@ -34,13 +34,13 @@ public class VisitTracker<K> { reset(); } - public VisitTracker(int id) { + public VisitTracker(final int id) { super(); this.id = id; reset(); } - public VisitTracker(int id, K key) { + public VisitTracker(final int id, final K key) { super(); this.id = id; this.key = key; @@ -98,7 +98,7 @@ public class VisitTracker<K> { return "Key: " + key + " id: " + id; } - private void fail(String message) { + private void fail(final String message) { throw new IllegalStateException(message); } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java b/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java index 448727c..f341dea 100644 --- a/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java +++ b/src/test/java/org/apache/commons/pool2/VisitTrackerFactory.java @@ -37,39 +37,39 @@ public class VisitTrackerFactory<K> implements PooledObjectFactory<VisitTracker< return new DefaultPooledObject<VisitTracker<K>>(new VisitTracker<K>(nextId++)); } @Override - public PooledObject<VisitTracker<K>> makeObject(K key) { + public PooledObject<VisitTracker<K>> makeObject(final K key) { return new DefaultPooledObject<VisitTracker<K>>(new VisitTracker<K>(nextId++, key)); } @Override - public void destroyObject(PooledObject<VisitTracker<K>> ref) { + public void destroyObject(final PooledObject<VisitTracker<K>> ref) { ref.getObject().destroy(); } @Override - public void destroyObject(K key, PooledObject<VisitTracker<K>> ref) { + public void destroyObject(final K key, final PooledObject<VisitTracker<K>> ref) { ref.getObject().destroy(); } @Override - public boolean validateObject(PooledObject<VisitTracker<K>> ref) { + public boolean validateObject(final PooledObject<VisitTracker<K>> ref) { return ref.getObject().validate(); } @Override - public boolean validateObject(K key, PooledObject<VisitTracker<K>> ref) { + public boolean validateObject(final K key, final PooledObject<VisitTracker<K>> ref) { return ref.getObject().validate(); } @Override - public void activateObject(PooledObject<VisitTracker<K>> ref) throws Exception { + public void activateObject(final PooledObject<VisitTracker<K>> ref) throws Exception { ref.getObject().activate(); } @Override - public void activateObject(K key, PooledObject<VisitTracker<K>> ref) throws Exception { + public void activateObject(final K key, final PooledObject<VisitTracker<K>> ref) throws Exception { ref.getObject().activate(); } @Override - public void passivateObject(PooledObject<VisitTracker<K>> ref) throws Exception { + public void passivateObject(final PooledObject<VisitTracker<K>> ref) throws Exception { ref.getObject().passivate(); } @Override - public void passivateObject(K key, PooledObject<VisitTracker<K>> ref) throws Exception { + public void passivateObject(final K key, final PooledObject<VisitTracker<K>> ref) throws Exception { ref.getObject().passivate(); } public void resetId() { http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/Waiter.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/Waiter.java b/src/test/java/org/apache/commons/pool2/Waiter.java index fe8e689..ce4fc5b 100644 --- a/src/test/java/org/apache/commons/pool2/Waiter.java +++ b/src/test/java/org/apache/commons/pool2/Waiter.java @@ -37,7 +37,7 @@ public class Waiter { private long validationCount = 0; private final int id = instanceCount.getAndIncrement(); - public Waiter(boolean active, boolean valid, long latency) { + public Waiter(final boolean active, final boolean valid, final long latency) { this.active = active; this.valid = valid; this.latency = latency; @@ -80,7 +80,7 @@ public class Waiter { * * @param active new active state */ - public void setActive(boolean active) { + public void setActive(final boolean active) { final boolean activeState = this.active; if (activeState == active) { return; @@ -99,7 +99,7 @@ public class Waiter { return latency; } - public void setLatency(long latency) { + public void setLatency(final long latency) { this.latency = latency; } @@ -108,7 +108,7 @@ public class Waiter { return valid; } - public void setValid(boolean valid) { + public void setValid(final boolean valid) { this.valid = valid; } @@ -157,7 +157,7 @@ public class Waiter { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (!(obj instanceof Waiter)) { return false; } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/WaiterFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/WaiterFactory.java b/src/test/java/org/apache/commons/pool2/WaiterFactory.java index 7727e25..3ac1709 100644 --- a/src/test/java/org/apache/commons/pool2/WaiterFactory.java +++ b/src/test/java/org/apache/commons/pool2/WaiterFactory.java @@ -67,10 +67,10 @@ KeyedPooledObjectFactory<K,Waiter> { /** Maximum of (makes - destroys) per key */ private final long maxActivePerKey; // GKOP 1.x calls this maxActive - public WaiterFactory(long activateLatency, long destroyLatency, - long makeLatency, long passivateLatency, long validateLatency, - long waiterLatency,long maxActive, long maxActivePerKey, - double passivateInvalidationProbability) { + public WaiterFactory(final long activateLatency, final long destroyLatency, + final long makeLatency, final long passivateLatency, final long validateLatency, + final long waiterLatency,final long maxActive, final long maxActivePerKey, + final double passivateInvalidationProbability) { this.activateLatency = activateLatency; this.destroyLatency = destroyLatency; this.makeLatency = makeLatency; @@ -82,28 +82,28 @@ KeyedPooledObjectFactory<K,Waiter> { this.passivateInvalidationProbability = passivateInvalidationProbability; } - public WaiterFactory(long activateLatency, long destroyLatency, - long makeLatency, long passivateLatency, long validateLatency, - long waiterLatency) { + public WaiterFactory(final long activateLatency, final long destroyLatency, + final long makeLatency, final long passivateLatency, final long validateLatency, + final long waiterLatency) { this(activateLatency, destroyLatency, makeLatency, passivateLatency, validateLatency, waiterLatency, Long.MAX_VALUE, Long.MAX_VALUE, 0); } - public WaiterFactory(long activateLatency, long destroyLatency, - long makeLatency, long passivateLatency, long validateLatency, - long waiterLatency,long maxActive) { + public WaiterFactory(final long activateLatency, final long destroyLatency, + final long makeLatency, final long passivateLatency, final long validateLatency, + final long waiterLatency,final long maxActive) { this(activateLatency, destroyLatency, makeLatency, passivateLatency, validateLatency, waiterLatency, maxActive, Long.MAX_VALUE, 0); } @Override - public void activateObject(PooledObject<Waiter> obj) throws Exception { + public void activateObject(final PooledObject<Waiter> obj) throws Exception { doWait(activateLatency); obj.getObject().setActive(true); } @Override - public void destroyObject(PooledObject<Waiter> obj) throws Exception { + public void destroyObject(final PooledObject<Waiter> obj) throws Exception { doWait(destroyLatency); obj.getObject().setValid(false); obj.getObject().setActive(false); @@ -128,7 +128,7 @@ KeyedPooledObjectFactory<K,Waiter> { } @Override - public void passivateObject(PooledObject<Waiter> obj) throws Exception { + public void passivateObject(final PooledObject<Waiter> obj) throws Exception { obj.getObject().setActive(false); doWait(passivateLatency); if (Math.random() < passivateInvalidationProbability) { @@ -137,12 +137,12 @@ KeyedPooledObjectFactory<K,Waiter> { } @Override - public boolean validateObject(PooledObject<Waiter> obj) { + public boolean validateObject(final PooledObject<Waiter> obj) { doWait(validateLatency); return obj.getObject().isValid(); } - protected void doWait(long latency) { + protected void doWait(final long latency) { if (latency == 0) { return; } @@ -175,12 +175,12 @@ KeyedPooledObjectFactory<K,Waiter> { // KeyedPoolableObjectFactory methods @Override - public void activateObject(K key, PooledObject<Waiter> obj) throws Exception { + public void activateObject(final K key, final PooledObject<Waiter> obj) throws Exception { activateObject(obj); } @Override - public void destroyObject(K key,PooledObject<Waiter> obj) throws Exception { + public void destroyObject(final K key,final PooledObject<Waiter> obj) throws Exception { destroyObject(obj); synchronized (this) { final Integer count = activeCounts.get(key); @@ -189,7 +189,7 @@ KeyedPooledObjectFactory<K,Waiter> { } @Override - public PooledObject<Waiter> makeObject(K key) throws Exception { + public PooledObject<Waiter> makeObject(final K key) throws Exception { synchronized (this) { Integer count = activeCounts.get(key); if (count == null) { @@ -209,12 +209,12 @@ KeyedPooledObjectFactory<K,Waiter> { } @Override - public void passivateObject(K key, PooledObject<Waiter> obj) throws Exception { + public void passivateObject(final K key, final PooledObject<Waiter> obj) throws Exception { passivateObject(obj); } @Override - public boolean validateObject(K key, PooledObject<Waiter> obj) { + public boolean validateObject(final K key, final PooledObject<Waiter> obj) { return validateObject(obj); } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java index 3c0ef81..b1b591b 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java @@ -288,7 +288,7 @@ public class TestAbandonedObjectPool { class ConcurrentBorrower extends Thread { private final ArrayList<PooledTestObject> _borrowed; - public ConcurrentBorrower(ArrayList<PooledTestObject> borrowed) { + public ConcurrentBorrower(final ArrayList<PooledTestObject> borrowed) { _borrowed = borrowed; } @@ -304,7 +304,7 @@ public class TestAbandonedObjectPool { class ConcurrentReturner extends Thread { private final PooledTestObject returned; - public ConcurrentReturner(PooledTestObject obj) { + public ConcurrentReturner(final PooledTestObject obj) { returned = obj; } @Override @@ -328,7 +328,7 @@ public class TestAbandonedObjectPool { validateLatency = 0; } - public SimpleFactory(long destroyLatency, long validateLatency) { + public SimpleFactory(final long destroyLatency, final long validateLatency) { this.destroyLatency = destroyLatency; this.validateLatency = validateLatency; } @@ -339,7 +339,7 @@ public class TestAbandonedObjectPool { } @Override - public boolean validateObject(PooledObject<PooledTestObject> obj) { + public boolean validateObject(final PooledObject<PooledTestObject> obj) { try { Thread.sleep(validateLatency); } catch (final Exception ex) { @@ -349,17 +349,17 @@ public class TestAbandonedObjectPool { } @Override - public void activateObject(PooledObject<PooledTestObject> obj) { + public void activateObject(final PooledObject<PooledTestObject> obj) { obj.getObject().setActive(true); } @Override - public void passivateObject(PooledObject<PooledTestObject> obj) { + public void passivateObject(final PooledObject<PooledTestObject> obj) { obj.getObject().setActive(false); } @Override - public void destroyObject(PooledObject<PooledTestObject> obj) throws Exception { + public void destroyObject(final PooledObject<PooledTestObject> obj) throws Exception { obj.getObject().setActive(false); // while destroying instances, yield control to other threads // helps simulate threading errors @@ -383,7 +383,7 @@ class PooledTestObject implements TrackedUse { _hash = hash.incrementAndGet(); } - public synchronized void setActive(boolean b) { + public synchronized void setActive(final boolean b) { active = b; } @@ -404,7 +404,7 @@ class PooledTestObject implements TrackedUse { return _hash; } - public void setAbandoned(boolean b) { + public void setAbandoned(final boolean b) { _abandoned = b; } @@ -420,7 +420,7 @@ class PooledTestObject implements TrackedUse { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (!(obj instanceof PooledTestObject)) { return false; } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java index 9305783..4777e55 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java @@ -68,7 +68,7 @@ import org.junit.Test; public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { @Override - protected KeyedObjectPool<Object,Object> makeEmptyPool(int mincapacity) { + protected KeyedObjectPool<Object,Object> makeEmptyPool(final int mincapacity) { final KeyedPooledObjectFactory<Object,Object> perKeyFactory = new SimplePerKeyFactory(); final GenericKeyedObjectPool<Object,Object> perKeyPool = @@ -79,17 +79,17 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { } @Override - protected KeyedObjectPool<Object,Object> makeEmptyPool(KeyedPooledObjectFactory<Object,Object> fac) { + protected KeyedObjectPool<Object,Object> makeEmptyPool(final KeyedPooledObjectFactory<Object,Object> fac) { return new GenericKeyedObjectPool<Object,Object>(fac); } @Override - protected Object getNthObject(Object key, int n) { + protected Object getNthObject(final Object key, final int n) { return String.valueOf(key) + String.valueOf(n); } @Override - protected Object makeKey(int n) { + protected Object makeKey(final int n) { return String.valueOf(n); } @@ -543,7 +543,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { * @param delay Maximum delay between iterations * @param gkopPool The keyed object pool to use */ - public <T> void runTestThreads(int numThreads, int iterations, int delay, GenericKeyedObjectPool<String,T> gkopPool) { + public <T> void runTestThreads(final int numThreads, final int iterations, final int delay, final GenericKeyedObjectPool<String,T> gkopPool) { final ArrayList<TestThread<T>> threads = new ArrayList<TestThread<T>>(); for(int i=0;i<numThreads;i++) { final TestThread<T> testThread = new TestThread<T>(gkopPool, iterations, delay); @@ -760,7 +760,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { checkEvictionOrder(true); } - private void checkEvictionOrder(boolean lifo) throws Exception { + private void checkEvictionOrder(final boolean lifo) throws Exception { final SimpleFactory<Integer> intFactory = new SimpleFactory<Integer>(); final GenericKeyedObjectPool<Integer,String> intPool = new GenericKeyedObjectPool<Integer,String>(intFactory); @@ -886,7 +886,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { checkEvictorVisiting(false); } - private void checkEvictorVisiting(boolean lifo) throws Exception { + private void checkEvictorVisiting(final boolean lifo) throws Exception { VisitTrackerFactory<Integer> trackerFactory = new VisitTrackerFactory<Integer>(); GenericKeyedObjectPool<Integer,VisitTracker<Integer>> intPool = new GenericKeyedObjectPool<Integer,VisitTracker<Integer>>(trackerFactory); @@ -1628,7 +1628,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private final KeyedObjectPool<String, String> pool; private final String key; private boolean done = false; - public InvalidateThread(KeyedObjectPool<String, String> pool, String key, String obj) { + public InvalidateThread(final KeyedObjectPool<String, String> pool, final String key, final String obj) { this.obj = obj; this.pool = pool; this.key = key; @@ -1658,7 +1658,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private final KeyedObjectPool<String,T> _pool; private final String _key; - public SimpleTestThread(KeyedObjectPool<String,T> pool, String key) { + public SimpleTestThread(final KeyedObjectPool<String,T> pool, final String key) { _pool = pool; _key = key; } @@ -1690,7 +1690,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private long ended; private String objectId; - public WaitingTestThread(KeyedObjectPool<String,String> pool, String key, long pause) { + public WaitingTestThread(final KeyedObjectPool<String,String> pool, final String key, final long pause) { _pool = pool; _key = key; _pause = pause; @@ -1737,20 +1737,20 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private volatile boolean _failed = false; private volatile Exception _exception; - public TestThread(KeyedObjectPool<String,T> pool) { + public TestThread(final KeyedObjectPool<String,T> pool) { this(pool, 100, 50, 50, true, null, null); } - public TestThread(KeyedObjectPool<String,T> pool, int iter) { + public TestThread(final KeyedObjectPool<String,T> pool, final int iter) { this(pool, iter, 50, 50, true, null, null); } - public TestThread(KeyedObjectPool<String,T> pool, int iter, int delay) { + public TestThread(final KeyedObjectPool<String,T> pool, final int iter, final int delay) { this(pool, iter, delay, delay, true, null, null); } - public TestThread(KeyedObjectPool<String,T> pool, int iter, int startDelay, - int holdTime, boolean randomDelay, T expectedObject, String key) { + public TestThread(final KeyedObjectPool<String,T> pool, final int iter, final int startDelay, + final int holdTime, final boolean randomDelay, final T expectedObject, final String key) { _pool = pool; _iter = iter; _startDelay = startDelay; @@ -1817,11 +1817,11 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { public SimpleFactory() { this(true); } - public SimpleFactory(boolean valid) { + public SimpleFactory(final boolean valid) { this.valid = valid; } @Override - public PooledObject<String> makeObject(K key) throws Exception { + public PooledObject<String> makeObject(final K key) throws Exception { if (exceptionOnCreate) { throw new Exception(); } @@ -1838,7 +1838,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { return new DefaultPooledObject<String>(out); } @Override - public void destroyObject(K key, PooledObject<String> obj) throws Exception { + public void destroyObject(final K key, final PooledObject<String> obj) throws Exception { doWait(destroyLatency); synchronized(this) { activeCount--; @@ -1848,7 +1848,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { } } @Override - public boolean validateObject(K key, PooledObject<String> obj) { + public boolean validateObject(final K key, final PooledObject<String> obj) { doWait(validateLatency); if (enableValidation) { return validateCounter++%2 == 0 ? evenValid : oddValid; @@ -1856,7 +1856,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { return valid; } @Override - public void activateObject(K key, PooledObject<String> obj) throws Exception { + public void activateObject(final K key, final PooledObject<String> obj) throws Exception { if (exceptionOnActivate) { if (!(validateCounter++%2 == 0 ? evenValid : oddValid)) { throw new Exception(); @@ -1864,44 +1864,44 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { } } @Override - public void passivateObject(K key, PooledObject<String> obj) throws Exception { + public void passivateObject(final K key, final PooledObject<String> obj) throws Exception { if (exceptionOnPassivate) { throw new Exception(); } } - public void setMaxTotalPerKey(int maxTotalPerKey) { + public void setMaxTotalPerKey(final int maxTotalPerKey) { this.maxTotalPerKey = maxTotalPerKey; } - public void setDestroyLatency(long destroyLatency) { + public void setDestroyLatency(final long destroyLatency) { this.destroyLatency = destroyLatency; } - public void setMakeLatency(long makeLatency) { + public void setMakeLatency(final long makeLatency) { this.makeLatency = makeLatency; } - public void setValidateLatency(long validateLatency) { + public void setValidateLatency(final long validateLatency) { this.validateLatency = validateLatency; } - public void setValidationEnabled(boolean b) { + public void setValidationEnabled(final boolean b) { enableValidation = b; } - void setEvenValid(boolean valid) { + void setEvenValid(final boolean valid) { evenValid = valid; } - void setValid(boolean valid) { + void setValid(final boolean valid) { evenValid = valid; oddValid = valid; } - public void setThrowExceptionOnActivate(boolean b) { + public void setThrowExceptionOnActivate(final boolean b) { exceptionOnActivate = b; } - public void setThrowExceptionOnDestroy(boolean b) { + public void setThrowExceptionOnDestroy(final boolean b) { exceptionOnDestroy = b; } - public void setThrowExceptionOnPassivate(boolean b) { + public void setThrowExceptionOnPassivate(final boolean b) { exceptionOnPassivate = b; } @@ -1922,7 +1922,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { boolean exceptionOnDestroy = false; boolean exceptionOnCreate = false; - private void doWait(long latency) { + private void doWait(final long latency) { try { Thread.sleep(latency); } catch (final InterruptedException ex) { @@ -1941,14 +1941,14 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { return false; } - private String getExceptionTrace(Throwable t){ + private String getExceptionTrace(final Throwable t){ final StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); return sw.toString(); } - private String formatSettings(String title, String s, int i, String s0, boolean b0, String s1, int i1, String s2, int i2, String s3, int i3, - String s4, int i4, String s5, int i5, String s6, int i6, int zeroLength, int oneLength, int twoLength){ + private String formatSettings(final String title, final String s, final int i, final String s0, final boolean b0, final String s1, final int i1, final String s2, final int i2, final String s3, final int i3, + final String s4, final int i4, final String s5, final int i5, final String s6, final int i6, final int zeroLength, final int oneLength, final int twoLength){ final StringBuilder sb = new StringBuilder(80); sb.append(title).append(' '); sb.append(s).append('=').append(i).append(' '); @@ -2047,7 +2047,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private static class DaemonThreadFactory implements ThreadFactory { @Override - public Thread newThread(Runnable r) { + public Thread newThread(final Runnable r) { final Thread t = new Thread(r); t.setDaemon(true); return t; @@ -2249,11 +2249,11 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private static class DummyFactory extends BaseKeyedPooledObjectFactory<Object,Object> { @Override - public Object create(Object key) throws Exception { + public Object create(final Object key) throws Exception { return null; } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } @@ -2266,11 +2266,11 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private static final class HashSetFactory extends BaseKeyedPooledObjectFactory<String, HashSet<String>> { @Override - public HashSet<String> create(String key) throws Exception { + public HashSet<String> create(final String key) throws Exception { return new HashSet<String>(); } @Override - public PooledObject<HashSet<String>> wrap(HashSet<String> value) { + public PooledObject<HashSet<String>> wrap(final HashSet<String> value) { return new DefaultPooledObject<HashSet<String>>(value); } } @@ -2280,7 +2280,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { ConcurrentHashMap<Object,AtomicInteger> map = new ConcurrentHashMap<Object,AtomicInteger>(); @Override - public Object create(Object key) throws Exception { + public Object create(final Object key) throws Exception { int counter = 0; final AtomicInteger Counter = map.get(key); if(null != Counter) { @@ -2292,7 +2292,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { return String.valueOf(key) + String.valueOf(counter); } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } @@ -2301,13 +2301,13 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { extends BaseKeyedPooledObjectFactory<Integer, Object> { @Override - public Object create(Integer key) + public Object create(final Integer key) throws Exception { return new Object(); } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java index 0ede9b0..92fee38 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java @@ -60,7 +60,7 @@ import org.junit.Test; public class TestGenericObjectPool extends TestBaseObjectPool { @Override - protected ObjectPool<String> makeEmptyPool(int mincap) { + protected ObjectPool<String> makeEmptyPool(final int mincap) { final GenericObjectPool<String> mtPool = new GenericObjectPool<String>(new SimpleFactory()); mtPool.setMaxTotal(mincap); @@ -75,7 +75,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - protected Object getNthObject(int n) { + protected Object getNthObject(final int n) { return String.valueOf(n); } @@ -313,7 +313,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { checkEvict(false); } - private void checkEvict(boolean lifo) throws Exception { + private void checkEvict(final boolean lifo) throws Exception { // yea this is hairy but it tests all the code paths in GOP.evict() pool.setSoftMinEvictableIdleTimeMillis(10); pool.setMinIdle(2); @@ -353,14 +353,14 @@ public class TestGenericObjectPool extends TestBaseObjectPool { checkEvictionOrder(true); } - private void checkEvictionOrder(boolean lifo) throws Exception { + private void checkEvictionOrder(final boolean lifo) throws Exception { checkEvictionOrderPart1(lifo); tearDown(); setUp(); checkEvictionOrderPart2(lifo); } - private void checkEvictionOrderPart1(boolean lifo) throws Exception { + private void checkEvictionOrderPart1(final boolean lifo) throws Exception { pool.setNumTestsPerEvictionRun(2); pool.setMinEvictableIdleTimeMillis(100); pool.setLifo(lifo); @@ -377,7 +377,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { assertEquals("Wrong instance returned", lifo ? "4" : "2" , obj); } - private void checkEvictionOrderPart2(boolean lifo) throws Exception { + private void checkEvictionOrderPart2(final boolean lifo) throws Exception { // Two eviction runs in sequence pool.setNumTestsPerEvictionRun(2); pool.setMinEvictableIdleTimeMillis(100); @@ -404,7 +404,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { checkEvictorVisiting(false); } - private void checkEvictorVisiting(boolean lifo) throws Exception { + private void checkEvictorVisiting(final boolean lifo) throws Exception { VisitTrackerFactory<Object> trackerFactory = new VisitTrackerFactory<Object>(); GenericObjectPool<VisitTracker<Object>> trackerPool = new GenericObjectPool<VisitTracker<Object>>(trackerFactory); @@ -1036,8 +1036,8 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final AtomicInteger callCount = new AtomicInteger(0); @Override - public boolean evict(EvictionConfig config, PooledObject<T> underTest, - int idleCount) { + public boolean evict(final EvictionConfig config, final PooledObject<T> underTest, + final int idleCount) { if (callCount.incrementAndGet() > 1500) { return true; } @@ -1113,7 +1113,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return new TimeTest(); } @Override - public PooledObject<TimeTest> wrap(TimeTest value) { + public PooledObject<TimeTest> wrap(final TimeTest value) { return new DefaultPooledObject<TimeTest>(value); } public long getCreateTime() { @@ -1253,7 +1253,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final String obj; private final ObjectPool<String> pool; private boolean done = false; - public InvalidateThread(ObjectPool<String> pool, String obj) { + public InvalidateThread(final ObjectPool<String> pool, final String obj) { this.obj = obj; this.pool = pool; } @@ -1363,7 +1363,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { @SuppressWarnings({ "rawtypes", "unchecked" }) - private void runTestThreads(int numThreads, int iterations, int delay, GenericObjectPool testPool) { + private void runTestThreads(final int numThreads, final int iterations, final int delay, final GenericObjectPool testPool) { final TestThread[] threads = new TestThread[numThreads]; for(int i=0;i<numThreads;i++) { threads[i] = new TestThread<String>(testPool,iterations,delay); @@ -1495,7 +1495,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final boolean borrow; public String obj; - public ConcurrentBorrowAndEvictThread(boolean borrow) { + public ConcurrentBorrowAndEvictThread(final boolean borrow) { this.borrow = borrow; } @@ -1538,30 +1538,30 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private volatile boolean _failed = false; private volatile Throwable _error; - public TestThread(ObjectPool<T> pool) { + public TestThread(final ObjectPool<T> pool) { this(pool, 100, 50, true, null); } - public TestThread(ObjectPool<T> pool, int iter) { + public TestThread(final ObjectPool<T> pool, final int iter) { this(pool, iter, 50, true, null); } - public TestThread(ObjectPool<T> pool, int iter, int delay) { + public TestThread(final ObjectPool<T> pool, final int iter, final int delay) { this(pool, iter, delay, true, null); } - public TestThread(ObjectPool<T> pool, int iter, int delay, - boolean randomDelay) { + public TestThread(final ObjectPool<T> pool, final int iter, final int delay, + final boolean randomDelay) { this(pool, iter, delay, randomDelay, null); } - public TestThread(ObjectPool<T> pool, int iter, int delay, - boolean randomDelay, Object obj) { + public TestThread(final ObjectPool<T> pool, final int iter, final int delay, + final boolean randomDelay, final Object obj) { this(pool, iter, delay, delay, randomDelay, obj); } - public TestThread(ObjectPool<T> pool, int iter, int startDelay, - int holdTime, boolean randomDelay, Object obj) { + public TestThread(final ObjectPool<T> pool, final int iter, final int startDelay, + final int holdTime, final boolean randomDelay, final Object obj) { _pool = pool; _iter = iter; _startDelay = startDelay; @@ -1678,7 +1678,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private SimpleFactory factory = null; - private void assertConfiguration(GenericObjectPoolConfig expected, GenericObjectPool<?> actual) throws Exception { + private void assertConfiguration(final GenericObjectPoolConfig expected, final GenericObjectPool<?> actual) throws Exception { assertEquals("testOnCreate",Boolean.valueOf(expected.getTestOnCreate()), Boolean.valueOf(actual.getTestOnCreate())); assertEquals("testOnBorrow",Boolean.valueOf(expected.getTestOnBorrow()), @@ -1702,36 +1702,36 @@ public class TestGenericObjectPool extends TestBaseObjectPool { public SimpleFactory() { this(true); } - public SimpleFactory(boolean valid) { + public SimpleFactory(final boolean valid) { this(valid,valid); } - public SimpleFactory(boolean evalid, boolean ovalid) { + public SimpleFactory(final boolean evalid, final boolean ovalid) { evenValid = evalid; oddValid = ovalid; } - public synchronized void setValid(boolean valid) { + public synchronized void setValid(final boolean valid) { setEvenValid(valid); setOddValid(valid); } - public synchronized void setEvenValid(boolean valid) { + public synchronized void setEvenValid(final boolean valid) { evenValid = valid; } - public synchronized void setOddValid(boolean valid) { + public synchronized void setOddValid(final boolean valid) { oddValid = valid; } - public synchronized void setThrowExceptionOnPassivate(boolean bool) { + public synchronized void setThrowExceptionOnPassivate(final boolean bool) { exceptionOnPassivate = bool; } - public synchronized void setMaxTotal(int maxTotal) { + public synchronized void setMaxTotal(final int maxTotal) { this.maxTotal = maxTotal; } - public synchronized void setDestroyLatency(long destroyLatency) { + public synchronized void setDestroyLatency(final long destroyLatency) { this.destroyLatency = destroyLatency; } - public synchronized void setMakeLatency(long makeLatency) { + public synchronized void setMakeLatency(final long makeLatency) { this.makeLatency = makeLatency; } - public synchronized void setValidateLatency(long validateLatency) { + public synchronized void setValidateLatency(final long validateLatency) { this.validateLatency = validateLatency; } @Override @@ -1755,7 +1755,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return new DefaultPooledObject<String>(String.valueOf(counter)); } @Override - public void destroyObject(PooledObject<String> obj) throws Exception { + public void destroyObject(final PooledObject<String> obj) throws Exception { final long waitLatency; final boolean hurl; synchronized(this) { @@ -1773,7 +1773,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } } @Override - public boolean validateObject(PooledObject<String> obj) { + public boolean validateObject(final PooledObject<String> obj) { final boolean validate; final boolean evenTest; final boolean oddTest; @@ -1795,7 +1795,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return true; } @Override - public void activateObject(PooledObject<String> obj) throws Exception { + public void activateObject(final PooledObject<String> obj) throws Exception { final boolean hurl; final boolean evenTest; final boolean oddTest; @@ -1813,7 +1813,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } } @Override - public void passivateObject(PooledObject<String> obj) throws Exception { + public void passivateObject(final PooledObject<String> obj) throws Exception { final boolean hurl; synchronized(this) { hurl = exceptionOnPassivate; @@ -1841,11 +1841,11 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return exceptionOnActivate; } - public synchronized void setThrowExceptionOnActivate(boolean b) { + public synchronized void setThrowExceptionOnActivate(final boolean b) { exceptionOnActivate = b; } - public synchronized void setThrowExceptionOnDestroy(boolean b) { + public synchronized void setThrowExceptionOnDestroy(final boolean b) { exceptionOnDestroy = b; } @@ -1853,7 +1853,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return enableValidation; } - public synchronized void setValidationEnabled(boolean b) { + public synchronized void setValidationEnabled(final boolean b) { enableValidation = b; } @@ -1861,7 +1861,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return makeCounter; } - private void doWait(long latency) { + private void doWait(final long latency) { try { Thread.sleep(latency); } catch (final InterruptedException ex) { @@ -1888,12 +1888,12 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public PooledObject<AtomicInteger> wrap(AtomicInteger integer) { + public PooledObject<AtomicInteger> wrap(final AtomicInteger integer) { return new DefaultPooledObject<AtomicInteger>(integer); } @Override - public void activateObject(PooledObject<AtomicInteger> p) { + public void activateObject(final PooledObject<AtomicInteger> p) { p.getObject().incrementAndGet(); try { Thread.sleep(activateLatency); @@ -1901,7 +1901,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public void passivateObject(PooledObject<AtomicInteger> p) { + public void passivateObject(final PooledObject<AtomicInteger> p) { p.getObject().decrementAndGet(); try { Thread.sleep(passivateLatency); @@ -1909,7 +1909,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public boolean validateObject(PooledObject<AtomicInteger> instance) { + public boolean validateObject(final PooledObject<AtomicInteger> instance) { try { Thread.sleep(validateLatency); } catch (final InterruptedException ex) {} @@ -1917,7 +1917,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public void destroyObject(PooledObject<AtomicInteger> p) { + public void destroyObject(final PooledObject<AtomicInteger> p) { try { Thread.sleep(destroyLatency); } catch (final InterruptedException ex) {} @@ -1927,7 +1927,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { /** * @param activateLatency the activateLatency to set */ - public void setActivateLatency(long activateLatency) { + public void setActivateLatency(final long activateLatency) { this.activateLatency = activateLatency; } @@ -1935,7 +1935,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { /** * @param passivateLatency the passivateLatency to set */ - public void setPassivateLatency(long passivateLatency) { + public void setPassivateLatency(final long passivateLatency) { this.passivateLatency = passivateLatency; } @@ -1943,7 +1943,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { /** * @param createLatency the createLatency to set */ - public void setCreateLatency(long createLatency) { + public void setCreateLatency(final long createLatency) { this.createLatency = createLatency; } @@ -1951,7 +1951,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { /** * @param destroyLatency the destroyLatency to set */ - public void setDestroyLatency(long destroyLatency) { + public void setDestroyLatency(final long destroyLatency) { this.destroyLatency = destroyLatency; } @@ -1959,7 +1959,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { /** * @param validateLatency the validateLatency to set */ - public void setValidateLatency(long validateLatency) { + public void setValidateLatency(final long validateLatency) { this.validateLatency = validateLatency; } } @@ -2096,7 +2096,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private long ended; private String objectId; - public WaitingTestThread(GenericObjectPool<String> pool, long pause) { + public WaitingTestThread(final GenericObjectPool<String> pool, final long pause) { _pool = pool; _pause = pause; _thrown = null; @@ -2301,7 +2301,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { */ final SwallowedExceptionListener listener = new SwallowedExceptionListener() { @Override - public void onSwallowException(Exception e) { + public void onSwallowException(final Exception e) { if (swallowedExceptions.size() == 2) { throw new OutOfMemoryError(); } @@ -2482,7 +2482,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return null; } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } } @@ -2499,7 +2499,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return new HashSet<String>(); } @Override - public PooledObject<HashSet<String>> wrap(HashSet<String> value) { + public PooledObject<HashSet<String>> wrap(final HashSet<String> value) { return new DefaultPooledObject<HashSet<String>>(value); } } @@ -2512,12 +2512,12 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return new Object(); } @Override - public PooledObject<Object> wrap(Object value) { + public PooledObject<Object> wrap(final Object value) { return new DefaultPooledObject<Object>(value); } @Override - public boolean validateObject(PooledObject<Object> obj) { + public boolean validateObject(final PooledObject<Object> obj) { try { Thread.sleep(1000); } catch (final InterruptedException e) { @@ -2531,7 +2531,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final GenericObjectPool<T> pool; - public EvictionThread(GenericObjectPool<T> pool) { + public EvictionThread(final GenericObjectPool<T> pool) { this.pool = pool; } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java index 7bfded0..28bc43f 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java @@ -88,7 +88,7 @@ public class TestGenericObjectPoolClassLoaders { BasePooledObjectFactory<URL> { private final int n; - CustomClassLoaderObjectFactory(int n) { + CustomClassLoaderObjectFactory(final int n) { this.n = n; } @@ -103,7 +103,7 @@ public class TestGenericObjectPoolClassLoaders { } @Override - public PooledObject<URL> wrap(URL value) { + public PooledObject<URL> wrap(final URL value) { return new DefaultPooledObject<URL>(value); } } @@ -111,13 +111,13 @@ public class TestGenericObjectPoolClassLoaders { private static class CustomClassLoader extends URLClassLoader { private final int n; - CustomClassLoader(int n) { + CustomClassLoader(final int n) { super(new URL[] { BASE_URL }); this.n = n; } @Override - public URL findResource(String name) { + public URL findResource(final String name) { if (!name.endsWith(String.valueOf(n))) { return null; } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java index 921f183..6e0b20c 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestPoolImplUtils.java @@ -42,7 +42,7 @@ public class TestPoolImplUtils { return null; } @Override - public PooledObject<String> wrap(String obj) { + public PooledObject<String> wrap(final String obj) { return null; } } @@ -69,7 +69,7 @@ public class TestPoolImplUtils { return null; } @Override - public PooledObject<Long> wrap(Long obj) { + public PooledObject<Long> wrap(final Long obj) { return null; } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java b/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java index 056060e..41fa415 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java @@ -216,7 +216,7 @@ public class TestSoftRefOutOfMemory { return new String(String.valueOf(counter)); } @Override - public PooledObject<String> wrap(String value) { + public PooledObject<String> wrap(final String value) { return new DefaultPooledObject<String>(value); } } @@ -225,7 +225,7 @@ public class TestSoftRefOutOfMemory { private final String buffer; private int counter = 0; - public LargePoolableObjectFactory(int size) { + public LargePoolableObjectFactory(final int size) { final char[] data = new char[size]; Arrays.fill(data, '.'); buffer = new String(data); @@ -238,7 +238,7 @@ public class TestSoftRefOutOfMemory { } @Override - public PooledObject<String> wrap(String value) { + public PooledObject<String> wrap(final String value) { return new DefaultPooledObject<String>(value); } } @@ -247,7 +247,7 @@ public class TestSoftRefOutOfMemory { private final OomeTrigger trigger; - public OomeFactory(OomeTrigger trigger) { + public OomeFactory(final OomeTrigger trigger) { this.trigger = trigger; } @@ -265,12 +265,12 @@ public class TestSoftRefOutOfMemory { } @Override - public PooledObject<String> wrap(String value) { + public PooledObject<String> wrap(final String value) { return new DefaultPooledObject<String>(value); } @Override - public boolean validateObject(PooledObject<String> p) { + public boolean validateObject(final PooledObject<String> p) { if (trigger.equals(OomeTrigger.VALIDATE)) { throw new OutOfMemoryError(); } @@ -281,7 +281,7 @@ public class TestSoftRefOutOfMemory { } @Override - public void destroyObject(PooledObject<String> p) throws Exception { + public void destroyObject(final PooledObject<String> p) throws Exception { if (trigger.equals(OomeTrigger.DESTROY)) { throw new OutOfMemoryError(); } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java index c9f0b40..aa4390c 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestSoftReferenceObjectPool.java @@ -28,7 +28,7 @@ import org.apache.commons.pool2.TestBaseObjectPool; public class TestSoftReferenceObjectPool extends TestBaseObjectPool { @Override - protected ObjectPool<String> makeEmptyPool(int cap) { + protected ObjectPool<String> makeEmptyPool(final int cap) { return new SoftReferenceObjectPool<String>(new SimpleFactory()); } @@ -38,7 +38,7 @@ public class TestSoftReferenceObjectPool extends TestBaseObjectPool { } @Override - protected Object getNthObject(int n) { + protected Object getNthObject(final int n) { return String.valueOf(n); } @@ -60,7 +60,7 @@ public class TestSoftReferenceObjectPool extends TestBaseObjectPool { return String.valueOf(counter++); } @Override - public PooledObject<String> wrap(String value) { + public PooledObject<String> wrap(final String value) { return new DefaultPooledObject<String>(value); } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java b/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java index 5324f88..50479e9 100644 --- a/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java +++ b/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java @@ -38,7 +38,7 @@ public class PerformanceTest { private GenericObjectPool<Integer> pool; - public void setLogLevel(int i) { + public void setLogLevel(final int i) { logLevel = i; } @@ -109,7 +109,7 @@ public class PerformanceTest { } } - private void run(int iterations, int nrThreads, int maxTotal, int maxIdle) { + private void run(final int iterations, final int nrThreads, final int maxTotal, final int maxIdle) { this.nrIterations = iterations; final SleepingObjectFactory factory = new SleepingObjectFactory(); @@ -183,7 +183,7 @@ public class PerformanceTest { threadPool.shutdown(); } - public static void main(String[] args) { + public static void main(final String[] args) { final PerformanceTest test = new PerformanceTest(); test.setLogLevel(0); System.out.println("Increase threads"); http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/performance/SleepingObjectFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/performance/SleepingObjectFactory.java b/src/test/java/org/apache/commons/pool2/performance/SleepingObjectFactory.java index 5b46712..2205505 100644 --- a/src/test/java/org/apache/commons/pool2/performance/SleepingObjectFactory.java +++ b/src/test/java/org/apache/commons/pool2/performance/SleepingObjectFactory.java @@ -42,38 +42,38 @@ public class SleepingObjectFactory implements PooledObjectFactory<Integer> { } @Override - public void destroyObject(PooledObject<Integer> obj) throws Exception { + public void destroyObject(final PooledObject<Integer> obj) throws Exception { debug("destroyObject", obj); sleep(250); } @Override - public boolean validateObject(PooledObject<Integer> obj) { + public boolean validateObject(final PooledObject<Integer> obj) { debug("validateObject", obj); sleep(30); return true; } @Override - public void activateObject(PooledObject<Integer> obj) throws Exception { + public void activateObject(final PooledObject<Integer> obj) throws Exception { debug("activateObject", obj); sleep(10); } @Override - public void passivateObject(PooledObject<Integer> obj) throws Exception { + public void passivateObject(final PooledObject<Integer> obj) throws Exception { debug("passivateObject", obj); sleep(10); } - private void debug(String method, Object obj) { + private void debug(final String method, final Object obj) { if (debug) { final String thread = "thread" + Thread.currentThread().getName(); System.out.println(thread + ": " + method + " " + obj); } } - private void sleep(long millis) { + private void sleep(final long millis) { try { Thread.sleep(millis); } @@ -85,7 +85,7 @@ public class SleepingObjectFactory implements PooledObjectFactory<Integer> { return debug; } - public void setDebug(boolean b) { + public void setDebug(final boolean b) { debug = b; } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedKeyedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedKeyedObjectPool.java b/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedKeyedObjectPool.java index a58db99..3f7a3cc 100644 --- a/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedKeyedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedKeyedObjectPool.java @@ -129,11 +129,11 @@ public abstract class BaseTestProxiedKeyedObjectPool { BaseKeyedPooledObjectFactory<String,TestObject> { @Override - public TestObject create(String key) throws Exception { + public TestObject create(final String key) throws Exception { return new TestObjectImpl(); } @Override - public PooledObject<TestObject> wrap(TestObject value) { + public PooledObject<TestObject> wrap(final TestObject value) { return new DefaultPooledObject<TestObject>(value); } } @@ -155,7 +155,7 @@ public abstract class BaseTestProxiedKeyedObjectPool { } @Override - public void setData(String data) { + public void setData(final String data) { this.data = data; } } http://git-wip-us.apache.org/repos/asf/commons-pool/blob/844cbd26/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedObjectPool.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedObjectPool.java b/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedObjectPool.java index c3014ca..c684702 100644 --- a/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/proxy/BaseTestProxiedObjectPool.java @@ -168,7 +168,7 @@ public abstract class BaseTestProxiedObjectPool { return new TestObjectImpl(); } @Override - public PooledObject<TestObject> wrap(TestObject value) { + public PooledObject<TestObject> wrap(final TestObject value) { return new DefaultPooledObject<TestObject>(value); } } @@ -190,7 +190,7 @@ public abstract class BaseTestProxiedObjectPool { } @Override - public void setData(String data) { + public void setData(final String data) { this.data = data; } }