CloneCommand: Refactor listing of files in deleteChildren
File.listFiles() returns null if the given File does not represent a directory, so we can just test for null instead of making a separate call to FS.DETECTED.isDirectory() This also avoids a false-positive error from SpotBugs which claims that there is a potential null-pointer exception on dereferencing the result of Files.listFiles(). Change-Id: I18e09e391011db997470f5a09d8e38bb604c0213 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
fdacfaecc4
commit
0e5b9f8a39
|
@ -77,7 +77,6 @@
|
|||
import org.eclipse.jgit.transport.RemoteConfig;
|
||||
import org.eclipse.jgit.transport.TagOpt;
|
||||
import org.eclipse.jgit.transport.URIish;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
import org.eclipse.jgit.util.FileUtils;
|
||||
|
||||
/**
|
||||
|
@ -681,10 +680,11 @@ private void cleanup() {
|
|||
}
|
||||
|
||||
private void deleteChildren(File file) throws IOException {
|
||||
if (!FS.DETECTED.isDirectory(file)) {
|
||||
File[] files = file.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
for (File child : file.listFiles()) {
|
||||
for (File child : files) {
|
||||
FileUtils.delete(child, FileUtils.RECURSIVE | FileUtils.SKIP_MISSING
|
||||
| FileUtils.IGNORE_ERRORS);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue