Browse Source

[spotbugs] Fix potential NPE in FS#write

Path#getParent can return null.

Change-Id: I01f13ac426dda4c007cc5caab546a0c9be62ce76
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v5.11.0.202102031030-m2
Matthias Sohn 3 years ago
parent
commit
23bc9dc71d
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

+ 4
- 1
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java View File

@@ -511,7 +511,10 @@ public abstract class FS {
}

private static void write(Path p, String body) throws IOException {
FileUtils.mkdirs(p.getParent().toFile(), true);
Path parent = p.getParent();
if (parent != null) {
FileUtils.mkdirs(parent.toFile(), true);
}
try (Writer w = new OutputStreamWriter(Files.newOutputStream(p),
UTF_8)) {
w.write(body);

Loading…
Cancel
Save