Skip to content

Commit 0fa5a39

Browse files
committed
Avoid possible NPEs.
1 parent b2165b7 commit 0fa5a39

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/org/apache/commons/io/file/CleaningPathVisitor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Path;
2424
import java.nio.file.attribute.BasicFileAttributes;
2525
import java.util.Arrays;
26+
import java.util.Objects;
2627

2728
import org.apache.commons.io.file.Counters.PathCounters;
2829

@@ -73,7 +74,7 @@ public CleaningPathVisitor(final PathCounters pathCounter, final String... skip)
7374
* @return true to process the given path, false if not.
7475
*/
7576
private boolean accept(final Path path) {
76-
return Arrays.binarySearch(skip, path.getFileName().toString()) < 0;
77+
return Arrays.binarySearch(skip, Objects.toString(path.getFileName(), null)) < 0;
7778
}
7879

7980
@Override

src/main/java/org/apache/commons/io/file/DeletingPathVisitor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Path;
2424
import java.nio.file.attribute.BasicFileAttributes;
2525
import java.util.Arrays;
26+
import java.util.Objects;
2627

2728
import org.apache.commons.io.file.Counters.PathCounters;
2829

@@ -75,7 +76,7 @@ public DeletingPathVisitor(final PathCounters pathCounter, final String... skip)
7576
* @return true to process the given path, false if not.
7677
*/
7778
private boolean accept(final Path path) {
78-
return Arrays.binarySearch(skip, path.getFileName().toString()) < 0;
79+
return Arrays.binarySearch(skip, Objects.toString(path.getFileName(), null)) < 0;
7980
}
8081

8182
@Override

0 commit comments

Comments
 (0)