[LANG-1525] Internally use Validate.notNull(foo, ...) instead of
Validate.isTrue(foo != null, ...).
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5aa8be2..a97452f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -106,6 +106,7 @@
<action type="update" dev="ggregory" due-to="Peter Verhas">Reuse own code in Functions.java #493.</action>
<action issue="LANG-1518" type="fix" dev="ggregory" due-to="Michele Preti, Bruno P. Kinoshita, Gary Gregory">MethodUtils.getAnnotation() with searchSupers = true does not work if super is generic #494.</action>
<action issue="LANG-1523" type="update" dev="ggregory" due-to="Edgar Asatryan, Bruno P. Kinoshita, Gary Gregory">Avoid unnecessary allocation in StringUtils.wrapIfMissing. #496.</action>
+ <action issue="LANG-1525" type="update" dev="ggregory" due-to="Edgar Asatryan, Bruno P. Kinoshita, Gary Gregory">Internally use Validate.notNull(foo, ...) instead of Validate.isTrue(foo != null, ...).</action>
</release>
<release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11.">
diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java
index be656d2..0504bed 100644
--- a/src/main/java/org/apache/commons/lang3/CharRange.java
+++ b/src/main/java/org/apache/commons/lang3/CharRange.java
@@ -179,7 +179,7 @@ public boolean contains(final char ch) {
* @throws IllegalArgumentException if {@code null} input
*/
public boolean contains(final CharRange range) {
- Validate.isTrue(range != null, "The Range must not be null");
+ Validate.notNull(range, "The Range must not be null");
if (negated) {
if (range.negated) {
return start >= range.start && end <= range.end;
diff --git a/src/main/java/org/apache/commons/lang3/CharUtils.java b/src/main/java/org/apache/commons/lang3/CharUtils.java
index be0aea4..b872ac0 100644
--- a/src/main/java/org/apache/commons/lang3/CharUtils.java
+++ b/src/main/java/org/apache/commons/lang3/CharUtils.java
@@ -134,7 +134,7 @@ public static Character toCharacterObject(final String str) {
* @throws IllegalArgumentException if the Character is null
*/
public static char toChar(final Character ch) {
- Validate.isTrue(ch != null, "The Character must not be null");
+ Validate.notNull(ch, "The Character must not be null");
return ch.charValue();
}
@@ -175,7 +175,7 @@ public static char toChar(final Character ch, final char defaultValue) {
* @throws IllegalArgumentException if the String is empty
*/
public static char toChar(final String str) {
- Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty");
+ Validate.notEmpty(str, "The String must not be empty");
return str.charAt(0);
}
@@ -263,7 +263,7 @@ public static int toIntValue(final char ch, final int defaultValue) {
* @throws IllegalArgumentException if the Character is not ASCII numeric or is null
*/
public static int toIntValue(final Character ch) {
- Validate.isTrue(ch != null, "The character must not be null");
+ Validate.notNull(ch, "The character must not be null");
return toIntValue(ch.charValue());
}
diff --git a/src/main/java/org/apache/commons/lang3/EnumUtils.java b/src/main/java/org/apache/commons/lang3/EnumUtils.java
index 75b052a..1df4301 100644
--- a/src/main/java/org/apache/commons/lang3/EnumUtils.java
+++ b/src/main/java/org/apache/commons/lang3/EnumUtils.java
@@ -116,7 +116,7 @@ public static <E extends Enum<E>> long generateBitVector(final Class<E> enumClas
Validate.notNull(values);
long total = 0;
for (final E constant : values) {
- Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED);
+ Validate.notNull(constant, NULL_ELEMENTS_NOT_PERMITTED);
total |= 1L << constant.ordinal();
}
return total;
@@ -173,7 +173,7 @@ public static <E extends Enum<E>> long generateBitVector(final Class<E> enumClas
Validate.notNull(values);
final EnumSet<E> condensed = EnumSet.noneOf(enumClass);
for (final E constant : values) {
- Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED);
+ Validate.notNull(constant, NULL_ELEMENTS_NOT_PERMITTED);
condensed.add(constant);
}
final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1];
diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java
index 28f8d76..14bfc1d 100644
--- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java
+++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java
@@ -133,7 +133,7 @@ public static <T extends Serializable> T roundtrip(final T msg) {
* @throws SerializationException (runtime) if the serialization fails
*/
public static void serialize(final Serializable obj, final OutputStream outputStream) {
- Validate.isTrue(outputStream != null, "The OutputStream must not be null");
+ Validate.notNull(outputStream, "The OutputStream must not be null");
try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) {
out.writeObject(obj);
} catch (final IOException ex) {
@@ -188,7 +188,7 @@ public static void serialize(final Serializable obj, final OutputStream outputSt
* (runtime) if the serialization fails
*/
public static <T> T deserialize(final InputStream inputStream) {
- Validate.isTrue(inputStream != null, "The InputStream must not be null");
+ Validate.notNull(inputStream, "The InputStream must not be null");
try (ObjectInputStream in = new ObjectInputStream(inputStream)) {
@SuppressWarnings("unchecked")
final T obj = (T) in.readObject();
@@ -219,7 +219,7 @@ public static <T> T deserialize(final InputStream inputStream) {
* (runtime) if the serialization fails
*/
public static <T> T deserialize(final byte[] objectData) {
- Validate.isTrue(objectData != null, "The byte[] must not be null");
+ Validate.notNull(objectData, "The byte[] must not be null");
return deserialize(new ByteArrayInputStream(objectData));
}
diff --git a/src/main/java/org/apache/commons/lang3/ThreadUtils.java b/src/main/java/org/apache/commons/lang3/ThreadUtils.java
index 5534194..fef3dc8 100644
--- a/src/main/java/org/apache/commons/lang3/ThreadUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ThreadUtils.java
@@ -50,7 +50,7 @@ public class ThreadUtils {
* thread groups from this thread's thread group up to the system thread group
*/
public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) {
- Validate.isTrue(threadGroup != null, "The thread group must not be null");
+ Validate.notNull(threadGroup, "The thread group must not be null");
final Thread thread = findThreadById(threadId);
if (thread != null && threadGroup.equals(thread.getThreadGroup())) {
return thread;
@@ -73,7 +73,7 @@ public static Thread findThreadById(final long threadId, final ThreadGroup threa
* thread groups from this thread's thread group up to the system thread group
*/
public static Thread findThreadById(final long threadId, final String threadGroupName) {
- Validate.isTrue(threadGroupName != null, "The thread group name must not be null");
+ Validate.notNull(threadGroupName, "The thread group name must not be null");
final Thread thread = findThreadById(threadId);
if (thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) {
return thread;
@@ -114,8 +114,8 @@ public static Collection<Thread> findThreadsByName(final String threadName, fina
* thread groups from this thread's thread group up to the system thread group
*/
public static Collection<Thread> findThreadsByName(final String threadName, final String threadGroupName) {
- Validate.isTrue(threadName != null, "The thread name must not be null");
- Validate.isTrue(threadGroupName != null, "The thread group name must not be null");
+ Validate.notNull(threadName, "The thread name must not be null");
+ Validate.notNull(threadGroupName, "The thread group name must not be null");
final Collection<ThreadGroup> threadGroups = findThreadGroups(new NamePredicate(threadGroupName));
@@ -305,7 +305,7 @@ public static class NamePredicate implements ThreadPredicate, ThreadGroupPredica
*/
public NamePredicate(final String name) {
super();
- Validate.isTrue(name != null, "The name must not be null");
+ Validate.notNull(name, "The name must not be null");
this.name = name;
}
@@ -390,8 +390,8 @@ public static Collection<ThreadGroup> findThreadGroups(final ThreadGroupPredicat
* thread groups from this thread's thread group up to the system thread group
*/
public static Collection<Thread> findThreads(final ThreadGroup group, final boolean recurse, final ThreadPredicate predicate) {
- Validate.isTrue(group != null, "The group must not be null");
- Validate.isTrue(predicate != null, "The predicate must not be null");
+ Validate.notNull(group, "The group must not be null");
+ Validate.notNull(predicate, "The predicate must not be null");
int count = group.activeCount();
Thread[] threads;
@@ -422,8 +422,8 @@ public static Collection<Thread> findThreads(final ThreadGroup group, final bool
* thread groups from this thread's thread group up to the system thread group
*/
public static Collection<ThreadGroup> findThreadGroups(final ThreadGroup group, final boolean recurse, final ThreadGroupPredicate predicate) {
- Validate.isTrue(group != null, "The group must not be null");
- Validate.isTrue(predicate != null, "The predicate must not be null");
+ Validate.notNull(group, "The group must not be null");
+ Validate.notNull(predicate, "The predicate must not be null");
int count = group.activeGroupCount();
ThreadGroup[] threadGroups;
diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
index 6beeaf7..2ea1f69 100644
--- a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
@@ -104,8 +104,8 @@ public class DiffBuilder<T> implements Builder<DiffResult<T>> {
public DiffBuilder(final T lhs, final T rhs,
final ToStringStyle style, final boolean testTriviallyEqual) {
- Validate.isTrue(lhs != null, "lhs cannot be null");
- Validate.isTrue(rhs != null, "rhs cannot be null");
+ Validate.notNull(lhs, "lhs cannot be null");
+ Validate.notNull(rhs, "rhs cannot be null");
this.diffs = new ArrayList<>();
this.left = lhs;
@@ -950,7 +950,7 @@ public DiffBuilder<T> append(final String fieldName, final Object[] lhs,
public DiffBuilder<T> append(final String fieldName,
final DiffResult<T> diffResult) {
validateFieldNameNotNull(fieldName);
- Validate.isTrue(diffResult != null, "Diff result cannot be null");
+ Validate.notNull(diffResult, "Diff result cannot be null");
if (objectsTriviallyEqual) {
return this;
}
@@ -978,7 +978,7 @@ public DiffResult<T> build() {
}
private void validateFieldNameNotNull(final String fieldName) {
- Validate.isTrue(fieldName != null, "Field name cannot be null");
+ Validate.notNull(fieldName, "Field name cannot be null");
}
}
diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
index 8132dd4..b8594ad 100644
--- a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
+++ b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
@@ -74,9 +74,9 @@ public class DiffResult<T> implements Iterable<Diff<?>> {
*/
DiffResult(final T lhs, final T rhs, final List<Diff<?>> diffs,
final ToStringStyle style) {
- Validate.isTrue(lhs != null, "Left hand object cannot be null");
- Validate.isTrue(rhs != null, "Right hand object cannot be null");
- Validate.isTrue(diffs != null, "List of differences cannot be null");
+ Validate.notNull(lhs, "Left hand object cannot be null");
+ Validate.notNull(rhs, "Right hand object cannot be null");
+ Validate.notNull(diffs, "List of differences cannot be null");
this.diffs = diffs;
this.lhs = lhs;
diff --git a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
index c430b40..7b7bbb0 100644
--- a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
@@ -358,7 +358,7 @@ public static int reflectionHashCode(final int initialNonZeroOddNumber, final in
*/
public static <T> int reflectionHashCode(final int initialNonZeroOddNumber, final int multiplierNonZeroOddNumber, final T object,
final boolean testTransients, final Class<? super T> reflectUpToClass, final String... excludeFields) {
- Validate.isTrue(object != null, "The object to build a hash code for must not be null");
+ Validate.notNull(object, "The object to build a hash code for must not be null");
final HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
Class<?> clazz = object.getClass();
reflectionAppend(object, clazz, builder, testTransients, excludeFields);
diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
index 3996a59..d19aa13 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -434,8 +434,7 @@ public static String toStringExclude(final Object object, final String... exclud
}
private static Object checkNotNull(final Object obj) {
- Validate.isTrue(obj != null, "The Object passed in should not be null.");
- return obj;
+ return Validate.notNull(obj, "The Object passed in should not be null.");
}
/**
diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
index ace1f83..3522ec3 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
@@ -133,8 +133,7 @@ public static ToStringStyle getDefaultStyle() {
* @throws IllegalArgumentException if the style is {@code null}
*/
public static void setDefaultStyle(final ToStringStyle style) {
- Validate.isTrue(style != null, "The style must not be null");
- defaultStyle = style;
+ defaultStyle = Validate.notNull(style, "The style must not be null");
}
//----------------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
index c1d0735..6fca65c 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
@@ -120,6 +120,6 @@ protected T initialize() throws Exception {
* @throws IllegalArgumentException if the {@code Callable} is <b>null</b>
*/
private void checkCallable(final Callable<T> call) {
- Validate.isTrue(call != null, "Callable must not be null!");
+ Validate.notNull(call, "Callable must not be null!");
}
}
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 6a6a9a0..7e36fd9 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
@@ -133,8 +133,8 @@ public MultiBackgroundInitializer(final ExecutorService exec) {
* @throws IllegalStateException if {@code start()} has already been called
*/
public void addInitializer(final String name, final BackgroundInitializer<?> init) {
- Validate.isTrue(name != null, "Name of child initializer must not be null!");
- Validate.isTrue(init != null, "Child initializer must not be null!");
+ Validate.notNull(name, "Name of child initializer must not be null!");
+ Validate.notNull(init, "Child initializer must not be null!");
synchronized (this) {
if (isStarted()) {
diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
index 6bfc79e..a2a67b4 100644
--- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
+++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
@@ -632,7 +632,7 @@ public static void printRootCauseStackTrace(final Throwable throwable, final Pri
if (throwable == null) {
return;
}
- Validate.isTrue(stream != null, "The PrintStream must not be null");
+ Validate.notNull(stream, "The PrintStream must not be null");
final String trace[] = getRootCauseStackTrace(throwable);
for (final String element : trace) {
stream.println(element);
@@ -663,7 +663,7 @@ public static void printRootCauseStackTrace(final Throwable throwable, final Pri
if (throwable == null) {
return;
}
- Validate.isTrue(writer != null, "The PrintWriter must not be null");
+ Validate.notNull(writer, "The PrintWriter must not be null");
final String trace[] = getRootCauseStackTrace(throwable);
for (final String element : trace) {
writer.println(element);
diff --git a/src/main/java/org/apache/commons/lang3/math/Fraction.java b/src/main/java/org/apache/commons/lang3/math/Fraction.java
index 7d452c1..7c11f2a 100644
--- a/src/main/java/org/apache/commons/lang3/math/Fraction.java
+++ b/src/main/java/org/apache/commons/lang3/math/Fraction.java
@@ -312,7 +312,7 @@ public static Fraction getFraction(double value) {
* @throws NumberFormatException if the number format is invalid
*/
public static Fraction getFraction(String str) {
- Validate.isTrue(str != null, "The string must not be null");
+ Validate.notNull(str, "The string must not be null");
// parse double format
int pos = str.indexOf('.');
if (pos >= 0) {
@@ -730,7 +730,7 @@ public Fraction subtract(final Fraction fraction) {
* cannot be represented in an {@code int}.
*/
private Fraction addSub(final Fraction fraction, final boolean isAdd) {
- Validate.isTrue(fraction != null, "The fraction must not be null");
+ Validate.notNull(fraction, "The fraction must not be null");
// zero is identity for addition.
if (numerator == 0) {
return isAdd ? fraction : fraction.negate();
@@ -778,7 +778,7 @@ private Fraction addSub(final Fraction fraction, final boolean isAdd) {
* {@code Integer.MAX_VALUE}
*/
public Fraction multiplyBy(final Fraction fraction) {
- Validate.isTrue(fraction != null, "The fraction must not be null");
+ Validate.notNull(fraction, "The fraction must not be null");
if (numerator == 0 || fraction.numerator == 0) {
return ZERO;
}
@@ -801,7 +801,7 @@ public Fraction multiplyBy(final Fraction fraction) {
* {@code Integer.MAX_VALUE}
*/
public Fraction divideBy(final Fraction fraction) {
- Validate.isTrue(fraction != null, "The fraction must not be null");
+ Validate.notNull(fraction, "The fraction must not be null");
if (fraction.numerator == 0) {
throw new ArithmeticException("The fraction to divide by must not be zero");
}
diff --git a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
index d9fb5fa..ae737cf 100644
--- a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
@@ -37,7 +37,7 @@ public class IEEE754rUtils {
* @since 3.4 Changed signature from min(double[]) to min(double...)
*/
public static double min(final double... array) {
- Validate.isTrue(array != null, "The Array must not be null");
+ Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns min
@@ -59,7 +59,7 @@ public static double min(final double... array) {
* @since 3.4 Changed signature from min(float[]) to min(float...)
*/
public static float min(final float... array) {
- Validate.isTrue(array != null, "The Array must not be null");
+ Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns min
@@ -149,7 +149,7 @@ public static float min(final float a, final float b) {
* @since 3.4 Changed signature from max(double[]) to max(double...)
*/
public static double max(final double... array) {
- Validate.isTrue(array != null, "The Array must not be null");
+ Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns max
@@ -171,7 +171,7 @@ public static double max(final double... array) {
* @since 3.4 Changed signature from max(float[]) to max(float...)
*/
public static float max(final float... array) {
- Validate.isTrue(array != null, "The Array must not be null");
+ Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns max
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index 97aee23..ab7badc 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -1312,7 +1312,7 @@ public static float max(final float... array) {
* @throws IllegalArgumentException if {@code array} is either {@code null} or empty
*/
private static void validateArray(final Object array) {
- Validate.isTrue(array != null, "The Array must not be null");
+ Validate.notNull(array, "The Array must not be null");
Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty.");
}
diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
index 07eb839..4d2ce16 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
@@ -86,7 +86,7 @@ public static Field getField(final Class<?> cls, final String fieldName) {
* in the inheritance hierarchy
*/
public static Field getField(final Class<?> cls, final String fieldName, final boolean forceAccess) {
- Validate.isTrue(cls != null, "The class must not be null");
+ Validate.notNull(cls, "The class must not be null");
Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty");
// FIXME is this workaround still needed? lang requires Java 6
// Sun Java 1.3 has a bugged implementation of getField hence we write the
@@ -169,7 +169,7 @@ public static Field getDeclaredField(final Class<?> cls, final String fieldName)
* if the class is {@code null}, or the field name is blank or empty
*/
public static Field getDeclaredField(final Class<?> cls, final String fieldName, final boolean forceAccess) {
- Validate.isTrue(cls != null, "The class must not be null");
+ Validate.notNull(cls, "The class must not be null");
Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty");
try {
// only consider the specified class by using getDeclaredField()
@@ -214,7 +214,7 @@ public static Field getDeclaredField(final Class<?> cls, final String fieldName,
* @since 3.2
*/
public static List<Field> getAllFieldsList(final Class<?> cls) {
- Validate.isTrue(cls != null, "The class must not be null");
+ Validate.notNull(cls, "The class must not be null");
final List<Field> allFields = new ArrayList<>();
Class<?> currentClass = cls;
while (currentClass != null) {
@@ -253,7 +253,7 @@ public static List<Field> getAllFieldsList(final Class<?> cls) {
* @since 3.4
*/
public static List<Field> getFieldsListWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) {
- Validate.isTrue(annotationCls != null, "The annotation class must not be null");
+ Validate.notNull(annotationCls, "The annotation class must not be null");
final List<Field> allFields = getAllFieldsList(cls);
final List<Field> annotatedFields = new ArrayList<>();
for (final Field field : allFields) {
@@ -294,7 +294,7 @@ public static Object readStaticField(final Field field) throws IllegalAccessExce
* if the field is not made accessible
*/
public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException {
- Validate.isTrue(field != null, "The field must not be null");
+ Validate.notNull(field, "The field must not be null");
Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName());
return readField(field, (Object) null, forceAccess);
}
@@ -337,7 +337,7 @@ public static Object readStaticField(final Class<?> cls, final String fieldName)
*/
public static Object readStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
final Field field = getField(cls, fieldName, forceAccess);
- Validate.isTrue(field != null, "Cannot locate field '%s' on %s", fieldName, cls);
+ Validate.notNull(field, "Cannot locate field '%s' on %s", fieldName, cls);
// already forced access above, don't repeat it here:
return readStaticField(field, false);
}
@@ -381,7 +381,7 @@ public static Object readDeclaredStaticField(final Class<?> cls, final String fi
*/
public static Object readDeclaredStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
final Field field = getDeclaredField(cls, fieldName, forceAccess);
- Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
+ Validate.notNull(field, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
// already forced access above, don't repeat it here:
return readStaticField(field, false);
}
@@ -420,7 +420,7 @@ public static Object readField(final Field field, final Object target) throws Il
* if the field is not made accessible
*/
public static Object readField(final Field field, final Object target, final boolean forceAccess) throws IllegalAccessException {
- Validate.isTrue(field != null, "The field must not be null");
+ Validate.notNull(field, "The field must not be null");
if (forceAccess && !field.isAccessible()) {
field.setAccessible(true);
} else {
@@ -464,7 +464,7 @@ public static Object readField(final Object target, final String fieldName) thro
* if the named field is not made accessible
*/
public static Object readField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
- Validate.isTrue(target != null, "target object must not be null");
+ Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass();
final Field field = getField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls);
@@ -507,7 +507,7 @@ public static Object readDeclaredField(final Object target, final String fieldNa
* if the field is not made accessible
*/
public static Object readDeclaredField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
- Validate.isTrue(target != null, "target object must not be null");
+ Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass();
final Field field = getDeclaredField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls, fieldName);
@@ -548,7 +548,7 @@ public static void writeStaticField(final Field field, final Object value) throw
* if the field is not made accessible or is {@code final}
*/
public static void writeStaticField(final Field field, final Object value, final boolean forceAccess) throws IllegalAccessException {
- Validate.isTrue(field != null, "The field must not be null");
+ Validate.notNull(field, "The field must not be null");
Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field %s.%s is not static", field.getDeclaringClass().getName(),
field.getName());
writeField(field, (Object) null, value, forceAccess);
@@ -595,7 +595,7 @@ public static void writeStaticField(final Class<?> cls, final String fieldName,
public static void writeStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException {
final Field field = getField(cls, fieldName, forceAccess);
- Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls);
+ Validate.notNull(field, "Cannot locate field %s on %s", fieldName, cls);
// already forced access above, don't repeat it here:
writeStaticField(field, value, false);
}
@@ -640,7 +640,7 @@ public static void writeDeclaredStaticField(final Class<?> cls, final String fie
public static void writeDeclaredStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException {
final Field field = getDeclaredField(cls, fieldName, forceAccess);
- Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
+ Validate.notNull(field, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
// already forced access above, don't repeat it here:
writeField(field, (Object) null, value, false);
}
@@ -682,7 +682,7 @@ public static void writeField(final Field field, final Object target, final Obje
*/
public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
throws IllegalAccessException {
- Validate.isTrue(field != null, "The field must not be null");
+ Validate.notNull(field, "The field must not be null");
if (forceAccess && !field.isAccessible()) {
field.setAccessible(true);
} else {
@@ -722,7 +722,7 @@ public static void removeFinalModifier(final Field field) {
*/
@Deprecated
public static void removeFinalModifier(final Field field, final boolean forceAccess) {
- Validate.isTrue(field != null, "The field must not be null");
+ Validate.notNull(field, "The field must not be null");
try {
if (Modifier.isFinal(field.getModifiers())) {
@@ -791,7 +791,7 @@ public static void writeField(final Object target, final String fieldName, final
*/
public static void writeField(final Object target, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException {
- Validate.isTrue(target != null, "target object must not be null");
+ Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass();
final Field field = getField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
@@ -839,7 +839,7 @@ public static void writeDeclaredField(final Object target, final String fieldNam
*/
public static void writeDeclaredField(final Object target, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException {
- Validate.isTrue(target != null, "target object must not be null");
+ Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass();
final Field field = getDeclaredField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 98e1b4d..1d76ce6 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -914,7 +914,7 @@ public static List<Method> getMethodsListWithAnnotation(final Class<?> cls,
final Class<? extends Annotation> annotationCls,
final boolean searchSupers, final boolean ignoreAccess) {
- Validate.isTrue(cls != null, "The class must not be null");
+ Validate.notNull(cls, "The class must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
final List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
: new ArrayList<>());
@@ -957,7 +957,7 @@ public static List<Method> getMethodsListWithAnnotation(final Class<?> cls,
public static <A extends Annotation> A getAnnotation(final Method method, final Class<A> annotationCls,
final boolean searchSupers, final boolean ignoreAccess) {
- Validate.isTrue(method != null, "The method must not be null");
+ Validate.notNull(method, "The method must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
if (!ignoreAccess && !MemberUtils.isAccessible(method)) {
return null;
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index 9fa2549..300b7ea 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -1786,7 +1786,7 @@ public static int truncatedCompareTo(final Date date1, final Date date2, final i
}
private static void validateDateNotNull(final Date date) {
- Validate.isTrue(date != null, "The date must not be null");
+ Validate.notNull(date, "The date must not be null");
}
//-----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java
index 18e4e90..8d59a55 100644
--- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java
@@ -311,7 +311,7 @@ public void testContains_Charrange() {
@Test
public void testContainsNullArg() {
final CharRange range = CharRange.is('a');
- final IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> range.contains(null));
+ final NullPointerException e = assertThrows(NullPointerException.class, () -> range.contains(null));
assertEquals("The Range must not be null", e.getMessage());
}
diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
index ae6be1c..49b1a93 100644
--- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java
@@ -200,7 +200,7 @@ public void testIsAsciiPrintable_char() {
public void testToChar_Character() {
assertEquals('A', CharUtils.toChar(CHARACTER_A));
assertEquals('B', CharUtils.toChar(CHARACTER_B));
- assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar((Character) null));
+ assertThrows(NullPointerException.class, () -> CharUtils.toChar((Character) null));
}
@Test
@@ -214,7 +214,7 @@ public void testToChar_Character_char() {
public void testToChar_String() {
assertEquals('A', CharUtils.toChar("A"));
assertEquals('B', CharUtils.toChar("BA"));
- assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar((String) null));
+ assertThrows(NullPointerException.class, () -> CharUtils.toChar((String) null));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar(""));
}
@@ -284,7 +284,7 @@ public void testToIntValue_char_int() {
public void testToIntValue_Character() {
assertEquals(0, CharUtils.toIntValue(Character.valueOf('0')));
assertEquals(3, CharUtils.toIntValue(Character.valueOf('3')));
- assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(null));
+ assertThrows(NullPointerException.class, () -> CharUtils.toIntValue(null));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(CHARACTER_A));
}
diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
index 90e8f51..1e79f45 100644
--- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
@@ -186,13 +186,13 @@ public void test_generateBitVectors_nullIterable() {
@Test
public void test_generateBitVector_nullElement() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> EnumUtils.generateBitVector(Traffic.class, Arrays.asList(Traffic.RED, null)));
}
@Test
public void test_generateBitVectors_nullElement() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> EnumUtils.generateBitVectors(Traffic.class, Arrays.asList(Traffic.RED, null)));
}
diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
index 698962f..a03b459 100644
--- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
@@ -141,12 +141,12 @@ public void testSerializeStreamNullObj() throws Exception {
@Test
public void testSerializeStreamObjNull() {
- assertThrows(IllegalArgumentException.class, () -> SerializationUtils.serialize(iMap, null));
+ assertThrows(NullPointerException.class, () -> SerializationUtils.serialize(iMap, null));
}
@Test
public void testSerializeStreamNullNull() {
- assertThrows(IllegalArgumentException.class, () -> SerializationUtils.serialize(null, null));
+ assertThrows(NullPointerException.class, () -> SerializationUtils.serialize(null, null));
}
@Test
@@ -214,7 +214,7 @@ public void testDeserializeStreamOfNull() throws Exception {
@Test
public void testDeserializeStreamNull() {
- assertThrows(IllegalArgumentException.class, () -> SerializationUtils.deserialize((InputStream) null));
+ assertThrows(NullPointerException.class, () -> SerializationUtils.deserialize((InputStream) null));
}
@Test
@@ -317,7 +317,7 @@ public void testDeserializeBytesOfNull() throws Exception {
@Test
public void testDeserializeBytesNull() {
- assertThrows(IllegalArgumentException.class, () -> SerializationUtils.deserialize((byte[]) null));
+ assertThrows(NullPointerException.class, () -> SerializationUtils.deserialize((byte[]) null));
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java
index 4e8df27..3942ff8 100644
--- a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java
@@ -42,42 +42,42 @@ public class ThreadUtilsTest {
@Test
public void testNullThreadName() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null));
}
@Test
public void testNullThreadGroupName() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadGroupsByName(null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroupsByName(null));
}
@Test
public void testNullThreadThreadGroupName1() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, "tgname"));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, "tgname"));
}
@Test
public void testNullThreadThreadGroupName2() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName("tname", (String) null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName("tname", (String) null));
}
@Test
public void testNullThreadThreadGroupName3() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, (String) null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, (String) null));
}
@Test
public void testNullThreadThreadGroup1() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName("tname", (ThreadGroup) null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName("tname", (ThreadGroup) null));
}
@Test
public void testNullThreadThreadGroup2() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadById(1L, (ThreadGroup) null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadById(1L, (ThreadGroup) null));
}
@Test
public void testNullThreadThreadGroup3() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, (ThreadGroup) null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, (ThreadGroup) null));
}
@Test
@@ -87,24 +87,24 @@ public void testInvalidThreadId() {
@Test
public void testThreadGroupsByIdFail() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> ThreadUtils.findThreadById(Thread.currentThread().getId(), (String) null));
}
@Test
public void testThreadgroupsNullParent() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> ThreadUtils.findThreadGroups(null, true, ThreadUtils.ALWAYS_TRUE_PREDICATE));
}
@Test
public void testThreadgroupsNullPredicate() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadGroups(null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroups(null));
}
@Test
public void testThreadsNullPredicate() {
- assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreads(null));
+ assertThrows(NullPointerException.class, () -> ThreadUtils.findThreads(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java
index 263a50b..a9e62de 100644
--- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java
@@ -308,12 +308,12 @@ public void testLongArray() {
@Test
public void testNullLhs() {
- assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE));
+ assertThrows(NullPointerException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE));
}
@Test
public void testNullRhs() {
- assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE));
+ assertThrows(NullPointerException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE));
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java
index b92b34f..2045f01 100644
--- a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java
@@ -117,19 +117,19 @@ public void testToStringSpecifyStyleOutput() {
@Test
public void testNullLhs() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> new DiffResult(null, SIMPLE_FALSE, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
}
@Test
public void testNullRhs() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> new DiffResult(SIMPLE_TRUE, null, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
}
@Test
public void testNullList() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, null, SHORT_STYLE));
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
index 598f899..d43ea02 100644
--- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java
@@ -180,7 +180,7 @@ public void testReflectionHashCodeEx2() {
@Test
public void testReflectionHashCodeEx3() {
- assertThrows(IllegalArgumentException.class, () -> HashCodeBuilder.reflectionHashCode(13, 19, null, true));
+ assertThrows(NullPointerException.class, () -> HashCodeBuilder.reflectionHashCode(13, 19, null, true));
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java
index 39a926b..b85bd9a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java
@@ -24,7 +24,7 @@ public class ReflectionToStringBuilderTest {
@Test
public void testConstructorWithNullObject() {
- assertThrows(IllegalArgumentException.class,
+ assertThrows(NullPointerException.class,
() -> new ReflectionToStringBuilder(null, ToStringStyle.DEFAULT_STYLE, new StringBuffer()));
}
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
index 647cd2e..4ca52bd 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
@@ -81,7 +81,7 @@ public void testGetSetDefault() {
@Test
public void testSetDefaultEx() {
- assertThrows(IllegalArgumentException.class, () -> ToStringBuilder.setDefaultStyle(null));
+ assertThrows(NullPointerException.class, () -> ToStringBuilder.setDefaultStyle(null));
}
@Test
@@ -1278,7 +1278,7 @@ class InheritedReflectionStaticFieldsFixture extends SimpleReflectionStaticField
@Test
public void testReflectionNull() {
- assertThrows(IllegalArgumentException.class, () -> ReflectionToStringBuilder.toString(null));
+ assertThrows(NullPointerException.class, () -> ReflectionToStringBuilder.toString(null));
}
/**
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
index accef5c..61746cc 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java
@@ -39,7 +39,7 @@ public class CallableBackgroundInitializerTest {
*/
@Test()
public void testInitNullCallable() {
- assertThrows(IllegalArgumentException.class, () -> new CallableBackgroundInitializer<>(null));
+ assertThrows(NullPointerException.class, () -> new CallableBackgroundInitializer<>(null));
}
/**
@@ -64,7 +64,7 @@ public void testInitExecutor() throws InterruptedException {
public void testInitExecutorNullCallable() throws InterruptedException {
final ExecutorService exec = Executors.newSingleThreadExecutor();
try {
- assertThrows(IllegalArgumentException.class, () -> new CallableBackgroundInitializer<Integer>(null, exec));
+ assertThrows(NullPointerException.class, () -> new CallableBackgroundInitializer<Integer>(null, exec));
} finally {
exec.shutdown();
exec.awaitTermination(1, TimeUnit.SECONDS);
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
index 973f72b..e93005b 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializerTest.java
@@ -72,7 +72,7 @@ private void checkChild(final BackgroundInitializer<?> child,
*/
@Test
public void testAddInitializerNullName() {
- assertThrows(IllegalArgumentException.class, () -> initializer.addInitializer(null, new ChildBackgroundInitializer()));
+ assertThrows(NullPointerException.class, () -> initializer.addInitializer(null, new ChildBackgroundInitializer()));
}
/**
@@ -81,7 +81,7 @@ public void testAddInitializerNullName() {
*/
@Test
public void testAddInitializerNullInit() {
- assertThrows(IllegalArgumentException.class, () -> initializer.addInitializer(CHILD_INIT, null));
+ assertThrows(NullPointerException.class, () -> initializer.addInitializer(CHILD_INIT, null));
}
/**
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index 7a4b338..2865056 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -521,7 +521,7 @@ public void testPrintRootCauseStackTrace_ThrowableStream() {
out = new ByteArrayOutputStream(1024);
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null));
out = new ByteArrayOutputStream(1024);
@@ -545,7 +545,7 @@ public void testPrintRootCauseStackTrace_ThrowableWriter() {
writer = new StringWriter(1024);
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null));
writer = new StringWriter(1024);
diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
index 10daae0..ff953cf 100644
--- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
@@ -324,7 +324,7 @@ public void testFactory_double() {
@Test
public void testFactory_String() {
- assertThrows(IllegalArgumentException.class, () -> Fraction.getFraction(null));
+ assertThrows(NullPointerException.class, () -> Fraction.getFraction(null));
}
@@ -741,7 +741,7 @@ public void testAdd() {
assertEquals(13*13*17*2*2, fr.getDenominator());
assertEquals(-17 - 2*13*2, fr.getNumerator());
- assertThrows(IllegalArgumentException.class, () -> fr.add(null));
+ assertThrows(NullPointerException.class, () -> fr.add(null));
// if this fraction is added naively, it will overflow.
// check that it doesn't.
@@ -836,7 +836,7 @@ public void testSubtract() {
assertSame(f2, f);
final Fraction fr = f;
- assertThrows(IllegalArgumentException.class, () -> fr.subtract(null));
+ assertThrows(NullPointerException.class, () -> fr.subtract(null));
// if this fraction is subtracted naively, it will overflow.
// check that it doesn't.
@@ -934,7 +934,7 @@ public void testMultiply() {
assertEquals(1, f.getDenominator());
final Fraction fr = f;
- assertThrows(IllegalArgumentException.class, () -> fr.multiplyBy(null));
+ assertThrows(NullPointerException.class, () -> fr.multiplyBy(null));
final Fraction fr1 = Fraction.getFraction(1, Integer.MAX_VALUE);
assertThrows(ArithmeticException.class, () -> fr1.multiplyBy(fr1));
@@ -979,7 +979,7 @@ public void testDivide() {
assertEquals(Integer.MIN_VALUE, fr.getNumerator());
assertEquals(1, fr.getDenominator());
- assertThrows(IllegalArgumentException.class, () -> fr.divideBy(null));
+ assertThrows(NullPointerException.class, () -> fr.divideBy(null));
final Fraction smallest = Fraction.getFraction(1, Integer.MAX_VALUE);
assertThrows(ArithmeticException.class, () -> smallest.divideBy(smallest.invert())); // Should overflow
diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
index 2caf60b..39fe5cd 100644
--- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
@@ -56,7 +56,7 @@ public void testLang381() {
@Test
public void testEnforceExceptions() {
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> IEEE754rUtils.min( (float[]) null),
"IllegalArgumentException expected for null input");
@@ -66,7 +66,7 @@ public void testEnforceExceptions() {
"IllegalArgumentException expected for empty input");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> IEEE754rUtils.max( (float[]) null),
"IllegalArgumentException expected for null input");
@@ -76,7 +76,7 @@ public void testEnforceExceptions() {
"IllegalArgumentException expected for empty input");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> IEEE754rUtils.min( (double[]) null),
"IllegalArgumentException expected for null input");
@@ -86,7 +86,7 @@ public void testEnforceExceptions() {
"IllegalArgumentException expected for empty input");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> IEEE754rUtils.max( (double[]) null),
"IllegalArgumentException expected for null input");
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 5e5c554..3e32c90 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -686,7 +686,7 @@ protected void testCreateBigDecimalFailure(final String str) {
// ----------------------------------------------------------------------
@Test
public void testMinLong_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((long[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.min((long[]) null));
}
@Test
@@ -705,7 +705,7 @@ public void testMinLong() {
@Test
public void testMinInt_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((int[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.min((int[]) null));
}
@Test
@@ -724,7 +724,7 @@ public void testMinInt() {
@Test
public void testMinShort_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((short[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.min((short[]) null));
}
@Test
@@ -743,7 +743,7 @@ public void testMinShort() {
@Test
public void testMinByte_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((byte[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.min((byte[]) null));
}
@Test
@@ -762,7 +762,7 @@ public void testMinByte() {
@Test
public void testMinDouble_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((double[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.min((double[]) null));
}
@Test
@@ -781,7 +781,7 @@ public void testMinDouble() {
@Test
public void testMinFloat_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((float[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.min((float[]) null));
}
@Test
@@ -800,7 +800,7 @@ public void testMinFloat() {
@Test
public void testMaxLong_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((long[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.max((long[]) null));
}
@Test
@@ -819,7 +819,7 @@ public void testMaxLong() {
@Test
public void testMaxInt_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((int[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.max((int[]) null));
}
@Test
@@ -838,7 +838,7 @@ public void testMaxInt() {
@Test
public void testMaxShort_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((short[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.max((short[]) null));
}
@Test
@@ -857,7 +857,7 @@ public void testMaxShort() {
@Test
public void testMaxByte_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((byte[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.max((byte[]) null));
}
@Test
@@ -876,7 +876,7 @@ public void testMaxByte() {
@Test
public void testMaxDouble_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((double[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.max((double[]) null));
}
@Test
@@ -888,7 +888,7 @@ public void testMaxDouble_emptyArray() {
public void testMaxDouble() {
final double[] d = null;
assertThrows(
- IllegalArgumentException.class, () -> NumberUtils.max(d), "No exception was thrown for null input.");
+ NullPointerException.class, () -> NumberUtils.max(d), "No exception was thrown for null input.");
assertThrows(
IllegalArgumentException.class,
@@ -904,7 +904,7 @@ public void testMaxDouble() {
@Test
public void testMaxFloat_nullArray() {
- assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((float[]) null));
+ assertThrows(NullPointerException.class, () -> NumberUtils.max((float[]) null));
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
index 9db1f80..20ae2ac 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
@@ -106,7 +106,7 @@ public void testGetField() {
@Test
public void testGetFieldIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getField(null, "none"));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getField(null, "none"));
}
@Test
@@ -145,7 +145,7 @@ public void testGetFieldForceAccess() {
@Test
public void testGetFieldForceAccessIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getField(null, "none", true));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getField(null, "none", true));
}
@Test
@@ -214,17 +214,17 @@ public void testGetFieldsWithAnnotation() throws NoSuchFieldException {
@Test
public void testGetFieldsWithAnnotationIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(FieldUtilsTest.class, null));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(FieldUtilsTest.class, null));
}
@Test
public void testGetFieldsWithAnnotationIllegalArgumentException2() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(null, Annotated.class));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(null, Annotated.class));
}
@Test
public void testGetFieldsWithAnnotationIllegalArgumentException3() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(null, null));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(null, null));
}
@Test
@@ -242,17 +242,17 @@ public void testGetFieldsListWithAnnotation() throws NoSuchFieldException {
@Test
public void testGetFieldsListWithAnnotationIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, null));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, null));
}
@Test
public void testGetFieldsListWithAnnotationIllegalArgumentException2() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, Annotated.class));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, Annotated.class));
}
@Test
public void testGetFieldsListWithAnnotationIllegalArgumentException3() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, null));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, null));
}
@Test
@@ -276,7 +276,7 @@ public void testGetDeclaredField() {
@Test
public void testGetDeclaredFieldAccessIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getDeclaredField(null, "none"));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getDeclaredField(null, "none"));
}
@Test
@@ -315,7 +315,7 @@ public void testGetDeclaredFieldForceAccess() {
@Test
public void testGetDeclaredFieldForceAccessIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.getDeclaredField(null, "none", true));
+ assertThrows(NullPointerException.class, () -> FieldUtils.getDeclaredField(null, "none", true));
}
@Test
@@ -340,7 +340,7 @@ public void testReadStaticField() throws Exception {
@Test
public void testReadStaticFieldIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.readStaticField(null));
+ assertThrows(NullPointerException.class, () -> FieldUtils.readStaticField(null));
}
@Test
@@ -359,7 +359,7 @@ public void testReadStaticFieldForceAccess() throws Exception {
@Test
public void testReadStaticFieldForceAccessIllegalArgumentException1() {
- assertThrows(IllegalArgumentException.class, () -> FieldUtils.readStaticField(null, true));
+ assertThrows(NullPointerException.class, () -> FieldUtils.readStaticField(null, true));
}
@Test
@@ -377,7 +377,7 @@ public void testReadNamedStaticField() throws Exception {
assertEquals(Foo.VALUE, FieldUtils.readStaticField(PublicChild.class, "VALUE"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readStaticField(null, "none"),
"null class should cause an IllegalArgumentException");
@@ -397,7 +397,7 @@ public void testReadNamedStaticField() throws Exception {
"blank field name should cause an IllegalArgumentException");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readStaticField(Foo.class, "does_not_exist"),
"a field that doesn't exist should cause an IllegalArgumentException");
@@ -415,7 +415,7 @@ public void testReadNamedStaticFieldForceAccess() throws Exception {
assertEquals("child", FieldUtils.readStaticField(PublicChild.class, "VALUE", true));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readStaticField(null, "none", true),
"null class should cause an IllegalArgumentException");
@@ -435,7 +435,7 @@ public void testReadNamedStaticFieldForceAccess() throws Exception {
"blank field name should cause an IllegalArgumentException");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readStaticField(Foo.class, "does_not_exist", true),
"a field that doesn't exist should cause an IllegalArgumentException");
@@ -449,12 +449,12 @@ public void testReadNamedStaticFieldForceAccess() throws Exception {
public void testReadDeclaredNamedStaticField() throws Exception {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE"));
assertThrows(
- IllegalArgumentException.class, () -> FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE"));
+ NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE"));
}
@@ -463,10 +463,10 @@ public void testReadDeclaredNamedStaticFieldForceAccess() throws Exception {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE", true));
assertEquals("child", FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE", true));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE", true));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE", true));
}
@@ -490,7 +490,7 @@ public void testReadField() throws Exception {
assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readField(null, publicChild),
"a null field should cause an IllegalArgumentException");
}
@@ -519,7 +519,7 @@ public void testReadFieldForceAccess() throws Exception {
assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild, true));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readField(null, publicChild, true),
"a null field should cause an IllegalArgumentException");
}
@@ -546,7 +546,7 @@ public void testReadNamedField() throws Exception {
"a blank field name should cause an IllegalArgumentException");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readField((Object) null, "none"),
"a null target should cause an IllegalArgumentException");
@@ -593,7 +593,7 @@ public void testReadNamedFieldForceAccess() throws Exception {
"a blank field name should cause an IllegalArgumentException");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readField((Object) null, "none", true),
"a null target should cause an IllegalArgumentException");
}
@@ -616,7 +616,7 @@ public void testReadDeclaredNamedField() throws Exception {
"a blank field name should cause an IllegalArgumentException");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readDeclaredField(null, "none"),
"a null target should cause an IllegalArgumentException");
@@ -652,7 +652,7 @@ public void testReadDeclaredNamedFieldForceAccess() throws Exception {
"a blank field name should cause an IllegalArgumentException");
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.readDeclaredField(null, "none", true),
"a null target should cause an IllegalArgumentException");
@@ -731,25 +731,25 @@ public void testWriteNamedStaticField() throws Exception {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePublic", "new");
assertEquals("new", StaticContainer.mutablePublic);
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutableProtected", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePackage", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePrivate", "new"));
assertThrows(
IllegalAccessException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new"));
}
@@ -782,25 +782,25 @@ public void testWriteDeclaredNamedStaticField() throws Exception {
FieldUtils.writeStaticField(StaticContainer.class, "mutablePublic", "new");
assertEquals("new", StaticContainer.mutablePublic);
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutableProtected", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePackage", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePrivate", "new"));
assertThrows(
IllegalAccessException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new"));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new"));
}
diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
index ab40b22..9966efe 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
@@ -868,12 +868,12 @@ public void testGetMethodsWithAnnotationIllegalArgumentException1() {
@Test
public void testGetMethodsWithAnnotationIllegalArgumentException2() {
- assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsWithAnnotation(null, Annotated.class));
+ assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsWithAnnotation(null, Annotated.class));
}
@Test
public void testGetMethodsWithAnnotationIllegalArgumentException3() {
- assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsWithAnnotation(null, null));
+ assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsWithAnnotation(null, null));
}
@Test
@@ -896,12 +896,12 @@ public void testGetMethodsListWithAnnotationIllegalArgumentException1() {
@Test
public void testGetMethodsListWithAnnotationIllegalArgumentException2() {
- assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, Annotated.class));
+ assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, Annotated.class));
}
@Test
public void testGetMethodsListWithAnnotationIllegalArgumentException3() {
- assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, null));
+ assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, null));
}
@Test
@@ -912,12 +912,12 @@ public void testGetAnnotationIllegalArgumentException1() {
@Test
public void testGetAnnotationIllegalArgumentException2() {
- assertThrows(IllegalArgumentException.class, () -> MethodUtils.getAnnotation(null, Annotated.class, true, true));
+ assertThrows(NullPointerException.class, () -> MethodUtils.getAnnotation(null, Annotated.class, true, true));
}
@Test
public void testGetAnnotationIllegalArgumentException3() {
- assertThrows(IllegalArgumentException.class, () -> MethodUtils.getAnnotation(null, null, true, true));
+ assertThrows(NullPointerException.class, () -> MethodUtils.getAnnotation(null, null, true, true));
}
private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls,
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
index 5f65d0e..be6f23b 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
@@ -49,23 +49,23 @@ public void setUp() {
@Test
public void testNullDate() {
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> DateUtils.getFragmentInMilliseconds((Date) null, Calendar.MILLISECOND));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> DateUtils.getFragmentInSeconds((Date) null, Calendar.MILLISECOND));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> DateUtils.getFragmentInMinutes((Date) null, Calendar.MILLISECOND));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> DateUtils.getFragmentInHours((Date) null, Calendar.MILLISECOND));
assertThrows(
- IllegalArgumentException.class,
+ NullPointerException.class,
() -> DateUtils.getFragmentInDays((Date) null, Calendar.MILLISECOND));
}
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
index 64cfde8..14dbf89 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -830,7 +830,7 @@ public void testRound() throws Exception {
DateUtils.round((Object) dateAmPm4, Calendar.AM_PM),
"round ampm-4 failed");
- assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Date) null, Calendar.SECOND));
+ assertThrows(NullPointerException.class, () -> DateUtils.round((Date) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Calendar) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Object) null, Calendar.SECOND));
assertThrows(ClassCastException.class, () -> DateUtils.round("", Calendar.SECOND));
@@ -1111,7 +1111,7 @@ public void testTruncate() throws Exception {
DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM),
"truncate ampm-4 failed");
- assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Date) null, Calendar.SECOND));
+ assertThrows(NullPointerException.class, () -> DateUtils.truncate((Date) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Calendar) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Object) null, Calendar.SECOND));
assertThrows(ClassCastException.class, () -> DateUtils.truncate("", Calendar.SECOND));
@@ -1389,7 +1389,7 @@ public void testCeil() throws Exception {
DateUtils.ceiling((Object) calAmPm4, Calendar.AM_PM),
"ceiling ampm-4 failed");
- assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Date) null, Calendar.SECOND));
+ assertThrows(NullPointerException.class, () -> DateUtils.ceiling((Date) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Calendar) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Object) null, Calendar.SECOND));
assertThrows(ClassCastException.class, () -> DateUtils.ceiling("", Calendar.SECOND));
@@ -1475,7 +1475,7 @@ public void testCeil() throws Exception {
public void testIteratorEx() {
assertThrows(IllegalArgumentException.class, () -> DateUtils.iterator(Calendar.getInstance(), -9999));
assertThrows
- (IllegalArgumentException.class, () -> DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER));
+ (NullPointerException.class, () -> DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER));
assertThrows
(IllegalArgumentException.class, () -> DateUtils.iterator((Calendar) null, DateUtils.RANGE_WEEK_CENTER));
assertThrows