]> source.dussan.org Git - jgit.git/commitdiff
[spotbugs] Fix potential NPE in FS.FileStoreAttributes#get 25/173425/6
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 4 Dec 2020 22:41:19 +0000 (23:41 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 22 Dec 2020 09:53:00 +0000 (10:53 +0100)
Path#getParent can return null, return fallback filestore attributes in
that case.

Change-Id: Ic09484d527bc87b27964b625e07373b82412f2da
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

index 874bfe87353f8ada301dbbe67fb4c248c41358d1..c80a3a4b7f02b51b24f538465c3cef6fbecf33b8 100644 (file)
@@ -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;