Skip to content

Commit d9e154a

Browse files
Sebastiangarydgregory
authored andcommitted
Remove throws IOException in method isSymlink() (#80)
* Remove throws IOException in method isSymlink() The IOException is caught in 'Files.isSymbolicLink(Path path)' and therefore not thrown anymore in 'public static boolean isSymlink(final File file)'. * Update FileUtils.java Remove some not thrown IOExceptions * Update FileUtils.java Remove some not thrown IOExceptions
1 parent 7c88a63 commit d9e154a

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,15 +2683,11 @@ private static long sizeOfDirectory0(final File directory) {
26832683
long size = 0;
26842684

26852685
for (final File file : files) {
2686-
try {
2687-
if (!isSymlink(file)) {
2688-
size += sizeOf0(file); // internal method
2689-
if (size < 0) {
2690-
break;
2691-
}
2686+
if (!isSymlink(file)) {
2687+
size += sizeOf0(file); // internal method
2688+
if (size < 0) {
2689+
break;
26922690
}
2693-
} catch (final IOException ioe) {
2694-
// Ignore exceptions caught when asking if a File is a symlink.
26952691
}
26962692
}
26972693

@@ -2741,12 +2737,8 @@ private static BigInteger sizeOfDirectoryBig0(final File directory) {
27412737
BigInteger size = BigInteger.ZERO;
27422738

27432739
for (final File file : files) {
2744-
try {
2745-
if (!isSymlink(file)) {
2746-
size = size.add(sizeOfBig0(file));
2747-
}
2748-
} catch (final IOException ioe) {
2749-
// Ignore exceptions caught when asking if a File is a symlink.
2740+
if (!isSymlink(file)) {
2741+
size = size.add(sizeOfBig0(file));
27502742
}
27512743
}
27522744

@@ -3161,10 +3153,9 @@ private static void validateMoveParameters(final File src, final File dest) thro
31613153
* {@code boolean java.nio.file.Files.isSymbolicLink(Path path)}
31623154
* @param file the file to check
31633155
* @return true if the file is a Symbolic Link
3164-
* @throws IOException if an IO error occurs while checking the file
31653156
* @since 2.0
31663157
*/
3167-
public static boolean isSymlink(final File file) throws IOException {
3158+
public static boolean isSymlink(final File file) {
31683159
if (file == null) {
31693160
throw new NullPointerException("File must not be null");
31703161
}

0 commit comments

Comments
 (0)