summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-12-08 17:13:10 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2017-12-08 17:16:34 +0900
commit0e5b9f8a39a955a58f39466264afed372b27aaa2 (patch)
treee7f3f5df5ebba7bc29999f38573881290ae9540f
parentfdacfaecc43e573feaf31dcb4ab26e3469868618 (diff)
downloadjgit-0e5b9f8a39a955a58f39466264afed372b27aaa2.tar.gz
jgit-0e5b9f8a39a955a58f39466264afed372b27aaa2.zip
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>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
index bde8e63d1d..cd099aa64f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
@@ -77,7 +77,6 @@ import org.eclipse.jgit.transport.RefSpec;
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 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
}
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);
}