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 2022/04/15 14:04:52 UTC
[commons-pool] branch master updated (f08e3fc5 -> 834a25d5)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
from f08e3fc5 Bump actions/setup-java from 2 to 3
new 934182f3 Format tweak.
new 0167e3b3 Sort members.
new 00117103 Add GenericKeyedObjectPool.getKeys().
new 834a25d5 Bump commons-parent from 52 to 53
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
pom.xml | 2 +-
src/changes/changes.xml | 6 +
.../commons/pool2/impl/GenericKeyedObjectPool.java | 19 +-
.../pool2/proxy/ProxiedKeyedObjectPool.java | 1 -
.../pool2/impl/TestGenericKeyedObjectPool.java | 389 +++++++++++----------
5 files changed, 223 insertions(+), 194 deletions(-)
[commons-pool] 01/04: Format tweak.
Posted by gg...@apache.org.
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
commit 934182f3aae01460f6729218c9eef86889003af2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 15 09:23:09 2022 -0400
Format tweak.
---
src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java | 1 -
1 file changed, 1 deletion(-)
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 a2e98e9d..c9877f7b 100644
--- a/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/proxy/ProxiedKeyedObjectPool.java
@@ -113,7 +113,6 @@ public class ProxiedKeyedObjectPool<K, V> implements KeyedObjectPool<K, V> {
pool.returnObject(key, proxySource.resolveProxy(proxy));
}
-
/**
* @since 2.4.3
*/
[commons-pool] 03/04: Add GenericKeyedObjectPool.getKeys().
Posted by gg...@apache.org.
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
commit 0011710334ef3a836315765575d7e22443f9a6b6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 15 09:48:47 2022 -0400
Add GenericKeyedObjectPool.getKeys().
---
src/changes/changes.xml | 3 +++
.../commons/pool2/impl/GenericKeyedObjectPool.java | 19 +++++++++++++++----
.../pool2/impl/TestGenericKeyedObjectPool.java | 17 +++++++++++++++--
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 44229f85..43e97eb2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -61,6 +61,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add PooledObject.getFullDuration().
</action>
+ <action dev="ggregory" type="add" due-to="Vamsi Pavan Kumar Sanka, Phil Steitz, Gary Gregory">
+ Add GenericKeyedObjectPool.getKeys().
+ </action>
<!-- UPDATE -->
<action dev="ggregory" type="update" due-to="Dependabot">
Bump actions/checkout from 2.3.4 to 3 #109, #112, #134.
diff --git a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
index ef21c799..e5d17b50 100644
--- a/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
@@ -221,7 +221,7 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
* to ensure any changes to the list of current keys is made in a
* thread-safe manner.
*/
- private final List<K> poolKeyList = new ArrayList<>(); // @GuardedBy("keyLock")
+ private final ArrayList<K> poolKeyList = new ArrayList<>(); // @GuardedBy("keyLock")
private final ReadWriteLock keyLock = new ReentrantReadWriteLock(true);
@@ -1106,6 +1106,17 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
return factory;
}
+ /**
+ * Gets a copy of the pool key list.
+ *
+ * @return a copy of the pool key list.
+ * @since 2.12.0
+ */
+ @SuppressWarnings("unchecked")
+ public List<K> getKeys() {
+ return (List<K>) poolKeyList.clone();
+ }
+
/**
* Gets the cap on the number of "idle" instances per key in the pool.
* If maxIdlePerKey is set too low on heavily loaded systems it is possible
@@ -1201,15 +1212,15 @@ public class GenericKeyedObjectPool<K, T> extends BaseGenericObjectPool<T>
return poolMap.values().stream().mapToInt(e -> e.getIdleObjects().size()).sum();
}
+
+ //--- JMX support ----------------------------------------------------------
+
@Override
public int getNumIdle(final K key) {
final ObjectDeque<T> objectDeque = poolMap.get(key);
return objectDeque != null ? objectDeque.getIdleObjects().size() : 0;
}
-
- //--- JMX support ----------------------------------------------------------
-
/**
* Calculate the number of objects to test in a run of the idle object
* evictor.
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 4b8f7994..e5e3d471 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
@@ -1649,11 +1649,24 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertEquals( "key4", gkoPool.borrowObject(key),"new-4");
}
+ @Test
+ @Timeout(value = 60, unit = TimeUnit.SECONDS)
+ public void testGetKeys() throws Exception {
+ gkoPool.addObject("one");
+ assertEquals(1, gkoPool.getKeys().size());
+ gkoPool.addObject("two");
+ assertEquals(2, gkoPool.getKeys().size());
+ gkoPool.clear("one");
+ assertEquals(1, gkoPool.getKeys().size());
+ assertEquals("two", (String) gkoPool.getKeys().get(0));
+ gkoPool.clear();
+ }
+
@Test
public void testGetStatsString() {
assertNotNull((gkoPool.getStatsString()));
}
-
+
/**
* Verify that threads waiting on a depleted pool get served when a checked out object is
* invalidated.
@@ -1685,7 +1698,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
}
}
}
-
+
@Test
public void testInvalidateFreesCapacityForOtherKeys() throws Exception {
gkoPool.setMaxTotal(1);
[commons-pool] 02/04: Sort members.
Posted by gg...@apache.org.
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
commit 0167e3b3256f28305265c7d29a6e1a3bd5899732
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 15 09:36:30 2022 -0400
Sort members.
---
.../pool2/impl/TestGenericKeyedObjectPool.java | 374 ++++++++++-----------
1 file changed, 187 insertions(+), 187 deletions(-)
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 976acabf..4b8f7994 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
@@ -1051,6 +1051,127 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
}
}
+ /**
+ * POOL-391 Verify that when clear(key) is called with reuseCapacity true,
+ * capacity freed is reused and allocated to most loaded pools.
+ *
+ * @throws Exception May occur in some failure modes
+ */
+ @Test
+ public void testClearReuseCapacity() throws Exception {
+ gkoPool.setMaxTotalPerKey(6);
+ gkoPool.setMaxTotal(6);
+ gkoPool.setMaxWait(Duration.ofSeconds(5));
+ // Create one thread to wait on "one", two on "two", three on "three"
+ final ArrayList<Thread> testThreads = new ArrayList<>();
+ testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "one")));
+ testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "two")));
+ testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "two")));
+ testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "three")));
+ testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "three")));
+ testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "three")));
+ // Borrow two each from "four", "five", "six" - using all capacity
+ final String four = gkoPool.borrowObject("four");
+ final String four2 = gkoPool.borrowObject("four");
+ final String five = gkoPool.borrowObject("five");
+ final String five2 = gkoPool.borrowObject("five");
+ final String six = gkoPool.borrowObject("six");
+ final String six2 = gkoPool.borrowObject("six");
+ Thread.sleep(100);
+ // Launch the waiters - all will be blocked waiting
+ for (Thread t : testThreads) {
+ t.start();
+ }
+ Thread.sleep(100);
+ // Return and clear the fours - at least one "three" should get served
+ // Other should be a two or a three (three was most loaded)
+ gkoPool.returnObject("four", four);
+ gkoPool.returnObject("four", four2);
+ gkoPool.clear("four");
+ Thread.sleep(20);
+ assertTrue(!testThreads.get(3).isAlive() || !testThreads.get(4).isAlive() || !testThreads.get(5).isAlive());
+ // Now clear the fives
+ gkoPool.returnObject("five", five);
+ gkoPool.returnObject("five", five2);
+ gkoPool.clear("five");
+ Thread.sleep(20);
+ // Clear the sixes
+ gkoPool.returnObject("six", six);
+ gkoPool.returnObject("six", six2);
+ gkoPool.clear("six");
+ Thread.sleep(20);
+ for (Thread t : testThreads) {
+ assertFalse(t.isAlive());
+ }
+ }
+
+ /**
+ * POOL-391 Adapted from code in the JIRA ticket.
+ *
+ * @throws Exception May occur in some failure modes
+ */
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
+ public void testClearUnblocksWaiters() {
+ final GenericKeyedObjectPoolConfig<Integer> config = new GenericKeyedObjectPoolConfig<>();
+ config.setMaxTotalPerKey(1);
+ config.setMinIdlePerKey(0);
+ config.setMaxIdlePerKey(-1);
+ config.setMaxTotal(-1);
+ config.setMaxWait(Duration.ofMillis(5));
+ GenericKeyedObjectPool<Integer, Integer> testPool = new GenericKeyedObjectPool<>(
+ new KeyedPooledObjectFactory<Integer, Integer>() {
+ @Override
+ public void activateObject(Integer key, PooledObject<Integer> p) throws Exception {
+ // do nothing
+ }
+
+ @Override
+ public void destroyObject(Integer key, PooledObject<Integer> p) throws Exception {
+ Thread.sleep(500);
+ }
+
+ @Override
+ public PooledObject<Integer> makeObject(Integer key) throws Exception {
+ return new DefaultPooledObject<>(10);
+ }
+
+ @Override
+ public void passivateObject(Integer key, PooledObject<Integer> p) throws Exception {
+ // do nothing
+ }
+
+ @Override
+ public boolean validateObject(Integer key, PooledObject<Integer> p) {
+ return true;
+ }
+ }, config);
+ final int borrowKey = 10;
+ Thread t = new Thread(() -> {
+ try {
+ while (true) {
+ Integer integer = testPool.borrowObject(borrowKey);
+ testPool.returnObject(borrowKey, integer);
+ Thread.sleep(10);
+ }
+ } catch (Exception e) {
+ fail();
+ }
+ });
+ Thread t2 = new Thread(() -> {
+ try {
+ while (true) {
+ testPool.clear(borrowKey);
+ Thread.sleep(10);
+ }
+ } catch (Exception e) {
+ fail();
+ }
+ });
+ t.start();
+ t2.start();
+ }
+
// POOL-259
@Test
public void testClientWaitStats() throws Exception {
@@ -1424,6 +1545,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
checkEvictorVisiting(false);
}
+
@Test
@Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testExceptionInValidationDuringEviction() throws Exception {
@@ -1468,7 +1590,6 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertEquals(0, gkoPool.getNumIdle());
}
-
@Test
@Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testExceptionOnDestroyDuringBorrow() throws Exception {
@@ -1565,6 +1686,19 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
}
}
+ @Test
+ public void testInvalidateFreesCapacityForOtherKeys() throws Exception {
+ gkoPool.setMaxTotal(1);
+ gkoPool.setMaxWait(Duration.ofMillis(500));
+ Thread borrower = new Thread(new SimpleTestThread<>(gkoPool, "two"));
+ String obj = gkoPool.borrowObject("one");
+ borrower.start(); // Will block
+ Thread.sleep(100); // Make sure borrower has started
+ gkoPool.invalidateObject("one", obj); // Should free capacity to serve the other key
+ Thread.sleep(20); // Should have been served by now
+ assertFalse(borrower.isAlive());
+ }
+
/**
* Verify that threads blocked waiting on a depleted pool get served when a checked out instance
* is invalidated.
@@ -1882,6 +2016,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertThrows(NoSuchElementException.class, () -> gkoPool.borrowObject(""));
}
+
@Test
@Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMaxTotalPerKeyZero() {
@@ -1891,6 +2026,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertThrows(NoSuchElementException.class, () -> gkoPool.borrowObject("a"));
}
+
/**
* Verifies that if a borrow of a new key is blocked because maxTotal has
* been reached, that borrow continues once another object is returned.
@@ -1941,7 +2077,6 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertThrows(NoSuchElementException.class, () -> gkoPool.borrowObject("a"));
}
-
/*
* Test multi-threaded pool access.
* Multiple keys, multiple threads, but maxActive only allows half the threads to succeed.
@@ -2000,7 +2135,6 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertEquals(wtt.length/2,failed,"Expected half the threads to fail");
}
-
@Test
@Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMinIdle() throws Exception {
@@ -2235,6 +2369,36 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
}
}
+
+ @Test
+ public void testReturnObjectWithBlockWhenExhausted() throws Exception {
+ gkoPool.setBlockWhenExhausted(true);
+ gkoPool.setMaxTotal(1);
+
+ // Test return object with no take waiters
+ String obj = gkoPool.borrowObject("0");
+ gkoPool.returnObject("0", obj);
+
+ // Test return object with a take waiter
+ final TestThread<String> testA = new TestThread<>(gkoPool, 1, 0, 500, false, null, "0");
+ final TestThread<String> testB = new TestThread<>(gkoPool, 1, 0, 0, false, null, "1");
+ final Thread threadA = new Thread(testA);
+ final Thread threadB = new Thread(testB);
+ threadA.start();
+ threadB.start();
+ threadA.join();
+ threadB.join();
+ }
+
+ @Test
+ public void testReturnObjectWithoutBlockWhenExhausted() throws Exception {
+ gkoPool.setBlockWhenExhausted(false);
+
+ // Test return object with no take waiters
+ String obj = gkoPool.borrowObject("0");
+ gkoPool.returnObject("0", obj);
+ }
+
/**
* JIRA: POOL-287
*
@@ -2351,7 +2515,6 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
runTestThreads(20, 100, 50, gkoPool);
}
-
// Pool-361
@Test
public void testValidateOnCreate() throws Exception {
@@ -2361,26 +2524,26 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertEquals(1, simpleFactory.validateCounter);
}
- @Test
- public void testValidateOnCreateFailure() throws Exception {
- gkoPool.setTestOnCreate(true);
- gkoPool.setTestOnBorrow(false);
- gkoPool.setMaxTotal(2);
- simpleFactory.setValidationEnabled(true);
- simpleFactory.setValid(false);
- // Make sure failed validations do not leak capacity
- gkoPool.addObject("one");
- gkoPool.addObject("one");
- assertEquals(0, gkoPool.getNumIdle());
- assertEquals(0, gkoPool.getNumActive());
- simpleFactory.setValid(true);
- final String obj = gkoPool.borrowObject("one");
- assertNotNull(obj);
- gkoPool.addObject("one");
- // Should have one idle, one out now
- assertEquals(1, gkoPool.getNumIdle());
- assertEquals(1, gkoPool.getNumActive());
- }
+ @Test
+public void testValidateOnCreateFailure() throws Exception {
+ gkoPool.setTestOnCreate(true);
+ gkoPool.setTestOnBorrow(false);
+ gkoPool.setMaxTotal(2);
+ simpleFactory.setValidationEnabled(true);
+ simpleFactory.setValid(false);
+ // Make sure failed validations do not leak capacity
+ gkoPool.addObject("one");
+ gkoPool.addObject("one");
+ assertEquals(0, gkoPool.getNumIdle());
+ assertEquals(0, gkoPool.getNumActive());
+ simpleFactory.setValid(true);
+ final String obj = gkoPool.borrowObject("one");
+ assertNotNull(obj);
+ gkoPool.addObject("one");
+ // Should have one idle, one out now
+ assertEquals(1, gkoPool.getNumIdle());
+ assertEquals(1, gkoPool.getNumActive());
+}
/**
* Verify that threads waiting on a depleted pool get served when a returning object fails
@@ -2474,169 +2637,6 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertTrue(wtt.thrown instanceof InterruptedException);
}
- /**
- * POOL-391 Adapted from code in the JIRA ticket.
- *
- * @throws Exception May occur in some failure modes
- */
- @Test
- @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
- public void testClearUnblocksWaiters() {
- final GenericKeyedObjectPoolConfig<Integer> config = new GenericKeyedObjectPoolConfig<>();
- config.setMaxTotalPerKey(1);
- config.setMinIdlePerKey(0);
- config.setMaxIdlePerKey(-1);
- config.setMaxTotal(-1);
- config.setMaxWait(Duration.ofMillis(5));
- GenericKeyedObjectPool<Integer, Integer> testPool = new GenericKeyedObjectPool<>(
- new KeyedPooledObjectFactory<Integer, Integer>() {
- @Override
- public PooledObject<Integer> makeObject(Integer key) throws Exception {
- return new DefaultPooledObject<>(10);
- }
-
- @Override
- public void destroyObject(Integer key, PooledObject<Integer> p) throws Exception {
- Thread.sleep(500);
- }
-
- @Override
- public boolean validateObject(Integer key, PooledObject<Integer> p) {
- return true;
- }
-
- @Override
- public void activateObject(Integer key, PooledObject<Integer> p) throws Exception {
- // do nothing
- }
-
- @Override
- public void passivateObject(Integer key, PooledObject<Integer> p) throws Exception {
- // do nothing
- }
- }, config);
- final int borrowKey = 10;
- Thread t = new Thread(() -> {
- try {
- while (true) {
- Integer integer = testPool.borrowObject(borrowKey);
- testPool.returnObject(borrowKey, integer);
- Thread.sleep(10);
- }
- } catch (Exception e) {
- fail();
- }
- });
- Thread t2 = new Thread(() -> {
- try {
- while (true) {
- testPool.clear(borrowKey);
- Thread.sleep(10);
- }
- } catch (Exception e) {
- fail();
- }
- });
- t.start();
- t2.start();
- }
-
- /**
- * POOL-391 Verify that when clear(key) is called with reuseCapacity true,
- * capacity freed is reused and allocated to most loaded pools.
- *
- * @throws Exception May occur in some failure modes
- */
- @Test
- public void testClearReuseCapacity() throws Exception {
- gkoPool.setMaxTotalPerKey(6);
- gkoPool.setMaxTotal(6);
- gkoPool.setMaxWait(Duration.ofSeconds(5));
- // Create one thread to wait on "one", two on "two", three on "three"
- final ArrayList<Thread> testThreads = new ArrayList<>();
- testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "one")));
- testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "two")));
- testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "two")));
- testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "three")));
- testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "three")));
- testThreads.add(new Thread(new SimpleTestThread<>(gkoPool, "three")));
- // Borrow two each from "four", "five", "six" - using all capacity
- final String four = gkoPool.borrowObject("four");
- final String four2 = gkoPool.borrowObject("four");
- final String five = gkoPool.borrowObject("five");
- final String five2 = gkoPool.borrowObject("five");
- final String six = gkoPool.borrowObject("six");
- final String six2 = gkoPool.borrowObject("six");
- Thread.sleep(100);
- // Launch the waiters - all will be blocked waiting
- for (Thread t : testThreads) {
- t.start();
- }
- Thread.sleep(100);
- // Return and clear the fours - at least one "three" should get served
- // Other should be a two or a three (three was most loaded)
- gkoPool.returnObject("four", four);
- gkoPool.returnObject("four", four2);
- gkoPool.clear("four");
- Thread.sleep(20);
- assertTrue(!testThreads.get(3).isAlive() || !testThreads.get(4).isAlive() || !testThreads.get(5).isAlive());
- // Now clear the fives
- gkoPool.returnObject("five", five);
- gkoPool.returnObject("five", five2);
- gkoPool.clear("five");
- Thread.sleep(20);
- // Clear the sixes
- gkoPool.returnObject("six", six);
- gkoPool.returnObject("six", six2);
- gkoPool.clear("six");
- Thread.sleep(20);
- for (Thread t : testThreads) {
- assertFalse(t.isAlive());
- }
- }
-
- @Test
- public void testInvalidateFreesCapacityForOtherKeys() throws Exception {
- gkoPool.setMaxTotal(1);
- gkoPool.setMaxWait(Duration.ofMillis(500));
- Thread borrower = new Thread(new SimpleTestThread<>(gkoPool, "two"));
- String obj = gkoPool.borrowObject("one");
- borrower.start(); // Will block
- Thread.sleep(100); // Make sure borrower has started
- gkoPool.invalidateObject("one", obj); // Should free capacity to serve the other key
- Thread.sleep(20); // Should have been served by now
- assertFalse(borrower.isAlive());
- }
-
- @Test
- public void testReturnObjectWithBlockWhenExhausted() throws Exception {
- gkoPool.setBlockWhenExhausted(true);
- gkoPool.setMaxTotal(1);
-
- // Test return object with no take waiters
- String obj = gkoPool.borrowObject("0");
- gkoPool.returnObject("0", obj);
-
- // Test return object with a take waiter
- final TestThread<String> testA = new TestThread<>(gkoPool, 1, 0, 500, false, null, "0");
- final TestThread<String> testB = new TestThread<>(gkoPool, 1, 0, 0, false, null, "1");
- final Thread threadA = new Thread(testA);
- final Thread threadB = new Thread(testB);
- threadA.start();
- threadB.start();
- threadA.join();
- threadB.join();
- }
-
- @Test
- public void testReturnObjectWithoutBlockWhenExhausted() throws Exception {
- gkoPool.setBlockWhenExhausted(false);
-
- // Test return object with no take waiters
- String obj = gkoPool.borrowObject("0");
- gkoPool.returnObject("0", obj);
- }
-
}
[commons-pool] 04/04: Bump commons-parent from 52 to 53
Posted by gg...@apache.org.
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
commit 834a25d500ef4fff517d06bcbc03495ea60a1067
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 15 10:04:46 2022 -0400
Bump commons-parent from 52 to 53
---
pom.xml | 2 +-
src/changes/changes.xml | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 50e305b6..73134c32 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>52</version>
+ <version>53</version>
</parent>
<artifactId>commons-pool2</artifactId>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 43e97eb2..d40ccf13 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -101,6 +101,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="kinow" type="update" due-to="Dependabot">
Bump asm-util from 9.2 to 9.3 #141.
</action>
+ <action dev="ggregory" type="update" due-to="Gary Gregory">
+ Bump commons-parent from 52 to 53.
+ </action>
</release>
<release version="2.11.1" date="2021-08-18" description="This is a maintenance release (Java 8).">
<!-- FIX -->