garydgregory commented on a change in pull request #196:
URL: https://github.com/apache/commons-io/pull/196#discussion_r566371592



##########
File path: src/main/java/org/apache/commons/io/FileDeleteStrategy.java
##########
@@ -144,6 +147,7 @@ public boolean deleteQuietly(final File fileToDelete) {
      * @throws IOException if an error occurs during file deletion
      */
     protected boolean doDelete(final File file) throws IOException {
+        Objects.requireNonNull(file,"file");

Review comment:
       Fix formatting.
   

##########
File path: src/main/java/org/apache/commons/io/FileSystemUtils.java
##########
@@ -271,9 +272,8 @@ public static long freeSpaceKb(final long timeout) throws 
IOException {
      * @throws IOException if an error occurs when finding the free space
      */
     long freeSpaceOS(final String path, final int os, final boolean kb, final 
long timeout) throws IOException {
-        if (path == null) {
-            throw new IllegalArgumentException("Path must not be null");
-        }
+        Objects.requireNonNull(path,"path");

Review comment:
       Fix formatting.

##########
File path: src/main/java/org/apache/commons/io/FileSystemUtils.java
##########
@@ -396,6 +396,7 @@ long parseDir(final String line, final String path) throws 
IOException {
      */
     long freeSpaceUnix(final String path, final boolean kb, final boolean 
posix, final long timeout)
             throws IOException {
+        Objects.requireNonNull(path,"path");

Review comment:
       Fix formatting.

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -340,6 +341,7 @@ public static void cleanDirectory(final File directory) 
throws IOException {
      * @see #forceDeleteOnExit(File)
      */
     private static void cleanDirectoryOnExit(final File directory) throws 
IOException {
+        Objects.requireNonNull(directory, "directory");

Review comment:
       -1: no need, already done on the next line in `listFiles`.

##########
File path: src/main/java/org/apache/commons/io/FilenameUtils.java
##########
@@ -1510,6 +1510,9 @@ public static boolean wildcardMatch(final String 
fileName, final String wildcard
      * @return true if the given name is a valid host name
      */
     private static boolean isValidHostName(final String name) {
+        if(Objects.isNull(name)) {

Review comment:
       Fix formatting and no need to call an API meant for use in lambdas when 
`name == null` would do.
   

##########
File path: 
src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
##########
@@ -200,12 +201,9 @@ public FileAlterationObserver(final File directory, final 
FileFilter fileFilter,
      */
     protected FileAlterationObserver(final FileEntry rootEntry, final 
FileFilter fileFilter,
                                      final IOCase caseSensitivity) {
-        if (rootEntry == null) {
-            throw new IllegalArgumentException("Root entry is missing");
-        }
-        if (rootEntry.getFile() == null) {
-            throw new IllegalArgumentException("Root directory is missing");
-        }
+        Objects.requireNonNull(rootEntry, "rootEntry");
+        Objects.requireNonNull(rootEntry.getFile(),"rootDirectory");

Review comment:
       Fix formatting.
   

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -866,6 +868,8 @@ public static void copyFile(final File srcFile, final File 
destFile, final CopyO
      * @since 2.1
      */
     public static long copyFile(final File input, final OutputStream output) 
throws IOException {
+        Objects.requireNonNull(input, "input");
+        Objects.requireNonNull(output, "output");

Review comment:
       -1: no need to check on `output`, this already done in `copyLarge`.
   
   I'll stop this type of comment since these checks over the top in this PR. 
IOW, let's not check for NPEs when we do not need to.
   

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -314,6 +314,7 @@ public static long checksumCRC32(final File file) throws 
IOException {
      * @see #forceDelete(File)
      */
     public static void cleanDirectory(final File directory) throws IOException 
{
+        Objects.requireNonNull(directory, "directory");

Review comment:
       -1: no need, already done on the next line in `listFiles`.

##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1200,6 +1210,7 @@ public static void deleteDirectory(final File directory) 
throws IOException {
      * @throws IOException          in case deletion is unsuccessful
      */
     private static void deleteDirectoryOnExit(final File directory) throws 
IOException {
+        Objects.requireNonNull(directory,"directory");

Review comment:
       Fix formatting.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to