From d5fef1e78469cb517cbe3a0af410802e0679ce44 Mon Sep 17 00:00:00 2001 From: Diego Marcilio Date: Sat, 26 Mar 2022 18:43:05 +0100 Subject: [PATCH] Updating javadoc for NullPointerException when Validate.notNull() is called (#870) --- .../org/apache/commons/lang3/CharRange.java | 2 +- .../org/apache/commons/lang3/ThreadUtils.java | 24 ++++++++++--------- .../MultiBackgroundInitializer.java | 3 ++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java index 3a1fd188d..eae5196bb 100644 --- a/src/main/java/org/apache/commons/lang3/CharRange.java +++ b/src/main/java/org/apache/commons/lang3/CharRange.java @@ -184,7 +184,7 @@ public boolean contains(final char ch) { * * @param range the range to check against * @return {@code true} if this range entirely contains the input range - * @throws IllegalArgumentException if {@code null} input + * @throws NullPointerException if {@code null} input */ public boolean contains(final CharRange range) { Validate.notNull(range, "range"); diff --git a/src/main/java/org/apache/commons/lang3/ThreadUtils.java b/src/main/java/org/apache/commons/lang3/ThreadUtils.java index f8b85873e..ebecc7661 100644 --- a/src/main/java/org/apache/commons/lang3/ThreadUtils.java +++ b/src/main/java/org/apache/commons/lang3/ThreadUtils.java @@ -68,7 +68,7 @@ public static class NamePredicate implements ThreadPredicate, ThreadGroupPredica * Predicate constructor * * @param name thread or thread group name - * @throws IllegalArgumentException if the name is {@code null} + * @throws NullPointerException if the name is {@code null} */ public NamePredicate(final String name) { Validate.notNull(name, "name"); @@ -171,7 +171,8 @@ public static Thread findThreadById(final long threadId) { * @param threadGroupName The thread group name * @return The threads which belongs to a thread group with the specified group name and the thread's id match the specified id. * {@code null} is returned if no such thread exists - * @throws IllegalArgumentException if the specified id is zero or negative or the group name is null + * @throws NullPointerException if the group name is null + * @throws IllegalArgumentException if the specified id is zero or negative * @throws SecurityException * if the current thread cannot access the system thread group * @@ -194,7 +195,8 @@ public static Thread findThreadById(final long threadId, final String threadGrou * @param threadGroup The thread group * @return The thread which belongs to a specified thread group and the thread's id match the specified id. * {@code null} is returned if no such thread exists - * @throws IllegalArgumentException if the specified id is zero or negative or the group is null + * @throws NullPointerException if {@code threadGroup == null} + * @throws IllegalArgumentException if the specified id is zero or negative * @throws SecurityException * if the current thread cannot access the system thread group * @@ -217,7 +219,7 @@ public static Thread findThreadById(final long threadId, final ThreadGroup threa * @param recurse if {@code true} then evaluate the predicate recursively on all thread groups in all subgroups of the given group * @param predicate the predicate * @return An unmodifiable {@code Collection} of active thread groups which match the given predicate and which is a subgroup of the given thread group - * @throws IllegalArgumentException if the given group or predicate is null + * @throws NullPointerException if the given group or predicate is null * @throws SecurityException if the current thread cannot modify * thread groups from this thread's thread group up to the system thread group */ @@ -247,7 +249,7 @@ public static Collection findThreadGroups(final ThreadGroup threadG * * @param predicate the predicate * @return An unmodifiable {@code Collection} of active thread groups matching the given predicate - * @throws IllegalArgumentException if the predicate is null + * @throws NullPointerException if the predicate is null * @throws SecurityException * if the current thread cannot access the system thread group * @throws SecurityException if the current thread cannot modify @@ -262,7 +264,7 @@ public static Collection findThreadGroups(final ThreadGroupPredicat * * @param threadGroupName The thread group name * @return the thread groups with the specified group name or an empty collection if no such thread group exists. The collection returned is always unmodifiable. - * @throws IllegalArgumentException if group name is null + * @throws NullPointerException if group name is null * @throws SecurityException * if the current thread cannot access the system thread group * @@ -280,7 +282,7 @@ public static Collection findThreadGroupsByName(final String thread * @param recurse if {@code true} then evaluate the predicate recursively on all threads in all subgroups of the given group * @param predicate the predicate * @return An unmodifiable {@code Collection} of active threads which match the given predicate and which belongs to the given thread group - * @throws IllegalArgumentException if the given group or predicate is null + * @throws NullPointerException if the given group or predicate is null * @throws SecurityException if the current thread cannot modify * thread groups from this thread's thread group up to the system thread group */ @@ -311,7 +313,7 @@ public static Collection findThreads(final ThreadGroup threadGroup, fina * @param predicate the predicate * @return An unmodifiable {@code Collection} of active threads matching the given predicate * - * @throws IllegalArgumentException if the predicate is null + * @throws NullPointerException if the predicate is null * @throws SecurityException * if the current thread cannot access the system thread group * @throws SecurityException if the current thread cannot modify @@ -326,7 +328,7 @@ public static Collection findThreads(final ThreadPredicate predicate) { * * @param threadName The thread name * @return The threads with the specified name or an empty collection if no such thread exists. The collection returned is always unmodifiable. - * @throws IllegalArgumentException if the specified name is null + * @throws NullPointerException if the specified name is null * @throws SecurityException * if the current thread cannot access the system thread group * @@ -344,7 +346,7 @@ public static Collection findThreadsByName(final String threadName) { * @param threadGroupName The thread group name * @return The threads which belongs to a thread group with the specified group name and the thread's name match the specified name, * An empty collection is returned if no such thread exists. The collection returned is always unmodifiable. - * @throws IllegalArgumentException if the specified thread name or group name is null + * @throws NullPointerException if the specified thread name or group name is null * @throws SecurityException * if the current thread cannot access the system thread group * @@ -376,7 +378,7 @@ public static Collection findThreadsByName(final String threadName, fina * @param threadGroup The thread group * @return The threads which belongs to a thread group and the thread's name match the specified name, * An empty collection is returned if no such thread exists. The collection returned is always unmodifiable. - * @throws IllegalArgumentException if the specified thread name or group is null + * @throws NullPointerException if the specified thread name or group is null * @throws SecurityException * if the current thread cannot access the system thread group * diff --git a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java index 08c9b34cf..d627526e2 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java @@ -128,7 +128,8 @@ public MultiBackgroundInitializer(final ExecutorService exec) { * @param name the name of the initializer (must not be null) * @param backgroundInitializer the {@code BackgroundInitializer} to add (must not be * null) - * @throws IllegalArgumentException if a required parameter is missing + * @throws NullPointerException if either {@code name} or {@code backgroundInitializer} + * is {@code null} * @throws IllegalStateException if {@code start()} has already been called */ public void addInitializer(final String name, final BackgroundInitializer backgroundInitializer) {