PackInserterTest: Prevent potential NPE dereferencing Path.getFileName()
Path.getFileName() may return null if the path has zero elements. Enclose the dereference in a null-check. Change-Id: I7ea3d3f07edc13a80b593d28e8fd512a4e1ed56b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
0e5b9f8a39
commit
c861c0e2ee
|
@ -529,9 +529,12 @@ void assertNoBadFiles(File f) throws IOException {
|
|||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
String name = file.getFileName().toString();
|
||||
if (!attrs.isDirectory() && badName.test(name)) {
|
||||
bad.add(name);
|
||||
Path fileName = file.getFileName();
|
||||
if (fileName != null) {
|
||||
String name = fileName.toString();
|
||||
if (!attrs.isDirectory() && badName.test(name)) {
|
||||
bad.add(name);
|
||||
}
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue