PMD: ignore empty catch block
MODIFY
src/main/java/org/apache/commons/io/FileUtils.java
src/main/java/org/apache/commons/io/FileUtils.java
@@ -1157,7 +1157,7 @@ static String decodeUrl(final String url) {
i += 3;
} while (i < n && url.charAt(i) == '%');
continue;
- } catch (final RuntimeException e) {
+ } catch (final RuntimeException ignored) {
// malformed percent-encoded octet, fall through and
// append characters literally
} finally {

MODIFY
src/main/java/org/apache/commons/io/file/DeletingPathVisitor.java
src/main/java/org/apache/commons/io/file/DeletingPathVisitor.java
@@ -163,7 +163,7 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr
try {
// deleteIfExists does not work for this case
Files.delete(file);
- } catch (final NoSuchFileException e) {
+ } catch (final NoSuchFileException ignored) {
// ignore
}
}

MODIFY
src/main/java/org/apache/commons/io/file/PathUtils.java
src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -537,7 +537,7 @@ public static PathCounters deleteFile(final Path file, final LinkOption[] linkOp
pathCounts.getByteCounter().add(size);
return pathCounts;
}
- } catch (final AccessDeniedException e) {
+ } catch (final AccessDeniedException ignored) {
// Ignore and try again below.
}
final Path parent = getParent(file);
@@ -1436,7 +1436,7 @@ public static Path setReadOnly(final Path path, final boolean readOnly, final Li
if (setDosReadOnly(path, readOnly, linkOptions)) {
return path;
}
- } catch (final IOException e) {
+ } catch (final IOException ignored) {
// Retry with POSIX below.
}
final Path parent = getParent(path);

MODIFY
src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java
src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java
@@ -264,7 +264,7 @@ public boolean accept(final File file) {
return Arrays.equals(this.magicNumbers, fileBytes);
}
}
- catch (final IOException ioe) {
+ catch (final IOException ignored) {
// Do nothing, fall through and do not accept file
}
}
@@ -301,7 +301,7 @@ public FileVisitResult accept(final Path file, final BasicFileAttributes attribu
return toFileVisitResult(Arrays.equals(this.magicNumbers, byteBuffer.array()));
}
}
- catch (final IOException ioe) {
+ catch (final IOException ignored) {
// Do nothing, fall through and do not accept file
}
}

MODIFY
src/main/java/org/apache/commons/io/input/ReadAheadInputStream.java
src/main/java/org/apache/commons/io/input/ReadAheadInputStream.java
@@ -227,8 +227,8 @@ private void closeUnderlyingInputStreamIfNecessary() {
if (needToCloseUnderlyingInputStream) {
try {
underlyingInputStream.close();
- } catch (final IOException e) {
- // TODO ?
+ } catch (final IOException ignored) {
+ // TODO Rethrow as UncheckedIOException?
}
}
}

PMD: ignore empty catch block