diff options
author | Andy Clement <aclement@pivotal.io> | 2021-11-29 15:31:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-29 15:31:59 -0800 |
commit | 27aba3f4dfb18600f6b83e8cdf4e268d63d48ec0 (patch) | |
tree | 701f33ae353f92fa184e1484128e4843246cfc64 | |
parent | 90cfa088f5a2c0c8eb2b04553e14c560f472512a (diff) | |
parent | 793a015abbdf77e20052362db626d9aea855c16b (diff) | |
download | aspectj-27aba3f4dfb18600f6b83e8cdf4e268d63d48ec0.tar.gz aspectj-27aba3f4dfb18600f6b83e8cdf4e268d63d48ec0.zip |
Merge pull request #100 from turbanoff/File.exists_before_File.isDirectory_is_redundant
Remove redundant File.exists() check before File.isDirectory()
5 files changed, 10 insertions, 11 deletions
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java index 29f8f6d6d..c2f350d0c 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java @@ -117,10 +117,10 @@ public class ClassPath implements Serializable { File file = new File(path); try { - if (file.exists()) { - if (file.isDirectory()) { - vec.add(new Dir(path)); - } else if (file.getName().endsWith("jrt-fs.jar")) { // TODO a bit crude... + if (file.isDirectory()) { + vec.add(new Dir(path)); + } else if (file.exists()) { + if (file.getName().endsWith("jrt-fs.jar")) { // TODO a bit crude... vec.add(new JImage()); } else { vec.add(new Zip(new ZipFile(file))); diff --git a/build/src/test/java/org/aspectj/build/BuildModuleTests.java b/build/src/test/java/org/aspectj/build/BuildModuleTests.java index 64f8b1016..181d84fcc 100644 --- a/build/src/test/java/org/aspectj/build/BuildModuleTests.java +++ b/build/src/test/java/org/aspectj/build/BuildModuleTests.java @@ -175,7 +175,7 @@ public class BuildModuleTests extends TestCase { void checkSourceDirectory(File srcDir, String module) { final String label = "source dir " + srcDir + " (module " + module + ")"; - assertTrue(label, (srcDir.exists() && srcDir.isDirectory())); + assertTrue(label, srcDir.isDirectory()); String license = getLicense(module); // if (replacing) { // if (replacing && true) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java index 54fee3bfa..1e3310cd7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -993,7 +993,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) { return true; } - if (checkClassFiles && f.exists() && f.isDirectory()) { + if (checkClassFiles && f.isDirectory()) { // We should use here a list/set of directories we know have or have not changed - some kind of // List<File> buildConfig.getClasspathEntriesWithChangedContents() @@ -1045,7 +1045,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) { return true; } - if (checkClassFiles && f.exists() && f.isDirectory()) { + if (checkClassFiles && f.isDirectory()) { // We should use here a list/set of directories we know have or have not changed - some kind of // List<File> buildConfig.getClasspathEntriesWithChangedContents() diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java index 4c3bb93ea..7755718dd 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java @@ -465,7 +465,7 @@ public class Ajc2 extends Javac { File parent = argfile.getParentFile(); // Sanity check - if (parent == null || !parent.exists() || !parent.isDirectory()) { + if (parent == null || !parent.isDirectory()) { return; } diff --git a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java index 6aea81dfa..03b29a85a 100644 --- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java @@ -267,7 +267,7 @@ public class FileUtil { * return true; * }}, true);</code></pre> * @param file root/starting point. If a file, the only one visited. - * @param filter supplies boolean accept(File) method + * @param fileFilter supplies boolean accept(File) method * @param userRecursion - if true, do accept() on dirs; else, recurse * @return false if any fileFilter.accept(File) did. * @throws IllegalArgumentException if file or fileFilter is null @@ -655,7 +655,6 @@ public class FileUtil { */ protected static boolean deleteDirectory(File dir) { return ((null != dir) - && dir.exists() && dir.isDirectory() && FileUtil.descendFileTree(dir, DELETE_FILES, false) && FileUtil.descendFileTree(dir, DELETE_DIRS, true) @@ -675,7 +674,7 @@ public class FileUtil { protected static final FileFilter DELETE_DIRS = new FileFilter() { public boolean accept(File file) { return ((null != file) && file.isDirectory() - && file.exists() && file.delete()); + && file.delete()); } }; protected static final FileFilter DELETE_FILES = new FileFilter() { |