[spotbugs] Fix potential NPE in WorkingTreeIterator#isModified
File#list can return null. Fix the potential NPE by using Files#list which is also faster since it retrieves directory entries lazily while File#list retrieves them eagerly. Change-Id: Idf4bda398861c647587e357326b8bc8b587a2584 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
b1d8e8642f
commit
90b046e7ab
|
@ -25,6 +25,7 @@
|
|||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Instant;
|
||||
|
@ -983,8 +984,9 @@ public boolean isModified(DirCacheEntry entry, boolean forceContentCheck,
|
|||
return true;
|
||||
} else if (ObjectId.zeroId().compareTo(idBuffer,
|
||||
idOffset) == 0) {
|
||||
return new File(repository.getWorkTree(),
|
||||
entry.getPathString()).list().length > 0;
|
||||
Path p = repository.getWorkTree().toPath()
|
||||
.resolve(entry.getPathString());
|
||||
return Files.list(p).findAny().isPresent();
|
||||
}
|
||||
return false;
|
||||
} else if (mode == FileMode.SYMLINK.getBits())
|
||||
|
|
Loading…
Reference in New Issue