diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-12-04 23:41:19 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-12-22 10:53:00 +0100 |
commit | bceb202319b6f2b02b15f32db5c40a912e4bd1f3 (patch) | |
tree | e318bf3c891414cb35e54b7b460026b3f90be708 /org.eclipse.jgit/src/org/eclipse | |
parent | d7b94f019449a8d5210b3bdd8dc439d508d227d5 (diff) | |
download | jgit-bceb202319b6f2b02b15f32db5c40a912e4bd1f3.tar.gz jgit-bceb202319b6f2b02b15f32db5c40a912e4bd1f3.zip |
[spotbugs] Fix potential NPE in FS.FileStoreAttributes#get
Path#getParent can return null, return fallback filestore attributes in
that case.
Change-Id: Ic09484d527bc87b27964b625e07373b82412f2da
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 3 |
1 files changed, 3 insertions, 0 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 874bfe8735..c80a3a4b7f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -337,6 +337,9 @@ public abstract class FS { try { path = path.toAbsolutePath(); Path dir = Files.isDirectory(path) ? path : path.getParent(); + if (dir == null) { + return FALLBACK_FILESTORE_ATTRIBUTES; + } FileStoreAttributes cached = attrCacheByPath.get(dir); if (cached != null) { return cached; |