You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/02 17:37:30 UTC

[commons-io] branch master updated (d6da6b2a -> 12a19412)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


    from d6da6b2a Better exception message
     new 3c352e20 Stay compatible with 2.12.0
     new c7d957d7 Add PathUtils.EMPTY_FILE_ATTRIBUTE_ARRAY
     new 12a19412 [IO-798] DeferredFileOutputStream throws exception when system temp dir is a symlink

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                                           | 6 ++++++
 src/main/java/org/apache/commons/io/IOUtils.java                  | 8 +++++++-
 src/main/java/org/apache/commons/io/file/PathUtils.java           | 7 +++++++
 .../org/apache/commons/io/output/DeferredFileOutputStream.java    | 2 +-
 4 files changed, 21 insertions(+), 2 deletions(-)


[commons-io] 03/03: [IO-798] DeferredFileOutputStream throws exception when system temp dir is a symlink

Posted by gg...@apache.org.
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

commit 12a19412a7373b5415bd1f9d79dc4334c29434b3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 2 13:37:25 2023 -0400

    [IO-798] DeferredFileOutputStream throws exception when system temp dir
    is a symlink
---
 src/changes/changes.xml                                                | 3 +++
 .../java/org/apache/commons/io/output/DeferredFileOutputStream.java    | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 645c5cd8..5826c514 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,6 +67,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         Only read the relevant portion of a file in AbstractOrigin.PathOrigin.getByteArray(long, int)
       </action>
+      <action dev="ggregory" type="fix" due-to="Shai Shapira, Gary Gregory" issue="IO-798">
+        DeferredFileOutputStream throws exception when system temp dir is a symlink.
+      </action>
       <!-- ADD -->
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add CharSequenceInputStream.Builder.
diff --git a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
index 66a3cabf..78bc4b9c 100644
--- a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
@@ -342,7 +342,7 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream {
         if (prefix != null) {
             outputPath = Files.createTempFile(directory, prefix, suffix);
         }
-        PathUtils.createParentDirectories(outputPath);
+        PathUtils.createParentDirectories(outputPath, null, PathUtils.EMPTY_FILE_ATTRIBUTE_ARRAY);
         final OutputStream fos = Files.newOutputStream(outputPath);
         try {
             memoryOutputStream.writeTo(fos);


[commons-io] 02/03: Add PathUtils.EMPTY_FILE_ATTRIBUTE_ARRAY

Posted by gg...@apache.org.
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

commit c7d957d7eaab0422511aa17d92b44c6c3fd05134
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 2 13:36:03 2023 -0400

    Add PathUtils.EMPTY_FILE_ATTRIBUTE_ARRAY
---
 src/changes/changes.xml                                 | 3 +++
 src/main/java/org/apache/commons/io/file/PathUtils.java | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index eff21635..645c5cd8 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 AbstractOrigin.size().
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        PathUtils.EMPTY_FILE_ATTRIBUTE_ARRAY.
+      </action>
       <!-- UPDATE -->
       <action dev="ggregory" type="update" due-to="Gary Gregory, Dependabot">
         Bump commons-parent from 57 to 58.
diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 9d7984de..1c6bd0d6 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -166,6 +166,13 @@ public final class PathUtils {
      */
     public static final DeleteOption[] EMPTY_DELETE_OPTION_ARRAY = {};
 
+    /**
+     * Empty {@link FileAttribute} array.
+     *
+     * @since 2.13.0
+     */
+    public static final FileAttribute<?>[] EMPTY_FILE_ATTRIBUTE_ARRAY = {};
+
     /**
      * Empty {@link FileVisitOption} array.
      */


[commons-io] 01/03: Stay compatible with 2.12.0

Posted by gg...@apache.org.
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

commit 3c352e208d90c37ceca371920ead1bb80fa83229
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 2 13:35:27 2023 -0400

    Stay compatible with 2.12.0
---
 src/main/java/org/apache/commons/io/IOUtils.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java
index 160bb176..a8d8ffb2 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -1926,6 +1926,9 @@ public class IOUtils {
      */
     public static int read(final InputStream input, final byte[] buffer, final int offset, final int length)
             throws IOException {
+        if (length == 0) {
+            return 0;
+        }
         return read(input::read, buffer, offset, length);
     }
 
@@ -2659,7 +2662,10 @@ public class IOUtils {
      * @since 2.1
      */
     public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
-        return toByteArray(input::read, size);
+        if (size == 0) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        return toByteArray(Objects.requireNonNull(input, "input")::read, size);
     }
 
     /**