summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-12-04 09:40:47 +0100
committerChristian Halstrick <christian.halstrick@sap.com>2020-12-17 18:42:00 +0100
commit23bc9dc71dac196b9db6154a93d21d68c0a0bb06 (patch)
treeb19a8c8ec9edf86c44b57e49deb23b67aee96978
parent1ed6353962296a3f70d6673d68dc4784f2766c4e (diff)
downloadjgit-23bc9dc71dac196b9db6154a93d21d68c0a0bb06.tar.gz
jgit-23bc9dc71dac196b9db6154a93d21d68c0a0bb06.zip
[spotbugs] Fix potential NPE in FS#write
Path#getParent can return null. Change-Id: I01f13ac426dda4c007cc5caab546a0c9be62ce76 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index d8cab358e7..874bfe8735 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -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);