You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/02/08 15:14:40 UTC
[commons-pool] branch master updated: Use final.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
The following commit(s) were added to refs/heads/master by this push:
new 77c0d29 Use final.
77c0d29 is described below
commit 77c0d290fbab322921f1f276848755f2a48518d0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Feb 8 10:14:35 2019 -0500
Use final.
---
.../commons/pool2/impl/GenericObjectPool.java | 2 +-
.../commons/pool2/impl/TestGenericObjectPool.java | 4 ++--
.../TestGenericObjectPoolFactoryCreateFailure.java | 28 +++++++++++-----------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
index 0575f7e..7aff5f4 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
@@ -920,7 +920,7 @@ public class GenericObjectPool<T> extends BaseGenericObjectPool<T>
// In case there are already threads waiting on something in the pool
// (e.g. idleObjects.takeFirst(); then we need to provide them a fresh instance.
// Otherwise they will be stuck forever (or until timeout)
- PooledObject<T> freshPooled = create();
+ final PooledObject<T> freshPooled = create();
idleObjects.put(freshPooled);
}
}
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 dc0ab98..6b97fb8 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
@@ -1169,7 +1169,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
@Test(timeout = 60000)
public void testCloseMultiplePools1() throws Exception {
- GenericObjectPool<String> genericObjectPool2 = new GenericObjectPool<>(simpleFactory);
+ final GenericObjectPool<String> genericObjectPool2 = new GenericObjectPool<>(simpleFactory);
genericObjectPool.setTimeBetweenEvictionRunsMillis(1);
genericObjectPool2.setTimeBetweenEvictionRunsMillis(1);
genericObjectPool2.close();
@@ -1178,7 +1178,7 @@ public class TestGenericObjectPool extends TestBaseObjectPool {
@Test(timeout = 60000)
public void testCloseMultiplePools2() throws Exception {
- GenericObjectPool<String> genericObjectPool2 = new GenericObjectPool<>(simpleFactory);
+ final GenericObjectPool<String> genericObjectPool2 = new GenericObjectPool<>(simpleFactory);
// Ensure eviction takes a long time, during which time EvictionTimer.executor's queue is empty
simpleFactory.setDestroyLatency(1000L);
// Ensure there is an object to evict, so that above latency takes effect
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java
index 20e62a1..4a8b1bc 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolFactoryCreateFailure.java
@@ -42,12 +42,12 @@ public class TestGenericObjectPoolFactoryCreateFailure {
}
@Override
- public boolean validateObject(PooledObject<Object> p) {
+ public boolean validateObject(final PooledObject<Object> p) {
return true;
}
@Override
- public PooledObject<Object> wrap(Object obj) {
+ public PooledObject<Object> wrap(final Object obj) {
return new DefaultPooledObject<>(new Object());
}
}
@@ -56,7 +56,7 @@ public class TestGenericObjectPoolFactoryCreateFailure {
private final CountDownLatch barrier;
private final AtomicBoolean failed;
private final GenericObjectPool<Object> pool;
- private WinnerRunnable(GenericObjectPool<Object> pool, CountDownLatch barrier, AtomicBoolean failed) {
+ private WinnerRunnable(final GenericObjectPool<Object> pool, final CountDownLatch barrier, final AtomicBoolean failed) {
this.pool = pool;
this.failed = failed;
this.barrier = barrier;
@@ -65,7 +65,7 @@ public class TestGenericObjectPoolFactoryCreateFailure {
public void run() {
try {
System.out.println("start borrowing in parallel thread");
- Object obj = pool.borrowObject();
+ final Object obj = pool.borrowObject();
// wait for another thread to start borrowObject
if (!barrier.await(5, TimeUnit.SECONDS)) {
@@ -78,7 +78,7 @@ public class TestGenericObjectPoolFactoryCreateFailure {
pool.returnObject(obj);
println("ended borrowing in parallel thread");
- } catch (Exception e) {
+ } catch (final Exception e) {
failed.set(true);
e.printStackTrace();
}
@@ -89,18 +89,18 @@ public class TestGenericObjectPoolFactoryCreateFailure {
System.out.println(msg);
}
- private static void sleepIgnoreException(long millis) {
+ private static void sleepIgnoreException(final long millis) {
try {
Thread.sleep(millis);
- } catch(Throwable e) {
+ } catch(final Throwable e) {
// ignore
}
}
@Test(timeout = 10_000)
public void testBorrowObjectStuck() {
- SingleObjectFactory factory = new SingleObjectFactory();
- GenericObjectPoolConfig<Object> config = new GenericObjectPoolConfig<>();
+ final SingleObjectFactory factory = new SingleObjectFactory();
+ final GenericObjectPoolConfig<Object> config = new GenericObjectPoolConfig<>();
config.setMaxIdle(1);
config.setMaxTotal(1);
config.setBlockWhenExhausted(true);
@@ -115,9 +115,9 @@ public class TestGenericObjectPoolFactoryCreateFailure {
config.setMaxWaitMillis(-1);
try (GenericObjectPool<Object> pool = new GenericObjectPool<>(factory, config)) {
- AtomicBoolean failed = new AtomicBoolean();
- CountDownLatch barrier = new CountDownLatch(1);
- Thread thread1 = new Thread(new WinnerRunnable(pool, barrier, failed));
+ final AtomicBoolean failed = new AtomicBoolean();
+ final CountDownLatch barrier = new CountDownLatch(1);
+ final Thread thread1 = new Thread(new WinnerRunnable(pool, barrier, failed));
thread1.start();
// wait for object to be created
@@ -130,9 +130,9 @@ public class TestGenericObjectPoolFactoryCreateFailure {
try {
println("try borrow in main thread");
- Object o = pool.borrowObject();
+ final Object o = pool.borrowObject();
println("Success borrow in main thread " + o);
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}