Browse Source

[spotbugs]: Fix potential NPE in FileSnapshot constructor

File#getParent can return null which caused this spotbugs warning.

FS.FileStoreAttributes#get already gets the parent directory if the
passed File is not a directory and checks for null. Hence there is no
need to get the parent directory in the FileSnapshot constructor.

Change-Id: I77f71503cffb05970ab8d9ba55b69c96c53098b9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v5.11.0.202102031030-m2
Matthias Sohn 3 years ago
parent
commit
ef04b3b883

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java View File

@@ -223,7 +223,7 @@ public class FileSnapshot {
this.file = file;
this.lastRead = Instant.now();
this.fileStoreAttributeCache = useConfig
? FS.getFileStoreAttributes(file.toPath().getParent())
? FS.getFileStoreAttributes(file.toPath())
: FALLBACK_FILESTORE_ATTRIBUTES;
BasicFileAttributes fileAttributes = null;
try {

Loading…
Cancel
Save