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 b9efbe5d [IO-800] Fix back-incompatible change for PathUtils.deleteDirectory(): throw NoSuchFileException instead of IllegalArgumentException (#459) b9efbe5d is described below commit b9efbe5d2667fdbfbe4edd8ce6df5aec29ab215d Author: Jan Høydahl <jan...@users.noreply.github.com> AuthorDate: Thu Jun 8 20:01:32 2023 +0200 [IO-800] Fix back-incompatible change for PathUtils.deleteDirectory(): throw NoSuchFileException instead of IllegalArgumentException (#459) * IO-800: Fix back-incompatible change for deleteDirectory on nonexisting path * Bring back test method delete by mistake * Update Javadoc --------- Co-authored-by: Gary Gregory <garydgreg...@users.noreply.github.com> --- src/main/java/org/apache/commons/io/file/PathUtils.java | 2 +- .../java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java | 3 ++- 2 files changed, 3 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 1c6bd0d6..56b2a05c 100644 --- a/src/main/java/org/apache/commons/io/file/PathUtils.java +++ b/src/main/java/org/apache/commons/io/file/PathUtils.java @@ -1646,11 +1646,11 @@ public final class PathUtils { * @param <T> See {@link Files#walkFileTree(Path,FileVisitor)}. * @return the given visitor. * + * @throws NoSuchFileException if the directory does not exist. * @throws IOException if an I/O error is thrown by a visitor method. * @throws NullPointerException if the directory is {@code null}. */ public static <T extends FileVisitor<? super Path>> T visitFileTree(final T visitor, final Path directory) throws IOException { - requireExists(directory, "directory"); Files.walkFileTree(directory, visitor); return visitor; } diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java index 298e24c9..a22630d4 100644 --- a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java +++ b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; @@ -37,7 +38,7 @@ public class PathUtilsDeleteDirectoryTest extends AbstractTempDirTest { public void testDeleteAbsentDirectory() throws IOException { final Path absent = tempDirPath.resolve("ThisDirectoryDoesNotExist"); assertFalse(Files.exists(absent)); - final Class<IllegalArgumentException> expectedType = IllegalArgumentException.class; + final Class<NoSuchFileException> expectedType = NoSuchFileException.class; assertThrows(expectedType, () -> PathUtils.deleteDirectory(absent)); assertThrows(expectedType, () -> PathUtils.deleteDirectory(absent, StandardDeleteOption.OVERRIDE_READ_ONLY)); assertThrows(expectedType, () -> PathUtils.deleteDirectory(absent, PathUtils.EMPTY_DELETE_OPTION_ARRAY));