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 2024/12/09 13:24:14 UTC
(commons-lang) branch master updated (01b2da35a -> 39dd58102)
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-lang.git
from 01b2da35a Javadoc
new 6b2517c41 Use forEach()
new 39dd58102 Don't build a String when it's not needed
The 2 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:
src/main/java/org/apache/commons/lang3/Validate.java | 13 ++++++-------
.../apache/commons/lang3/concurrent/ConcurrentUtils.java | 2 +-
2 files changed, 7 insertions(+), 8 deletions(-)
(commons-lang) 01/02: Use forEach()
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-lang.git
commit 6b2517c416ad32764e756b1113aeeccc93b764ec
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 9 08:23:51 2024 -0500
Use forEach()
---
src/main/java/org/apache/commons/lang3/Validate.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/Validate.java b/src/main/java/org/apache/commons/lang3/Validate.java
index cf5aba48a..298285aeb 100644
--- a/src/main/java/org/apache/commons/lang3/Validate.java
+++ b/src/main/java/org/apache/commons/lang3/Validate.java
@@ -17,9 +17,9 @@
package org.apache.commons.lang3;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import java.util.regex.Pattern;
@@ -667,13 +667,12 @@ public class Validate {
*/
public static <T extends Iterable<?>> T noNullElements(final T iterable, final String message, final Object... values) {
Objects.requireNonNull(iterable, "iterable");
- int i = 0;
- for (final Iterator<?> it = iterable.iterator(); it.hasNext(); i++) {
- if (it.next() == null) {
- final Object[] values2 = ArrayUtils.addAll(values, Integer.valueOf(i));
- throw new IllegalArgumentException(getMessage(message, values2));
+ AtomicInteger ai = new AtomicInteger();
+ iterable.forEach(e -> {
+ if (e == null) {
+ throw new IllegalArgumentException(getMessage(message, ArrayUtils.addAll(values, ai.getAndIncrement())));
}
- }
+ });
return iterable;
}
(commons-lang) 02/02: Don't build a String when it's not needed
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-lang.git
commit 39dd58102e2cf2fdde6af5f2aa6ad040d08807e2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 9 08:24:09 2024 -0500
Don't build a String when it's not needed
---
src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java b/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
index 6351726b6..080cd1df0 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
@@ -106,7 +106,7 @@ public class ConcurrentUtils {
* checked exception
*/
static Throwable checkedException(final Throwable ex) {
- Validate.isTrue(ExceptionUtils.isChecked(ex), "Not a checked exception: " + ex);
+ Validate.isTrue(ExceptionUtils.isChecked(ex), "Not a checked exception: %s", ex);
return ex;
}