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-dbcp.git


The following commit(s) were added to refs/heads/master by this push:
     new 70ad0fb5 Build and fill list in one go
70ad0fb5 is described below

commit 70ad0fb54401ae2c5416d7c822519ef6595a24cf
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Sep 13 18:16:24 2023 -0400

    Build and fill list in one go
    
    Javadoc
---
 src/test/java/org/apache/commons/dbcp2/StackMessageLog.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java 
b/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
index b8c1f104..f2b214d0 100644
--- a/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
+++ b/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
@@ -48,14 +48,15 @@ public class StackMessageLog extends SimpleLog {
     }
 
     /**
-     * Note: iterator is fail-fast, lock the stack first.
+     * Gets a copy of the message stack.
+     * <p>
+     * Note: lock the stack first.
+     * </p>
+     *
+     * @return a new list.
      */
     public static List<String> getAll() {
-        final List<String> messages = new ArrayList<>();
-        for (String element : MESSAGE_STACK) {
-            messages.add(element);
-        }
-        return messages;
+        return new ArrayList<>(MESSAGE_STACK);
     }
 
     public static boolean isEmpty() {

Reply via email to