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/07/07 22:05:01 UTC

[commons-pool] branch master updated: Refactor magic string in test

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 9ceccf24 Refactor magic string in test
9ceccf24 is described below

commit 9ceccf243a1c132e74547f9aaf0100b71e11cb5d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 7 18:04:57 2023 -0400

    Refactor magic string in test
---
 .../apache/commons/pool2/impl/TestGenericKeyedObjectPool.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 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 79418893..4da07c18 100644
--- a/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
+++ b/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
@@ -1049,7 +1049,8 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
         config.setBlockWhenExhausted(false); // pool exhausted indicates a bug in the test
 
         gkoPool = new GenericKeyedObjectPool<>(simpleFactory, config);
-        gkoPool.addObjects(Arrays.asList("0"), threadCount);
+        final String key = "0";
+        gkoPool.addObjects(Arrays.asList(key), threadCount);
         // all objects in the pool are now idle.
 
         final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
@@ -1061,9 +1062,9 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
                         if (useYield) {
                             Thread.yield();
                         }
-                        gkoPool.clear("0", true);
+                        gkoPool.clear(key, true);
                         try {
-                            gkoPool.addObjects(Arrays.asList("0"), addCount);
+                            gkoPool.addObjects(Arrays.asList(key), addCount);
                         } catch (IllegalArgumentException | TestException e) {
                             fail(e);
                         }
@@ -1075,8 +1076,8 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
                             if (useYield) {
                                 Thread.yield();
                             }
-                            final String pooled = gkoPool.borrowObject("0");
-                            gkoPool.returnObject("0", pooled);
+                            final String pooled = gkoPool.borrowObject(key);
+                            gkoPool.returnObject(key, pooled);
                         }
                     } catch (TestException e) {
                         fail(e);