]> source.dussan.org Git - jgit.git/commitdiff
[findBugs] Fix potential NPE in GC 82/87782/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 28 Dec 2016 23:58:40 +0000 (00:58 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 28 Dec 2016 23:59:33 +0000 (00:59 +0100)
Change-Id: I59cda76b2c5039e08612f394ee4f7f1788578c49
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index 147e54dce82dc0b9a7e56e4a6a72daf4dfbeb8a3..560db924013cf677c9a9ddc6c9dffb26fce2dfc6 100644 (file)
@@ -1204,9 +1204,10 @@ public class GC {
                                new DirectoryStream.Filter<Path>() {
 
                                        public boolean accept(Path file) throws IOException {
-                                               return Files.isRegularFile(file) && PATTERN_LOOSE_OBJECT
-                                                               .matcher(file.getFileName().toString())
-                                                               .matches();
+                                               Path fileName = file.getFileName();
+                                               return Files.isRegularFile(file) && fileName != null
+                                                               && PATTERN_LOOSE_OBJECT
+                                                                               .matcher(fileName.toString()).matches();
                                        }
                                })) {
                        for (Iterator<Path> iter = stream.iterator(); iter.hasNext();