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 f382ada  Null-guard IOUtils.close(Closeable, IOConsumer).
f382ada is described below

commit f382ada1a767b9198fb9adf8cd2260a68cd6b8cd
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Aug 7 09:27:12 2020 -0400

    Null-guard IOUtils.close(Closeable, IOConsumer).
---
 src/changes/changes.xml                          | 3 +++
 src/main/java/org/apache/commons/io/IOUtils.java | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index df461c5..bd2f091 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -89,6 +89,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add PathUtils.getAclEntryList(Path).
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        Null-guard IOUtils.close(Closeable, IOConsumer).
+      </action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         Replace FindBugs with SpotBugs.
       </action>
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java 
b/src/main/java/org/apache/commons/io/IOUtils.java
index a9b1122..73a2bb9 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -372,9 +372,11 @@ public class IOUtils {
      * @since 2.7
      */
     public static void close(final Closeable... closeables) throws IOException 
{
-            for(Closeable closeable : closeables) {
+        if (closeables != null) {
+            for (Closeable closeable : closeables) {
                 if (closeable != null) {
                     closeable.close();
+                }
             }
         }
     }

Reply via email to