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 2023/01/01 16:11:04 UTC
[commons-pool] branch master updated: Use diamonds
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 0f1ef340 Use diamonds
0f1ef340 is described below
commit 0f1ef34024c77d4b3224c6c5f4fe2c67fd0d3ae7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 1 11:11:00 2023 -0500
Use diamonds
- Use final
- Use long line
- Comment out console output
- Close pools
- No need to throw Exception
- Separate methods with an empty line
---
.../pool2/impl/TestBaseGenericObjectPool.java | 23 +++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
index 3a50840f..afd78418 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestBaseGenericObjectPool.java
@@ -116,23 +116,28 @@ public class TestBaseGenericObjectPool {
assertEquals(0, evictingPool.getNumIdle());
}
}
+
/**
* POOL-393
- * Ensure JMX registration does not add too much latency to pool creation.
+ * Tests JMX registration does not add too much latency to pool creation.
*/
+ @SuppressWarnings("resource") // pools closed in finally block
@Test
@Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
- public void testJMXRegistrationLatency() throws Exception {
+ public void testJMXRegistrationLatency() {
final int numPools = 1000;
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final ArrayList<GenericObjectPool<Waiter, IllegalStateException>> pools = new ArrayList<>();
- long startTime = System.currentTimeMillis();
- for (int i = 0; i < numPools; i++) {
- pools.add(new GenericObjectPool<Waiter, IllegalStateException>(
- new WaiterFactory<String>(0,0,0,0,0,0), new GenericObjectPoolConfig<Waiter>()));
+ try {
+ // final long startTime = System.currentTimeMillis();
+ for (int i = 0; i < numPools; i++) {
+ pools.add(new GenericObjectPool<>(new WaiterFactory<String>(0, 0, 0, 0, 0, 0), new GenericObjectPoolConfig<Waiter>()));
+ }
+ // System.out.println("Duration: " + (System.currentTimeMillis() - startTime));
+ final ObjectName oname = pools.get(numPools - 1).getJmxName();
+ assertEquals(1, mbs.queryNames(oname, null).size());
+ } finally {
+ pools.forEach(GenericObjectPool::close);
}
- System.out.println("Duration: " + (System.currentTimeMillis() - startTime));
- final ObjectName oname = pools.get(numPools - 1).getJmxName();
- assertEquals(1, mbs.queryNames(oname, null).size());
}
}