Provide an exception message.
MODIFY
src/main/java/org/apache/commons/io/StandardLineSeparator.java
src/main/java/org/apache/commons/io/StandardLineSeparator.java
* @param lineSeparator a non-null line separator.
*/
StandardLineSeparator(final String lineSeparator) {
- this.lineSeparator = Objects.requireNonNull(lineSeparator);
+ this.lineSeparator = Objects.requireNonNull(lineSeparator, "lineSeparator");
}
/**

MODIFY
src/main/java/org/apache/commons/io/filefilter/AndFileFilter.java
src/main/java/org/apache/commons/io/filefilter/AndFileFilter.java
@@ -60,7 +60,7 @@ public AndFileFilter() {
* @param initialList the initial list.
*/
private AndFileFilter(final ArrayList<IOFileFilter> initialList) {
- this.fileFilters = Objects.requireNonNull(initialList);
+ this.fileFilters = Objects.requireNonNull(initialList, "initialList");
}
/**
@@ -104,7 +104,7 @@ public AndFileFilter(final IOFileFilter... fileFilters) {
* @since 1.1
*/
public AndFileFilter(final List<IOFileFilter> fileFilters) {
- this(new ArrayList<>(Objects.requireNonNull(fileFilters)));
+ this(new ArrayList<>(Objects.requireNonNull(fileFilters, "fileFilters")));
}
/**

MODIFY
src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java
src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java
@@ -56,7 +56,7 @@ public OrFileFilter() {
* @param initialList the initial list.
*/
private OrFileFilter(final ArrayList<IOFileFilter> initialList) {
- this.fileFilters = Objects.requireNonNull(initialList);
+ this.fileFilters = Objects.requireNonNull(initialList, "initialList");
}
/**
@@ -99,7 +99,7 @@ public OrFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) {
* @since 1.1
*/
public OrFileFilter(final List<IOFileFilter> fileFilters) {
- this(new ArrayList<>(Objects.requireNonNull(fileFilters)));
+ this(new ArrayList<>(Objects.requireNonNull(fileFilters, "fileFilters")));
}
/**

MODIFY
src/main/java/org/apache/commons/io/function/IOConsumer.java
src/main/java/org/apache/commons/io/function/IOConsumer.java
* @throws NullPointerException if {@code after} is null
*/
default IOConsumer<T> andThen(final IOConsumer<? super T> after) {
- Objects.requireNonNull(after);
+ Objects.requireNonNull(after, "after");
return (final T t) -> {
accept(t);
after.accept(t);

MODIFY
src/main/java/org/apache/commons/io/function/IOFunction.java
src/main/java/org/apache/commons/io/function/IOFunction.java
* @see #andThen(IOFunction)
*/
default <V> IOFunction<V, R> compose(final IOFunction<? super V, ? extends T> before) {
- Objects.requireNonNull(before);
+ Objects.requireNonNull(before, "before");
return (final V v) -> apply(before.apply(v));
}
* @see #andThen(IOFunction)
*/
default <V> IOFunction<V, R> compose(final Function<? super V, ? extends T> before) {
- Objects.requireNonNull(before);
+ Objects.requireNonNull(before, "before");
return (final V v) -> apply(before.apply(v));
}
* @see #andThen(IOFunction)
*/
default IOSupplier<R> compose(final IOSupplier<? extends T> before) {
- Objects.requireNonNull(before);
+ Objects.requireNonNull(before, "before");
return () -> apply(before.get());
}
* @see #andThen(IOFunction)
*/
default IOSupplier<R> compose(final Supplier<? extends T> before) {
- Objects.requireNonNull(before);
+ Objects.requireNonNull(before, "before");
return () -> apply(before.get());
}
* @see #compose(IOFunction)
*/
default <V> IOFunction<T, V> andThen(final IOFunction<? super R, ? extends V> after) {
- Objects.requireNonNull(after);
+ Objects.requireNonNull(after, "after");
return (final T t) -> after.apply(apply(t));
}
* @see #compose(IOFunction)
*/
default <V> IOFunction<T, V> andThen(final Function<? super R, ? extends V> after) {
- Objects.requireNonNull(after);
+ Objects.requireNonNull(after, "after");
return (final T t) -> after.apply(apply(t));
}
* @see #compose(IOFunction)
*/
default IOConsumer<T> andThen(final IOConsumer<? super R> after) {
- Objects.requireNonNull(after);
+ Objects.requireNonNull(after, "after");
return (final T t) -> after.accept(apply(t));
}
* @see #compose(IOFunction)
*/
default IOConsumer<T> andThen(final Consumer<? super R> after) {
- Objects.requireNonNull(after);
+ Objects.requireNonNull(after, "after");
return (final T t) -> after.accept(apply(t));
}

MODIFY
src/main/java/org/apache/commons/io/input/UnsynchronizedByteArrayInputStream.java
src/main/java/org/apache/commons/io/input/UnsynchronizedByteArrayInputStream.java
* @param data the buffer
*/
public UnsynchronizedByteArrayInputStream(final byte[] data) {
- this.data = Objects.requireNonNull(data);
+ this.data = Objects.requireNonNull(data, "data");
this.offset = 0;
this.eod = data.length;
this.markedOffset = this.offset;
@@ -80,7 +80,7 @@ public UnsynchronizedByteArrayInputStream(final byte[] data) {
* @throws IllegalArgumentException if the offset is less than zero
*/
public UnsynchronizedByteArrayInputStream(final byte[] data, final int offset) {
- Objects.requireNonNull(data);
+ Objects.requireNonNull(data, "data");
if (offset < 0) {
throw new IllegalArgumentException("offset cannot be negative");
}
@@ -107,7 +107,7 @@ public UnsynchronizedByteArrayInputStream(final byte[] data, final int offset, f
if (length < 0) {
throw new IllegalArgumentException("length cannot be negative");
}
- this.data = Objects.requireNonNull(data);
+ this.data = Objects.requireNonNull(data, "data");
this.offset = min(offset, data.length > 0 ? data.length : offset);
this.eod = min(this.offset + length, data.length);
this.markedOffset = this.offset;
@@ -125,13 +125,13 @@ public int read() {
@Override
public int read(final byte[] dest) {
- Objects.requireNonNull(dest);
+ Objects.requireNonNull(dest, "dest");
return read(dest, 0, dest.length);
}
@Override
public int read(final byte[] dest, final int off, final int len) {
- Objects.requireNonNull(dest);
+ Objects.requireNonNull(dest, "dest");
if (off < 0 || len < 0 || off + len > dest.length) {
throw new IndexOutOfBoundsException();
}

MODIFY
src/main/java/org/apache/commons/io/input/XmlStreamReader.java
src/main/java/org/apache/commons/io/input/XmlStreamReader.java
@@ -141,7 +141,7 @@ public String getDefaultEncoding() {
* @throws IOException thrown if there is a problem reading the file.
*/
public XmlStreamReader(final File file) throws IOException {
- this(new FileInputStream(Objects.requireNonNull(file)));
+ this(new FileInputStream(Objects.requireNonNull(file, "file")));
}
/**

MODIFY
src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java
src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java
@@ -87,7 +87,7 @@ public byte read() {
* exception.
*/
public void read(final byte[] targetBuffer, final int targetOffset, final int length) {
- Objects.requireNonNull(targetBuffer);
+ Objects.requireNonNull(targetBuffer, "targetBuffer");
if (targetOffset < 0 || targetOffset >= targetBuffer.length) {
throw new IllegalArgumentException("Invalid offset: " + targetOffset);
}

Provide an exception message.