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 76668a8 Use lambdas. 76668a8 is described below commit 76668a8373fd91be30aca7258bee6735799e16ae Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Mon Jun 28 20:35:52 2021 -0400 Use lambdas. --- .../commons/pool2/impl/InterruptibleReentrantLock.java | 6 +----- .../commons/pool2/impl/SecurityManagerCallStack.java | 16 ++++++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/pool2/impl/InterruptibleReentrantLock.java b/src/main/java/org/apache/commons/pool2/impl/InterruptibleReentrantLock.java index c75c547..fae6230 100644 --- a/src/main/java/org/apache/commons/pool2/impl/InterruptibleReentrantLock.java +++ b/src/main/java/org/apache/commons/pool2/impl/InterruptibleReentrantLock.java @@ -16,7 +16,6 @@ */ package org.apache.commons.pool2.impl; -import java.util.Collection; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; @@ -50,9 +49,6 @@ class InterruptibleReentrantLock extends ReentrantLock { * @param condition the condition on which the threads are waiting. */ public void interruptWaiters(final Condition condition) { - final Collection<Thread> threads = getWaitingThreads(condition); - for (final Thread thread : threads) { - thread.interrupt(); - } + getWaitingThreads(condition).forEach(Thread::interrupt); } } diff --git a/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java b/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java index 5c586a2..0e65634 100644 --- a/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java +++ b/src/main/java/org/apache/commons/pool2/impl/SecurityManagerCallStack.java @@ -22,8 +22,10 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * A {@link CallStack} strategy using a {@link SecurityManager}. Obtaining the current call stack is much faster via a @@ -47,12 +49,8 @@ public class SecurityManagerCallStack implements CallStack { * @return class stack */ private List<WeakReference<Class<?>>> getCallStack() { - final Class<?>[] classes = getClassContext(); - final List<WeakReference<Class<?>>> stack = new ArrayList<>(classes.length); - for (final Class<?> klass : classes) { - stack.add(new WeakReference<>(klass)); - } - return stack; + final Stream<WeakReference<Class<?>>> map = Arrays.stream(getClassContext()).map(WeakReference::new); + return map.collect(Collectors.toList()); } } @@ -119,9 +117,7 @@ public class SecurityManagerCallStack implements CallStack { } } writer.println(message); - for (final WeakReference<Class<?>> reference : snapshotRef.stack) { - writer.println(reference.get()); - } + snapshotRef.stack.forEach(reference -> writer.println(reference.get())); return true; } }