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 2021/01/11 16:07:15 UTC

[commons-io] branch master updated (1c441b9 -> 1c1e493)

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 1c441b9  Javadoc.
     new ffb46b8  Fix NPE compiler warning by short circuit.
     new 1c1e493  Better exception message.

The 2 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/main/java/org/apache/commons/io/file/PathUtils.java | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)


[commons-io] 01/02: Fix NPE compiler warning by short circuit.

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 ffb46b826ae5aa82fcc337133e758dca4d5b2dd1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 11 10:59:28 2021 -0500

    Fix NPE compiler warning by short circuit.
---
 src/main/java/org/apache/commons/io/file/PathUtils.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 3a2fb69..fc53109 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -525,7 +525,7 @@ public final class PathUtils {
         if (path1 == null && path2 == null) {
             return true;
         }
-        if (path1 == null ^ path2 == null) {
+        if (path1 == null || path2 == null) {
             return false;
         }
         if (!Files.exists(path1) && !Files.exists(path2)) {
@@ -621,7 +621,7 @@ public final class PathUtils {
         if (path1 == null && path2 == null) {
             return true;
         }
-        if (path1 == null ^ path2 == null) {
+        if (path1 == null || path2 == null) {
             return false;
         }
         final Path nPath1 = path1.normalize();


[commons-io] 02/02: Better exception message.

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 1c1e493b527238852762f13b356c6ab38e0daae2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 11 11:03:29 2021 -0500

    Better exception message.
---
 src/main/java/org/apache/commons/io/file/PathUtils.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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 fc53109..69e8713 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -868,15 +868,15 @@ public final class PathUtils {
      * @since 2.8.0
      */
     public static Path setReadOnly(final Path path, final boolean readOnly, final LinkOption... linkOptions)
-        throws IOException {
+            throws IOException {
         final DosFileAttributeView fileAttributeView = Files.getFileAttributeView(path, DosFileAttributeView.class,
-            linkOptions);
+                linkOptions);
         if (fileAttributeView != null) {
             fileAttributeView.setReadOnly(readOnly);
             return path;
         }
         final PosixFileAttributeView posixFileAttributeView = Files.getFileAttributeView(path,
-            PosixFileAttributeView.class, linkOptions);
+                PosixFileAttributeView.class, linkOptions);
         if (posixFileAttributeView != null) {
             // Works on Windows but not on Ubuntu:
             // Files.setAttribute(path, "unix:readonly", readOnly, options);
@@ -888,7 +888,9 @@ public final class PathUtils {
             permissions.remove(PosixFilePermission.OTHERS_WRITE);
             return Files.setPosixFilePermissions(path, permissions);
         }
-        throw new IOException("No DosFileAttributeView or PosixFileAttributeView for " + path);
+        throw new IOException(
+                String.format("No DosFileAttributeView or PosixFileAttributeView for '%s' (linkOptions=%s)", path,
+                        Arrays.toString(linkOptions)));
     }
 
     /**