Skip to content

Commit 5cc33ba

Browse files
committed
fix(apply-tags-from-csv): guard against null return from Path.getFileName()
Path.getFileName() returns null for filesystem root paths; skip such paths instead of dereferencing the result (fixes SpotBugs NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE).
1 parent c83b1e2 commit 5cc33ba

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/java/org/egothor/methodatlas/ApplyTagsFromCsvEngine.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,11 @@ private static Map<Path, List<MethodKey>> buildSourceIndex(List<Path> roots,
317317
}
318318
try (java.util.stream.Stream<Path> stream = Files.walk(root)) {
319319
for (Path path : (Iterable<Path>) stream.filter(Files::isRegularFile)::iterator) {
320-
String name = path.getFileName().toString();
320+
Path fileNamePath = path.getFileName();
321+
if (fileNamePath == null) {
322+
continue;
323+
}
324+
String name = fileNamePath.toString();
321325
if (fileSuffixes.stream().noneMatch(name::endsWith)) {
322326
continue;
323327
}

0 commit comments

Comments
 (0)