diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-08 17:13:10 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-08 17:16:34 +0900 |
commit | 0e5b9f8a39a955a58f39466264afed372b27aaa2 (patch) | |
tree | e7f3f5df5ebba7bc29999f38573881290ae9540f | |
parent | fdacfaecc43e573feaf31dcb4ab26e3469868618 (diff) | |
download | jgit-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.java | 6 |
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); } |