Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 14D3E200C35 for ; Sun, 12 Mar 2017 20:47:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 13890160B87; Sun, 12 Mar 2017 19:47:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ECF73160B8F for ; Sun, 12 Mar 2017 20:47:37 +0100 (CET) Received: (qmail 64296 invoked by uid 500); 12 Mar 2017 19:47:32 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 62062 invoked by uid 99); 12 Mar 2017 19:47:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Mar 2017 19:47:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 759F0F4B61; Sun, 12 Mar 2017 19:47:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mattsicker@apache.org To: commits@commons.apache.org Date: Sun, 12 Mar 2017 19:47:47 -0000 Message-Id: <31191324aba54db1bf73d9906201e54f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [17/50] [abbrv] commons-pool git commit: Add final modifier to method parameters. archived-at: Sun, 12 Mar 2017 19:47:40 -0000 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 implements KeyedObjectPool { * @param pool The object pool to wrap * @param proxySource The source of the proxy objects */ - public ProxiedKeyedObjectPool(KeyedObjectPool pool, - ProxySource proxySource) { + public ProxiedKeyedObjectPool(final KeyedObjectPool pool, + final ProxySource proxySource) { this.pool = pool; this.proxySource = proxySource; } @@ -53,7 +53,7 @@ public class ProxiedKeyedObjectPool implements KeyedObjectPool { @SuppressWarnings("unchecked") @Override - public V borrowObject(K key) throws Exception, NoSuchElementException, + public V borrowObject(final K key) throws Exception, NoSuchElementException, IllegalStateException { UsageTracking usageTracking = null; if (pool instanceof UsageTracking) { @@ -65,30 +65,30 @@ public class ProxiedKeyedObjectPool implements KeyedObjectPool { } @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 implements KeyedObjectPool { } @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 implements ObjectPool { * @param pool The object pool to wrap * @param proxySource The source of the proxy objects */ - public ProxiedObjectPool(ObjectPool pool, ProxySource proxySource) { + public ProxiedObjectPool(final ObjectPool pool, final ProxySource proxySource) { this.pool = pool; this.proxySource = proxySource; } @@ -66,14 +66,14 @@ public class ProxiedObjectPool implements ObjectPool { @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 { @Override - public Object create(Object key) throws Exception { + public Object create(final Object key) throws Exception { return null; } @Override - public PooledObject wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(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 makeEmptyPool(int mincapacity) { + protected ObjectPool 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 wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(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 wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(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 calls) { + static void removeDestroyObjectCall(final List calls) { final Iterator 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 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 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 invokeEveryMethod(ObjectPool op) throws Exception { + private static List invokeEveryMethod(final ObjectPool op) throws Exception { op.addObject(); op.borrowObject(); op.clear(); @@ -820,7 +820,7 @@ public class TestPoolUtils { return expectedMethods; } - private static List invokeEveryMethod(KeyedObjectPool kop) throws Exception { + private static List invokeEveryMethod(final KeyedObjectPool kop) throws Exception { kop.addObject(null); kop.borrowObject(null); kop.clear(); @@ -842,7 +842,7 @@ public class TestPoolUtils { return expectedMethods; } - private static List invokeEveryMethod(PooledObjectFactory pof) throws Exception { + private static List invokeEveryMethod(final PooledObjectFactory pof) throws Exception { pof.activateObject(null); pof.destroyObject(null); pof.makeObject(); @@ -857,7 +857,7 @@ public class TestPoolUtils { return expectedMethods; } - private static List invokeEveryMethod(KeyedPooledObjectFactory kpof) throws Exception { + private static List invokeEveryMethod(final KeyedPooledObjectFactory 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 { 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 { 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 implements PooledObjectFactory>(new VisitTracker(nextId++)); } @Override - public PooledObject> makeObject(K key) { + public PooledObject> makeObject(final K key) { return new DefaultPooledObject>(new VisitTracker(nextId++, key)); } @Override - public void destroyObject(PooledObject> ref) { + public void destroyObject(final PooledObject> ref) { ref.getObject().destroy(); } @Override - public void destroyObject(K key, PooledObject> ref) { + public void destroyObject(final K key, final PooledObject> ref) { ref.getObject().destroy(); } @Override - public boolean validateObject(PooledObject> ref) { + public boolean validateObject(final PooledObject> ref) { return ref.getObject().validate(); } @Override - public boolean validateObject(K key, PooledObject> ref) { + public boolean validateObject(final K key, final PooledObject> ref) { return ref.getObject().validate(); } @Override - public void activateObject(PooledObject> ref) throws Exception { + public void activateObject(final PooledObject> ref) throws Exception { ref.getObject().activate(); } @Override - public void activateObject(K key, PooledObject> ref) throws Exception { + public void activateObject(final K key, final PooledObject> ref) throws Exception { ref.getObject().activate(); } @Override - public void passivateObject(PooledObject> ref) throws Exception { + public void passivateObject(final PooledObject> ref) throws Exception { ref.getObject().passivate(); } @Override - public void passivateObject(K key, PooledObject> ref) throws Exception { + public void passivateObject(final K key, final PooledObject> 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 { /** 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 { 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 obj) throws Exception { + public void activateObject(final PooledObject obj) throws Exception { doWait(activateLatency); obj.getObject().setActive(true); } @Override - public void destroyObject(PooledObject obj) throws Exception { + public void destroyObject(final PooledObject obj) throws Exception { doWait(destroyLatency); obj.getObject().setValid(false); obj.getObject().setActive(false); @@ -128,7 +128,7 @@ KeyedPooledObjectFactory { } @Override - public void passivateObject(PooledObject obj) throws Exception { + public void passivateObject(final PooledObject obj) throws Exception { obj.getObject().setActive(false); doWait(passivateLatency); if (Math.random() < passivateInvalidationProbability) { @@ -137,12 +137,12 @@ KeyedPooledObjectFactory { } @Override - public boolean validateObject(PooledObject obj) { + public boolean validateObject(final PooledObject 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 { // KeyedPoolableObjectFactory methods @Override - public void activateObject(K key, PooledObject obj) throws Exception { + public void activateObject(final K key, final PooledObject obj) throws Exception { activateObject(obj); } @Override - public void destroyObject(K key,PooledObject obj) throws Exception { + public void destroyObject(final K key,final PooledObject obj) throws Exception { destroyObject(obj); synchronized (this) { final Integer count = activeCounts.get(key); @@ -189,7 +189,7 @@ KeyedPooledObjectFactory { } @Override - public PooledObject makeObject(K key) throws Exception { + public PooledObject makeObject(final K key) throws Exception { synchronized (this) { Integer count = activeCounts.get(key); if (count == null) { @@ -209,12 +209,12 @@ KeyedPooledObjectFactory { } @Override - public void passivateObject(K key, PooledObject obj) throws Exception { + public void passivateObject(final K key, final PooledObject obj) throws Exception { passivateObject(obj); } @Override - public boolean validateObject(K key, PooledObject obj) { + public boolean validateObject(final K key, final PooledObject 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 _borrowed; - public ConcurrentBorrower(ArrayList borrowed) { + public ConcurrentBorrower(final ArrayList 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 obj) { + public boolean validateObject(final PooledObject obj) { try { Thread.sleep(validateLatency); } catch (final Exception ex) { @@ -349,17 +349,17 @@ public class TestAbandonedObjectPool { } @Override - public void activateObject(PooledObject obj) { + public void activateObject(final PooledObject obj) { obj.getObject().setActive(true); } @Override - public void passivateObject(PooledObject obj) { + public void passivateObject(final PooledObject obj) { obj.getObject().setActive(false); } @Override - public void destroyObject(PooledObject obj) throws Exception { + public void destroyObject(final PooledObject 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 makeEmptyPool(int mincapacity) { + protected KeyedObjectPool makeEmptyPool(final int mincapacity) { final KeyedPooledObjectFactory perKeyFactory = new SimplePerKeyFactory(); final GenericKeyedObjectPool perKeyPool = @@ -79,17 +79,17 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { } @Override - protected KeyedObjectPool makeEmptyPool(KeyedPooledObjectFactory fac) { + protected KeyedObjectPool makeEmptyPool(final KeyedPooledObjectFactory fac) { return new GenericKeyedObjectPool(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 void runTestThreads(int numThreads, int iterations, int delay, GenericKeyedObjectPool gkopPool) { + public void runTestThreads(final int numThreads, final int iterations, final int delay, final GenericKeyedObjectPool gkopPool) { final ArrayList> threads = new ArrayList>(); for(int i=0;i testThread = new TestThread(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 intFactory = new SimpleFactory(); final GenericKeyedObjectPool intPool = new GenericKeyedObjectPool(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 trackerFactory = new VisitTrackerFactory(); GenericKeyedObjectPool> intPool = new GenericKeyedObjectPool>(trackerFactory); @@ -1628,7 +1628,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private final KeyedObjectPool pool; private final String key; private boolean done = false; - public InvalidateThread(KeyedObjectPool pool, String key, String obj) { + public InvalidateThread(final KeyedObjectPool 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 _pool; private final String _key; - public SimpleTestThread(KeyedObjectPool pool, String key) { + public SimpleTestThread(final KeyedObjectPool 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 pool, String key, long pause) { + public WaitingTestThread(final KeyedObjectPool 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 pool) { + public TestThread(final KeyedObjectPool pool) { this(pool, 100, 50, 50, true, null, null); } - public TestThread(KeyedObjectPool pool, int iter) { + public TestThread(final KeyedObjectPool pool, final int iter) { this(pool, iter, 50, 50, true, null, null); } - public TestThread(KeyedObjectPool pool, int iter, int delay) { + public TestThread(final KeyedObjectPool pool, final int iter, final int delay) { this(pool, iter, delay, delay, true, null, null); } - public TestThread(KeyedObjectPool pool, int iter, int startDelay, - int holdTime, boolean randomDelay, T expectedObject, String key) { + public TestThread(final KeyedObjectPool 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 makeObject(K key) throws Exception { + public PooledObject makeObject(final K key) throws Exception { if (exceptionOnCreate) { throw new Exception(); } @@ -1838,7 +1838,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { return new DefaultPooledObject(out); } @Override - public void destroyObject(K key, PooledObject obj) throws Exception { + public void destroyObject(final K key, final PooledObject obj) throws Exception { doWait(destroyLatency); synchronized(this) { activeCount--; @@ -1848,7 +1848,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { } } @Override - public boolean validateObject(K key, PooledObject obj) { + public boolean validateObject(final K key, final PooledObject 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 obj) throws Exception { + public void activateObject(final K key, final PooledObject 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 obj) throws Exception { + public void passivateObject(final K key, final PooledObject 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 { @Override - public Object create(Object key) throws Exception { + public Object create(final Object key) throws Exception { return null; } @Override - public PooledObject wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(value); } } @@ -2266,11 +2266,11 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { private static final class HashSetFactory extends BaseKeyedPooledObjectFactory> { @Override - public HashSet create(String key) throws Exception { + public HashSet create(final String key) throws Exception { return new HashSet(); } @Override - public PooledObject> wrap(HashSet value) { + public PooledObject> wrap(final HashSet value) { return new DefaultPooledObject>(value); } } @@ -2280,7 +2280,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { ConcurrentHashMap map = new ConcurrentHashMap(); @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 wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(value); } } @@ -2301,13 +2301,13 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool { extends BaseKeyedPooledObjectFactory { @Override - public Object create(Integer key) + public Object create(final Integer key) throws Exception { return new Object(); } @Override - public PooledObject wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(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 makeEmptyPool(int mincap) { + protected ObjectPool makeEmptyPool(final int mincap) { final GenericObjectPool mtPool = new GenericObjectPool(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 trackerFactory = new VisitTrackerFactory(); GenericObjectPool> trackerPool = new GenericObjectPool>(trackerFactory); @@ -1036,8 +1036,8 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final AtomicInteger callCount = new AtomicInteger(0); @Override - public boolean evict(EvictionConfig config, PooledObject underTest, - int idleCount) { + public boolean evict(final EvictionConfig config, final PooledObject 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 wrap(TimeTest value) { + public PooledObject wrap(final TimeTest value) { return new DefaultPooledObject(value); } public long getCreateTime() { @@ -1253,7 +1253,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final String obj; private final ObjectPool pool; private boolean done = false; - public InvalidateThread(ObjectPool pool, String obj) { + public InvalidateThread(final ObjectPool 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(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 pool) { + public TestThread(final ObjectPool pool) { this(pool, 100, 50, true, null); } - public TestThread(ObjectPool pool, int iter) { + public TestThread(final ObjectPool pool, final int iter) { this(pool, iter, 50, true, null); } - public TestThread(ObjectPool pool, int iter, int delay) { + public TestThread(final ObjectPool pool, final int iter, final int delay) { this(pool, iter, delay, true, null); } - public TestThread(ObjectPool pool, int iter, int delay, - boolean randomDelay) { + public TestThread(final ObjectPool pool, final int iter, final int delay, + final boolean randomDelay) { this(pool, iter, delay, randomDelay, null); } - public TestThread(ObjectPool pool, int iter, int delay, - boolean randomDelay, Object obj) { + public TestThread(final ObjectPool pool, final int iter, final int delay, + final boolean randomDelay, final Object obj) { this(pool, iter, delay, delay, randomDelay, obj); } - public TestThread(ObjectPool pool, int iter, int startDelay, - int holdTime, boolean randomDelay, Object obj) { + public TestThread(final ObjectPool 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.valueOf(counter)); } @Override - public void destroyObject(PooledObject obj) throws Exception { + public void destroyObject(final PooledObject 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 obj) { + public boolean validateObject(final PooledObject 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 obj) throws Exception { + public void activateObject(final PooledObject 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 obj) throws Exception { + public void passivateObject(final PooledObject 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 wrap(AtomicInteger integer) { + public PooledObject wrap(final AtomicInteger integer) { return new DefaultPooledObject(integer); } @Override - public void activateObject(PooledObject p) { + public void activateObject(final PooledObject p) { p.getObject().incrementAndGet(); try { Thread.sleep(activateLatency); @@ -1901,7 +1901,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public void passivateObject(PooledObject p) { + public void passivateObject(final PooledObject p) { p.getObject().decrementAndGet(); try { Thread.sleep(passivateLatency); @@ -1909,7 +1909,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public boolean validateObject(PooledObject instance) { + public boolean validateObject(final PooledObject instance) { try { Thread.sleep(validateLatency); } catch (final InterruptedException ex) {} @@ -1917,7 +1917,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { } @Override - public void destroyObject(PooledObject p) { + public void destroyObject(final PooledObject 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 pool, long pause) { + public WaitingTestThread(final GenericObjectPool 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 wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(value); } } @@ -2499,7 +2499,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return new HashSet(); } @Override - public PooledObject> wrap(HashSet value) { + public PooledObject> wrap(final HashSet value) { return new DefaultPooledObject>(value); } } @@ -2512,12 +2512,12 @@ public class TestGenericObjectPool extends TestBaseObjectPool { return new Object(); } @Override - public PooledObject wrap(Object value) { + public PooledObject wrap(final Object value) { return new DefaultPooledObject(value); } @Override - public boolean validateObject(PooledObject obj) { + public boolean validateObject(final PooledObject obj) { try { Thread.sleep(1000); } catch (final InterruptedException e) { @@ -2531,7 +2531,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool { private final GenericObjectPool pool; - public EvictionThread(GenericObjectPool pool) { + public EvictionThread(final GenericObjectPool 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 { private final int n; - CustomClassLoaderObjectFactory(int n) { + CustomClassLoaderObjectFactory(final int n) { this.n = n; } @@ -103,7 +103,7 @@ public class TestGenericObjectPoolClassLoaders { } @Override - public PooledObject wrap(URL value) { + public PooledObject wrap(final URL value) { return new DefaultPooledObject(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 wrap(String obj) { + public PooledObject wrap(final String obj) { return null; } } @@ -69,7 +69,7 @@ public class TestPoolImplUtils { return null; } @Override - public PooledObject wrap(Long obj) { + public PooledObject 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 wrap(String value) { + public PooledObject wrap(final String value) { return new DefaultPooledObject(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 wrap(String value) { + public PooledObject wrap(final String value) { return new DefaultPooledObject(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 wrap(String value) { + public PooledObject wrap(final String value) { return new DefaultPooledObject(value); } @Override - public boolean validateObject(PooledObject p) { + public boolean validateObject(final PooledObject p) { if (trigger.equals(OomeTrigger.VALIDATE)) { throw new OutOfMemoryError(); } @@ -281,7 +281,7 @@ public class TestSoftRefOutOfMemory { } @Override - public void destroyObject(PooledObject p) throws Exception { + public void destroyObject(final PooledObject 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 makeEmptyPool(int cap) { + protected ObjectPool makeEmptyPool(final int cap) { return new SoftReferenceObjectPool(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 wrap(String value) { + public PooledObject wrap(final String value) { return new DefaultPooledObject(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 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 { } @Override - public void destroyObject(PooledObject obj) throws Exception { + public void destroyObject(final PooledObject obj) throws Exception { debug("destroyObject", obj); sleep(250); } @Override - public boolean validateObject(PooledObject obj) { + public boolean validateObject(final PooledObject obj) { debug("validateObject", obj); sleep(30); return true; } @Override - public void activateObject(PooledObject obj) throws Exception { + public void activateObject(final PooledObject obj) throws Exception { debug("activateObject", obj); sleep(10); } @Override - public void passivateObject(PooledObject obj) throws Exception { + public void passivateObject(final PooledObject 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 { 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 { @Override - public TestObject create(String key) throws Exception { + public TestObject create(final String key) throws Exception { return new TestObjectImpl(); } @Override - public PooledObject wrap(TestObject value) { + public PooledObject wrap(final TestObject value) { return new DefaultPooledObject(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 wrap(TestObject value) { + public PooledObject wrap(final TestObject value) { return new DefaultPooledObject(value); } } @@ -190,7 +190,7 @@ public abstract class BaseTestProxiedObjectPool { } @Override - public void setData(String data) { + public void setData(final String data) { this.data = data; } }