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-io.git


The following commit(s) were added to refs/heads/master by this push:
     new c5ca539  Reuse IOUtils.length(Object[]).
c5ca539 is described below

commit c5ca539caf5cadb388ad1692cfdb2bf2f143c862
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Mon Jan 25 17:56:25 2021 -0500

    Reuse IOUtils.length(Object[]).
---
 src/main/java/org/apache/commons/io/FileUtils.java                  | 2 +-
 src/main/java/org/apache/commons/io/file/StandardDeleteOption.java  | 4 +++-
 src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java 
b/src/main/java/org/apache/commons/io/FileUtils.java
index 389653f..3b88aa3 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -2936,7 +2936,7 @@ public class FileUtils {
      * @since 1.1
      */
     public static File[] toFiles(final URL... urls) {
-        if (urls == null || urls.length == 0) {
+        if (IOUtils.length(urls) == 0) {
             return EMPTY_FILE_ARRAY;
         }
         final File[] files = new File[urls.length];
diff --git a/src/main/java/org/apache/commons/io/file/StandardDeleteOption.java 
b/src/main/java/org/apache/commons/io/file/StandardDeleteOption.java
index e7343cb..7dd3f73 100644
--- a/src/main/java/org/apache/commons/io/file/StandardDeleteOption.java
+++ b/src/main/java/org/apache/commons/io/file/StandardDeleteOption.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.io.file;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * Defines the standard delete options.
  *
@@ -38,7 +40,7 @@ public enum StandardDeleteOption implements DeleteOption {
      * @return true if the given options contain {@link 
StandardDeleteOption#OVERRIDE_READ_ONLY}.
      */
     public static boolean overrideReadOnly(final DeleteOption[] options) {
-        if (options == null || options.length == 0) {
+        if (IOUtils.length(options) == 0) {
             return false;
         }
         for (final DeleteOption deleteOption : options) {
diff --git 
a/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java 
b/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java
index ee7d4c9..83c673b 100644
--- a/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java
+++ b/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java
@@ -25,6 +25,8 @@ import java.nio.file.Path;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.stream.Stream;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * This filter accepts files or directories that are empty.
  * <p>
@@ -101,7 +103,7 @@ public class EmptyFileFilter extends AbstractFileFilter 
implements Serializable
     public boolean accept(final File file) {
         if (file.isDirectory()) {
             final File[] files = file.listFiles();
-            return files == null || files.length == 0;
+            return IOUtils.length(files) == 0;
         }
         return file.length() == 0;
     }

Reply via email to