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 2025/01/30 22:12:09 UTC
(commons-lang) branch master updated (5e1f169ce -> 1cadf8950)
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 5e1f169ce Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang.git
new 1521bf3e9 Instead of throwing a NullPointerException, ArrayUtils.toStringArray(Object[]) should return "null" for null elements like ArrayUtils.toStringArray(Object[], String) returns its valueForNullElements.
new d8b310a65 Instead of throwing a NullPointerException, ArrayUtils.toStringArray(Object[]) should return "null" for null elements like ArrayUtils.toStringArray(Object[], String) returns its valueForNullElements.
new 80a56e69e Migrate from APIs deprecated in Java 9
new 932791a24 No need to configure Javadoc to point to Commons Text for deprecated reference
new 1cadf8950 Bump org.apache.commons:commons-parent from 80 to 81
The 5 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 | 6 +--
src/changes/changes.xml | 3 +-
.../java/org/apache/commons/lang3/ArrayUtils.java | 45 ++++++++++++----------
.../org/apache/commons/lang3/ArrayUtilsTest.java | 5 +--
.../concurrent/AtomicInitializerNonObjectTest.java | 5 +--
5 files changed, 30 insertions(+), 34 deletions(-)
(commons-lang) 05/05: Bump org.apache.commons:commons-parent from 80 to 81
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 1cadf8950d4634496ed9b6c66a14e9749538d17e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 30 17:12:03 2025 -0500
Bump org.apache.commons:commons-parent from 80 to 81
---
pom.xml | 2 +-
src/changes/changes.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 8fbc25cc1..37b50e020 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>80</version>
+ <version>81</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>commons-lang3</artifactId>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 97dc1e9eb..d1ff0c2f6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -101,7 +101,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add FailableIntToFloatFunction.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Validate.isTrue(boolean, Supplier<String>).</action>
<!-- UPDATE -->
- <action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 73 to 80 #1267, #1277, #1283, #1288, #1302.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 73 to 81 #1267, #1277, #1283, #1288, #1302.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">[site] Bump org.codehaus.mojo:taglist-maven-plugin from 3.1.0 to 3.2.1 #1300.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">[test] Bump org.easymock:easymock from 5.4.0 to 5.5.0 #1317.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">[test] Bump org.apache.commons:commons-text from 1.12.0 to 1.13.0 #1336.</action>
(commons-lang) 03/05: Migrate from APIs deprecated in Java 9
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 80a56e69e5ae7f521220c1574d45bc4d52a1b057
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 30 10:41:11 2025 -0500
Migrate from APIs deprecated in Java 9
---
.../commons/lang3/concurrent/AtomicInitializerNonObjectTest.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/AtomicInitializerNonObjectTest.java b/src/test/java/org/apache/commons/lang3/concurrent/AtomicInitializerNonObjectTest.java
index 3a0966bfd..57f006e66 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/AtomicInitializerNonObjectTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/AtomicInitializerNonObjectTest.java
@@ -37,7 +37,7 @@ protected ConcurrentInitializer<Integer> createInitializer() {
return new AtomicInitializer<Integer>() {
@Override
protected Integer initialize() {
- return new Integer(0);
+ return Integer.valueOf(0);
}
};
}
@@ -52,10 +52,9 @@ protected Integer initialize() {
if (firstRun.getAndSet(0) == 1) {
return null;
}
- return new Integer(0);
+ return Integer.valueOf(0);
}
};
-
assertNull(initializer.get());
assertNull(initializer.get());
}
(commons-lang) 02/05: Instead of throwing a NullPointerException, ArrayUtils.toStringArray(Object[]) should return "null" for null elements like ArrayUtils.toStringArray(Object[], String) returns its valueForNullElements.
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 d8b310a650811b95c6dadd5c952ef910d4635ca5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 30 10:40:58 2025 -0500
Instead of throwing a NullPointerException,
ArrayUtils.toStringArray(Object[]) should return "null" for null
elements like ArrayUtils.toStringArray(Object[], String) returns its
valueForNullElements.
This also allows toStringArray(Object[]) to be implemented as
toStringArray(array, "null")
---
src/changes/changes.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8a52306f1..97dc1e9eb 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -80,6 +80,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1762" type="fix" dev="ggregory" due-to="Alonso Gonzalez, Gary Gregory">StopWatch methods should not delegate to deprecated methods.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Don't call TypeUtils.toString(Type) on every array item in TypeUtils.parameterize[WithOwner](Type, Class, Map, Type>) unless required.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Remove -nouses directive from maven-bundle-plugin. OSGi package imports now state 'uses' definitions for package imports, this doesn't affect JPMS (from org.apache.commons:commons-parent:80).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Instead of throwing a NullPointerException, ArrayUtils.toStringArray(Object[]) should return "null" for null elements like ArrayUtils.toStringArray(Object[], String) returns its valueForNullElements.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Strings and refactor StringUtils.</action>
<action issue="LANG-1747" type="add" dev="ggregory" due-to="Oliver B. Fischer, Gary Gregory">Add StopWatch.run([Failable]Runnable) and get([Failable]Supplier).</action>
(commons-lang) 01/05: Instead of throwing a NullPointerException, ArrayUtils.toStringArray(Object[]) should return "null" for null elements like ArrayUtils.toStringArray(Object[], String) returns its valueForNullElements.
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 1521bf3e9f3e2f944fc2331b0ac19c9f5f0fde6d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 30 10:40:45 2025 -0500
Instead of throwing a NullPointerException,
ArrayUtils.toStringArray(Object[]) should return "null" for null
elements like ArrayUtils.toStringArray(Object[], String) returns its
valueForNullElements.
This also allows toStringArray(Object[]) to be implemented as
toStringArray(array, "null")
---
.../java/org/apache/commons/lang3/ArrayUtils.java | 45 ++++++++++++----------
.../org/apache/commons/lang3/ArrayUtilsTest.java | 5 +--
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index 3f7a86eb3..11c35f741 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -37,6 +37,7 @@
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.commons.lang3.function.FailableFunction;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.stream.IntStreams;
@@ -4274,6 +4275,27 @@ public static int lastIndexOf(final short[] array, final short valueToFind, int
return INDEX_NOT_FOUND;
}
+ /**
+ * Maps elements from an array into elements of a new array of a given type, while mapping old elements to new elements.
+ *
+ * @param <T> The input array type.
+ * @param <R> The output array type.
+ * @param <E> The type of exceptions thrown when the mapper function fails.
+ * @param array The input array.
+ * @param componentType the component type of the result array.
+ * @param mapper a non-interfering, stateless function to apply to each element
+ * @return a new array
+ * @throws E Thrown when the mapper function fails.
+ */
+ private static <T, R, E extends Throwable> R[] map(final T[] array, final Class<R> componentType, final FailableFunction<? super T, ? extends R, E> mapper)
+ throws E {
+ final R[] newArray = newInstance(componentType, array.length);
+ for (int i = 0; i < newArray.length; i++) {
+ newArray[i] = mapper.apply(array[i]);
+ }
+ return newArray;
+ }
+
private static int max0(final int other) {
return Math.max(0, other);
}
@@ -9480,23 +9502,10 @@ public static String toString(final Object array, final String stringIfNull) {
* @param array the {@code Object[]} to be processed, may be null
* @return {@code String[]} of the same size as the source with its element's string representation,
* {@code null} if null array input
- * @throws NullPointerException if an array element is {@code null}
* @since 3.6
*/
public static String[] toStringArray(final Object[] array) {
- if (array == null) {
- return null;
- }
- if (array.length == 0) {
- return EMPTY_STRING_ARRAY;
- }
-
- final String[] result = new String[array.length];
- for (int i = 0; i < array.length; i++) {
- result[i] = array[i].toString();
- }
-
- return result;
+ return toStringArray(array, "null");
}
/**
@@ -9518,13 +9527,7 @@ public static String[] toStringArray(final Object[] array, final String valueFor
if (array.length == 0) {
return EMPTY_STRING_ARRAY;
}
-
- final String[] result = new String[array.length];
- for (int i = 0; i < array.length; i++) {
- result[i] = Objects.toString(array[i], valueForNullElements);
- }
-
- return result;
+ return map(array, String.class, e -> Objects.toString(e, valueForNullElements));
}
/**
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index 7256865e7..24572b474 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -6605,13 +6605,10 @@ public void testToString() {
@Test
public void testToStringArray_array() {
assertNull(ArrayUtils.toStringArray(null));
-
assertArrayEquals(new String[0], ArrayUtils.toStringArray(new Object[0]));
-
final Object[] array = {1, 2, 3, "array", "test"};
assertArrayEquals(new String[]{"1", "2", "3", "array", "test"}, ArrayUtils.toStringArray(array));
-
- assertThrows(NullPointerException.class, () -> ArrayUtils.toStringArray(new Object[]{null}));
+ assertArrayEquals(new String[]{"null"}, ArrayUtils.toStringArray(new Object[]{null}));
}
@Test
(commons-lang) 04/05: No need to configure Javadoc to point to Commons Text for deprecated reference
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 932791a2438edd42308ad3584c08ef575d1c8322
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 30 17:10:54 2025 -0500
No need to configure Javadoc to point to Commons Text for deprecated
reference
- Pick up other Javadoc link references from the parent POM
- This all fixes the Javadoc link warning on Java 8
---
pom.xml | 4 ----
1 file changed, 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index ca7fadf3a..8fbc25cc1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -209,10 +209,6 @@
<source>${maven.compiler.source}</source>
<quiet>true</quiet>
<notimestamp>true</notimestamp>
- <links>
- <link>https://commons.apache.org/proper/commons-text/apidocs</link>
- <link>${commons.javadoc.javaee.link}</link>
- </links>
<validateLinks>true</validateLinks>
<archive>
<manifest>