[spotbugs] Fix potential NPE in FileRepository#convertToReftable
File#listFiles can return null. Use Files#list which does not return null and should be faster since it's returning directory entries lazily while File#listFiles fetches them eagerly. Change-Id: I3bfe2a52278244fc469143692c06b05d9af0d0d4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
15998622fa
commit
a2bb540f29
|
@ -21,6 +21,7 @@
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -727,7 +728,8 @@ void convertToReftable(boolean writeLogs, boolean backup)
|
|||
throws IOException {
|
||||
File reftableDir = new File(getDirectory(), Constants.REFTABLE);
|
||||
File headFile = new File(getDirectory(), Constants.HEAD);
|
||||
if (reftableDir.exists() && reftableDir.listFiles().length > 0) {
|
||||
if (reftableDir.exists()
|
||||
&& Files.list(reftableDir.toPath()).findAny().isPresent()) {
|
||||
throw new IOException(JGitText.get().reftableDirExists);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue