Browse Source

Simplify logic

master
Gintas Grigelionis 7 years ago
parent
commit
9a8a441655
53 changed files with 98 additions and 119 deletions
  1. +2
    -10
      src/main/org/apache/tools/ant/Location.java
  2. +2
    -2
      src/main/org/apache/tools/ant/Project.java
  3. +1
    -1
      src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
  4. +1
    -1
      src/main/org/apache/tools/ant/input/GreedyInputHandler.java
  5. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
  6. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Antlib.java
  7. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Available.java
  8. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Checksum.java
  9. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  10. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Definer.java
  11. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  12. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/DependSet.java
  13. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Exit.java
  14. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  15. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  16. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Length.java
  17. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
  18. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/LoadResource.java
  19. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  20. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
  21. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  22. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Move.java
  23. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Parallel.java
  24. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/SubAnt.java
  25. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  26. +3
    -5
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  27. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  28. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  29. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
  30. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
  31. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
  32. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
  33. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
  34. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java
  35. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
  36. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
  37. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
  38. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
  39. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  40. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  41. +4
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  42. +4
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
  43. +7
    -10
      src/main/org/apache/tools/ant/types/DataType.java
  44. +6
    -7
      src/main/org/apache/tools/ant/types/Description.java
  45. +1
    -1
      src/main/org/apache/tools/ant/types/FileList.java
  46. +1
    -2
      src/main/org/apache/tools/ant/types/resources/Archives.java
  47. +1
    -1
      src/main/org/apache/tools/ant/types/resources/ResourceList.java
  48. +1
    -1
      src/main/org/apache/tools/ant/types/selectors/SelectSelector.java
  49. +1
    -1
      src/main/org/apache/tools/ant/util/DOMElementWriter.java
  50. +2
    -2
      src/main/org/apache/tools/ant/util/FileUtils.java
  51. +3
    -3
      src/main/org/apache/tools/ant/util/ResourceUtils.java
  52. +8
    -7
      src/main/org/apache/tools/zip/GeneralPurposeBit.java
  53. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java

+ 2
- 10
src/main/org/apache/tools/ant/Location.java View File

@@ -159,16 +159,8 @@ public class Location implements Serializable {
*/
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (!(other.getClass() == getClass())) {
return false;
}
return toString().equals(other.toString());
return this == other || other != null && other.getClass() == getClass()
&& toString().equals(other.toString());
}

/**


+ 2
- 2
src/main/org/apache/tools/ant/Project.java View File

@@ -1398,12 +1398,12 @@ public class Project implements ResourceFactory {
curtarget.performTasks();
succeededTargets.add(curtarget.getName());
} catch (final RuntimeException ex) {
if (!(keepGoingMode)) {
if (!keepGoingMode) {
throw ex; // throw further
}
thrownException = ex;
} catch (final Throwable ex) {
if (!(keepGoingMode)) {
if (!keepGoingMode) {
throw new BuildException(ex);
}
thrownException = ex;


+ 1
- 1
src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java View File

@@ -253,7 +253,7 @@ public final class ChainReaderHelper {
}
success = true;
} finally {
if (!(success || classLoadersToCleanUp.isEmpty())) {
if (!success && !classLoadersToCleanUp.isEmpty()) {
cleanUpClassLoaders(classLoadersToCleanUp);
}
}


+ 1
- 1
src/main/org/apache/tools/ant/input/GreedyInputHandler.java View File

@@ -65,7 +65,7 @@ public class GreedyInputHandler extends DefaultInputHandler {
}
}
request.setInput(new String(baos.toByteArray()));
if (!(request.isInputValid())) {
if (!request.isInputValid()) {
throw new BuildException(
"Received invalid console input");
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java View File

@@ -603,7 +603,7 @@ public abstract class AbstractCvsTask extends Task {
*/
public void setTag(String p) {
// Check if not real tag => set it to null
if (!(p == null || p.trim().isEmpty())) {
if (p != null && !p.trim().isEmpty()) {
tag = p;
addCommandArgument("-r" + p);
}
@@ -639,7 +639,7 @@ public abstract class AbstractCvsTask extends Task {
* can understand see man cvs
*/
public void setDate(String p) {
if (!(p == null || p.trim().isEmpty())) {
if (p != null && !p.trim().isEmpty()) {
addCommandArgument("-D");
addCommandArgument(p);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Antlib.java View File

@@ -92,7 +92,7 @@ public class Antlib extends Task implements TaskContainer {
UnknownElement ue =
parser.parseAntlibDescriptor(project, antlibResource);
// Check name is "antlib"
if (!(TAG.equals(ue.getTag()))) {
if (!TAG.equals(ue.getTag())) {
throw new BuildException(
"Unexpected tag " + ue.getTag() + " expecting "
+ TAG, ue.getLocation());


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -287,12 +287,12 @@ public class Available extends Task implements Condition {
} else {
setTaskName("available");
}
if (!(classname == null || checkClass(classname))) {
if (classname != null && !checkClass(classname)) {
log("Unable to load class " + classname + appendix,
Project.MSG_VERBOSE);
return false;
}
if ((file != null) && !checkFile()) {
if (file != null && !checkFile()) {
StringBuilder buf = new StringBuilder("Unable to find ");
if (type != null) {
buf.append(type).append(' ');
@@ -301,7 +301,7 @@ public class Available extends Task implements Condition {
log(buf.toString(), Project.MSG_VERBOSE);
return false;
}
if ((resource != null) && !checkResource(resource)) {
if (resource != null && !checkResource(resource)) {
log("Unable to load resource " + resource + appendix,
Project.MSG_VERBOSE);
return false;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Checksum.java View File

@@ -328,7 +328,7 @@ public class Checksum extends MatchingTask implements Condition {
throw new BuildException(
"Specify at least one source - a file or a resource collection.");
}
if (!(resources == null || resources.isFilesystemOnly())) {
if (resources != null && !resources.isFilesystemOnly()) {
throw new BuildException("Can only calculate checksums for file-based resources.");
}
if (file != null && file.exists() && file.isDirectory()) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -909,7 +909,7 @@ public class Copy extends Task {
for (String dir : dirs) {
final File d = new File(dir);
if (!d.exists()) {
if (!(d.mkdirs() || d.isDirectory())) {
if (!d.mkdirs() && !d.isDirectory()) {
log("Unable to create directory "
+ d.getAbsolutePath(), Project.MSG_ERR);
} else {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Definer.java View File

@@ -320,7 +320,7 @@ public abstract class Definer extends DefBase {
*/
private URL fileToURL() {
String message = null;
if (!(file.exists())) {
if (!file.exists()) {
message = "File " + file + " does not exist";
}
if (message == null && !(file.isFile())) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Delete.java View File

@@ -748,7 +748,7 @@ public class Delete extends MatchingTask {
if (!f.exists()) {
continue;
}
if (!(f.isDirectory()) || f.list().length == 0) {
if (!f.isDirectory() || f.list().length == 0) {
log("Deleting " + f, verbosity);
if (!delete(f) && failonerror) {
handle("Unable to delete "


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/DependSet.java View File

@@ -205,7 +205,7 @@ public class DependSet extends MatchingTask {
"At least one set of target files must be specified");
}
//no sources = nothing to compare; no targets = nothing to delete:
if (!(sources.isEmpty() || targets.isEmpty() || uptodate(sources, targets))) {
if (!sources.isEmpty() && !targets.isEmpty() && !uptodate(sources, targets)) {
log("Deleting all target files.", Project.MSG_VERBOSE);
if (verbose) {
for (String t : targets.list()) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Exit.java View File

@@ -138,7 +138,7 @@ public class Exit extends Task {
: (testIfCondition() && testUnlessCondition());
if (fail) {
String text = null;
if (!(message == null || message.trim().isEmpty())) {
if (message != null && !message.trim().isEmpty()) {
text = message.trim();
} else {
if (ifCondition != null && !"".equals(ifCondition)


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -268,7 +268,7 @@ public class Expand extends Task {
entryName = entryName.substring(1);
}

if (!(patternsets == null || patternsets.isEmpty())) {
if (patternsets != null && !patternsets.isEmpty()) {
String name = entryName.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);



+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -2174,8 +2174,7 @@ public class Javadoc extends Task {
private void doDocFilesSubDirs(final Commandline toExecute) {
if (docFilesSubDirs) {
toExecute.createArgument().setValue("-docfilessubdirs");
if (!(excludeDocFilesSubDir == null
|| excludeDocFilesSubDir.trim().isEmpty())) {
if (excludeDocFilesSubDir != null && !excludeDocFilesSubDir.trim().isEmpty()) {
toExecute.createArgument().setValue("-excludedocfilessubdir");
toExecute.createArgument().setValue(excludeDocFilesSubDir);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Length.java View File

@@ -221,7 +221,7 @@ public class Length extends Task implements Condition {
"the mode attribute is for use with the file/resource length function");
}
} else if (resources != null) {
if (!(EACH.equals(mode) || ALL.equals(mode))) {
if (!EACH.equals(mode) && !ALL.equals(mode)) {
throw new BuildException(
"invalid mode setting for file/resource length function: \""
+ mode + "\"");


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/LoadProperties.java View File

@@ -183,7 +183,7 @@ public class LoadProperties extends Task {

String text = instream.readFully();

if (!(text == null || text.isEmpty())) {
if (text != null && !text.isEmpty()) {
if (!text.endsWith("\n")) {
text = text + "\n";
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/LoadResource.java View File

@@ -178,7 +178,7 @@ public class LoadResource extends Task {
text = null;
}

if (!(text == null || text.isEmpty())) {
if (text != null && !text.isEmpty()) {
getProject().setNewProperty(property, text);
log("loaded " + text.length() + " characters",
Project.MSG_VERBOSE);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -729,8 +729,8 @@ public class MacroDef extends AntlibDefinition {
}
if (getURI() == null || "".equals(getURI())
|| getURI().equals(ProjectHelper.ANT_CORE_URI)) {
if (!(other.getURI() == null || "".equals(other.getURI())
|| other.getURI().equals(ProjectHelper.ANT_CORE_URI))) {
if (other.getURI() != null && !"".equals(other.getURI())
&& !other.getURI().equals(ProjectHelper.ANT_CORE_URI)) {
return false;
}
} else if (!getURI().equals(other.getURI())) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/MacroInstance.java View File

@@ -375,7 +375,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain
text = text.trim();
}
localAttributes.put(macroDef.getText().getName(), text);
} else if (!(text == null || text.trim().isEmpty())) {
} else if (text != null && !text.trim().isEmpty()) {
throw new BuildException(
"The \"%s\" macro does not support nested text data.",
getTaskName());


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -162,7 +162,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {
public void XsetIgnore(String ignoreString) {
log("The ignore attribute is deprecated."
+ "Please use the excludes attribute.", Project.MSG_WARN);
if (!(ignoreString == null || ignoreString.isEmpty())) {
if (ignoreString != null && !ignoreString.isEmpty()) {
StringTokenizer tok = new StringTokenizer(ignoreString, ", ",
false);
while (tok.hasMoreTokens()) {


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Move.java View File

@@ -179,7 +179,7 @@ public class Move extends Copy {
}
File d = new File(toDirName);
if (!d.exists()) {
if (!(d.mkdirs() || d.exists())) {
if (!d.mkdirs() && !d.exists()) {
log("Unable to create directory "
+ d.getAbsolutePath(), Project.MSG_ERR);
} else {
@@ -372,8 +372,8 @@ public class Move extends Copy {
+ " is a no-op.", Project.MSG_VERBOSE);
return true;
}
if (!(getFileUtils().areSame(sourceFile, destFile)
|| getFileUtils().tryHardToDelete(destFile, performGc))) {
if (!getFileUtils().areSame(sourceFile, destFile)
&& !getFileUtils().tryHardToDelete(destFile, performGc)) {
throw new BuildException("Unable to remove existing file %s",
destFile);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Parallel.java View File

@@ -269,7 +269,7 @@ public class Parallel extends Task
ThreadGroup group = new ThreadGroup("parallel");

TaskRunnable[] daemons = null;
if (!(daemonTasks == null || daemonTasks.tasks.isEmpty())) {
if (daemonTasks != null && !daemonTasks.tasks.isEmpty()) {
daemons = new TaskRunnable[daemonTasks.tasks.size()];
}



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/SubAnt.java View File

@@ -227,7 +227,7 @@ public class SubAnt extends Task {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
} catch (RuntimeException ex) {
if (!(getProject().isKeepGoingMode())) {
if (!getProject().isKeepGoingMode()) {
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
@@ -235,7 +235,7 @@ public class SubAnt extends Task {
}
thrownException = ex;
} catch (Throwable ex) {
if (!(getProject().isKeepGoingMode())) {
if (!getProject().isKeepGoingMode()) {
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/UpToDate.java View File

@@ -159,7 +159,7 @@ public class UpToDate extends Task implements Condition {
"At least one srcfile or a nested <srcfiles> or <srcresources> element must be set.");
}

if (!(sourceFileSets.isEmpty() && sourceResources.isEmpty())
if ((!sourceFileSets.isEmpty() || !sourceResources.isEmpty())
&& sourceFile != null) {
throw new BuildException(
"Cannot specify both the srcfile attribute and a nested <srcfiles> or <srcresources> element.");


+ 3
- 5
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -889,11 +889,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
*/
private void ensureDirectoryFor(final File targetFile) throws BuildException {
final File directory = targetFile.getParentFile();
if (!directory.exists()) {
if (!(directory.mkdirs() || directory.isDirectory())) {
handleError("Unable to create directory: "
+ directory.getAbsolutePath());
}
if (!directory.exists() && !directory.mkdirs() && !directory.isDirectory()) {
handleError("Unable to create directory: "
+ directory.getAbsolutePath());
}
}



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -1600,13 +1600,13 @@ public class Zip extends MatchingTask {
final List<Resource> resources = new Vector<>();
if (!doFilesonly) {
for (String d : rs.getIncludedDirectories()) {
if (!(d.isEmpty() && skipEmptyNames)) {
if (!d.isEmpty() || !skipEmptyNames) {
resources.add(rs.getResource(d));
}
}
}
for (String f : rs.getIncludedFiles()) {
if (!(f.isEmpty() && skipEmptyNames)) {
if (!f.isEmpty() || !skipEmptyNames) {
resources.add(rs.getResource(f));
}
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -334,7 +334,7 @@ public abstract class DefaultCompilerAdapter
}
}

if (!(extdirs == null || extdirs.isEmpty())) {
if (extdirs != null && !extdirs.isEmpty()) {
cmd.createArgument().setValue("-extdirs");
cmd.createArgument().setPath(extdirs);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java View File

@@ -83,7 +83,7 @@ public class Jikes extends DefaultCompilerAdapter {
classpath.append(new Path(project, jikesPath));
}

if (!(extdirs == null || extdirs.isEmpty())) {
if (extdirs != null && !extdirs.isEmpty()) {
cmd.createArgument().setValue("-extdirs");
cmd.createArgument().setPath(extdirs);
}


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java View File

@@ -88,8 +88,7 @@ public class ResourceContains implements Condition {
o = rc.iterator().next();
}
} else {
throw new BuildException("Illegal value at '%s': %s", refid,
o);
throw new BuildException("Illegal value at '%s': %s", refid, o);
}
}
this.resource = (Resource) o;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java View File

@@ -209,7 +209,7 @@ public class EchoProperties extends Task {
* @since Ant 1.7
*/
public void setRegex(String regex) {
if (!(regex == null || regex.isEmpty())) {
if (regex != null && !regex.isEmpty()) {
this.regex = regex;
PropertySet ps = new PropertySet();
ps.setProject(getProject());


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java View File

@@ -103,7 +103,7 @@ public abstract class Continuus extends Task {
*/
protected final String getCcmCommand() {
String toReturn = ccmDir;
if (!("".equals(toReturn) || toReturn.endsWith("/"))) {
if (!"".equals(toReturn) && !toReturn.endsWith("/")) {
toReturn += "/";
}



+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java View File

@@ -128,7 +128,7 @@ public abstract class ClearCase extends Task {
*/
protected final String getClearToolCommand() {
String toReturn = mClearToolDir;
if (!("".equals(toReturn) || toReturn.endsWith("/"))) {
if (!"".equals(toReturn) && !toReturn.endsWith("/")) {
toReturn += "/";
}



+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java View File

@@ -240,7 +240,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool
protected void addVendorFiles(Hashtable<String, File> ejbFiles, String ddPrefix) {

//choose the right vendor DD
if (!(version == BES || version == BAS)) {
if (version != BES && version != BAS) {
throw new BuildException("version " + version + " is not supported");
}



+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java View File

@@ -160,8 +160,7 @@ public class BorlandGenerateClient extends Task {
setMode(JAVA_MODE);
}

if (!(version == BorlandDeploymentTool.BES
|| version == BorlandDeploymentTool.BAS)) {
if (version != BorlandDeploymentTool.BES && version != BorlandDeploymentTool.BAS) {
throw new BuildException("version %d is not supported", version);
}



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java View File

@@ -566,8 +566,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
}

Path combinedClasspath = getCombinedClasspath();
if (!(wlClasspath == null || combinedClasspath == null
|| combinedClasspath.toString().trim().isEmpty())) {
if (wlClasspath != null && combinedClasspath != null
&& !combinedClasspath.toString().trim().isEmpty()) {
javaTask.createArg().setValue("-classpath");
javaTask.createArg().setPath(combinedClasspath);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java View File

@@ -240,7 +240,7 @@ public class Image extends MatchingTask {

if (dstFile.exists()) {
// avoid overwriting unless necessary
if(!overwrite
if (!overwrite
&& srcFile.lastModified() <= dstFile.lastModified()) {

log(srcFile + " omitted as " + dstFile


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java View File

@@ -355,7 +355,7 @@ public class jlink {
*/
String name = inputEntry.getName();

if (!(inputEntry.isDirectory() || name.endsWith(".class"))) {
if (!inputEntry.isDirectory() && !name.endsWith(".class")) {
try (InputStream input = zip.getInputStream(zip.getEntry(name))) {
String className = ClassNameReader.getClassName(input);



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -1703,8 +1703,8 @@ public class JUnitTask extends Task {
private void checkModules() {
if (hasPath(getCommandline().getModulepath()) ||
hasPath(getCommandline().getUpgrademodulepath())) {
if (!(batchTests.stream().allMatch(BaseTest::getFork)
&& tests.stream().allMatch(BaseTest::getFork))) {
if (!batchTests.stream().allMatch(BaseTest::getFork)
|| !tests.stream().allMatch(BaseTest::getFork)) {
throw new BuildException(
"The module path requires fork attribute to be set to true.");
}


+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -2394,8 +2394,8 @@ public class FTP extends Task implements FTPTaskConfig {
// to indicate that an attempt to create a directory has
// failed because the directory already exists.
int rc = ftp.getReplyCode();
if (!(ignoreNoncriticalErrors && (rc == CODE_550
|| rc == CODE_553 || rc == CODE_521))) {
if (!ignoreNoncriticalErrors
|| rc != CODE_550 && rc != CODE_553 && rc != CODE_521) {
throw new BuildException(
"could not create directory: %s",
ftp.getReplyString());
@@ -2420,8 +2420,7 @@ public class FTP extends Task implements FTPTaskConfig {
private void handleMkDirFailure(FTPClient ftp)
throws BuildException {
int rc = ftp.getReplyCode();
if (!(ignoreNoncriticalErrors
&& (rc == CODE_550 || rc == CODE_553 || rc == CODE_521))) {
if (!ignoreNoncriticalErrors || rc != CODE_550 && rc != CODE_553 && rc != CODE_521) {
throw new BuildException("could not create directory: %s",
ftp.getReplyString());
}


+ 4
- 6
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -1768,9 +1768,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
// to indicate that an attempt to create a directory has
// failed because the directory already exists.
int rc = ftp.getReplyCode();
if (!(task.isIgnoreNoncriticalErrors() && (rc == CODE_550
|| rc == CODE_553
|| rc == CODE_521))) {
if (!task.isIgnoreNoncriticalErrors()
|| rc != CODE_550 && rc != CODE_553 && rc != CODE_521) {
throw new BuildException("could not create directory: "
+ ftp.getReplyString());
}
@@ -1799,9 +1798,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
private void handleMkDirFailure(FTPClient ftp)
throws BuildException {
int rc = ftp.getReplyCode();
if (!(task.isIgnoreNoncriticalErrors() && (rc == CODE_550
|| rc == CODE_553
|| rc == CODE_521))) {
if (!task.isIgnoreNoncriticalErrors()
|| rc != CODE_550 && rc != CODE_553 && rc != CODE_521) {
throw new BuildException("could not create directory: "
+ ftp.getReplyString());
}


+ 4
- 5
src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java View File

@@ -138,13 +138,12 @@ public class Directory {
return true;
}

if (!(obj instanceof Directory)) {
return false;
if (obj instanceof Directory) {
Directory d = (Directory) obj;
return this.directory.equals(d.directory);
}

Directory d = (Directory) obj;

return this.directory.equals(d.directory);
return false;
}

/**


+ 7
- 10
src/main/org/apache/tools/ant/types/DataType.java View File

@@ -251,17 +251,14 @@ public abstract class DataType extends ProjectComponent implements Cloneable {
}
dieOnCircularReference(project);
Object o = ref.getReferencedObject(project);
if (!(requiredClass.isAssignableFrom(o.getClass()))) {
log("Class " + displayName(o.getClass())
+ " is not a subclass of "
+ displayName(requiredClass),
Project.MSG_VERBOSE);
String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName;
throw new BuildException(msg);
if (requiredClass.isAssignableFrom(o.getClass())) {
return (T) o;
}
@SuppressWarnings("unchecked")
final T result = (T) o;
return result;
log("Class " + displayName(o.getClass())
+ " is not a subclass of "
+ displayName(requiredClass),
Project.MSG_VERBOSE);
throw new BuildException(ref.getRefId() + " doesn\'t denote a " + dataTypeName);
}

/**


+ 6
- 7
src/main/org/apache/tools/ant/types/Description.java View File

@@ -92,13 +92,12 @@ public class Description extends DataType {
return;
}
for (Task task : findElementInTarget(t, "description")) {
if (!(task instanceof UnknownElement)) {
continue;
}
UnknownElement ue = ((UnknownElement) task);
String descComp = ue.getWrapper().getText().toString();
if (descComp != null) {
description.append(project.replaceProperties(descComp));
if (task instanceof UnknownElement) {
UnknownElement ue = (UnknownElement) task;
String descComp = ue.getWrapper().getText().toString();
if (descComp != null) {
description.append(project.replaceProperties(descComp));
}
}
}
}


+ 1
- 1
src/main/org/apache/tools/ant/types/FileList.java View File

@@ -106,7 +106,7 @@ public class FileList extends DataType implements ResourceCollection {
*/
public void setFiles(String filenames) {
checkAttributesAllowed();
if (!(filenames == null || filenames.isEmpty())) {
if (filenames != null && !filenames.isEmpty()) {
StringTokenizer tok = new StringTokenizer(
filenames, ", \t\n\r\f", false);
while (tok.hasMoreTokens()) {


+ 1
- 2
src/main/org/apache/tools/ant/types/resources/Archives.java View File

@@ -120,8 +120,7 @@ public class Archives extends DataType
*/
@Override
public void setRefid(final Reference r) {
if (!(zips.getResourceCollections().isEmpty()
&& tars.getResourceCollections().isEmpty())) {
if (!zips.getResourceCollections().isEmpty() || !tars.getResourceCollections().isEmpty()) {
throw tooManyAttributes();
}
super.setRefid(r);


+ 1
- 1
src/main/org/apache/tools/ant/types/resources/ResourceList.java View File

@@ -110,7 +110,7 @@ public class ResourceList extends DataType implements ResourceCollection {
if (encoding != null) {
throw tooManyAttributes();
}
if (!(filterChains.isEmpty() && textDocuments.isEmpty())) {
if (!filterChains.isEmpty() || !textDocuments.isEmpty()) {
throw noChildrenAllowed();
}
super.setRefid(r);


+ 1
- 1
src/main/org/apache/tools/ant/types/selectors/SelectSelector.java View File

@@ -216,7 +216,7 @@ public class SelectSelector extends BaseSelectorContainer {
validate();

// Deal with if and unless properties first
if (!(passesConditions())) {
if (!passesConditions()) {
return false;
}



+ 1
- 1
src/main/org/apache/tools/ant/util/DOMElementWriter.java View File

@@ -550,7 +550,7 @@ public class DOMElementWriter {
* @return true if it is an entity.
*/
public boolean isReference(String ent) {
if (!(ent.charAt(0) == '&') || !ent.endsWith(";")) {
if (ent.charAt(0) != '&' || !ent.endsWith(";")) {
return false;
}



+ 2
- 2
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -665,12 +665,12 @@ public class FileUtils {
char sep = File.separatorChar;
filename = filename.replace('/', sep).replace('\\', sep);
char c = filename.charAt(0);
if (!(ON_DOS || ON_NETWARE)) {
if (!ON_DOS && !ON_NETWARE) {
return (c == sep);
}
if (c == sep) {
// CheckStyle:MagicNumber OFF
if (!(ON_DOS && len > 4 && filename.charAt(1) == sep)) {
if (!ON_DOS || len <= 4 || filename.charAt(1) != sep) {
return false;
}
// CheckStyle:MagicNumber ON


+ 3
- 3
src/main/org/apache/tools/ant/util/ResourceUtils.java View File

@@ -368,8 +368,8 @@ public class ResourceUtils {
final String inputEncoding, final String outputEncoding,
final Project project, final boolean force)
throws IOException {
if (!(overwrite || SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils()
.getFileTimestampGranularity()))) {
if (!overwrite && !SelectorUtils.isOutOfDate(source, dest,
FileUtils.getFileUtils().getFileTimestampGranularity())) {
return;
}
final boolean filterSetsAvailable = (filters != null
@@ -515,7 +515,7 @@ public class ResourceUtils {
}
final boolean e1 = r1.isExists();
final boolean e2 = r2.isExists();
if (!(e1 || e2)) {
if (!e1 && !e2) {
return 0;
}
if (e1 != e2) {


+ 8
- 7
src/main/org/apache/tools/zip/GeneralPurposeBit.java View File

@@ -189,14 +189,15 @@ public final class GeneralPurposeBit implements Cloneable {

@Override
public boolean equals(Object o) {
if (!(o instanceof GeneralPurposeBit)) {
return false;
if (o instanceof GeneralPurposeBit) {
GeneralPurposeBit g = (GeneralPurposeBit) o;
return g.encryptionFlag == encryptionFlag
&& g.strongEncryptionFlag == strongEncryptionFlag
&& g.languageEncodingFlag == languageEncodingFlag
&& g.dataDescriptorFlag == dataDescriptorFlag;
}
GeneralPurposeBit g = (GeneralPurposeBit) o;
return g.encryptionFlag == encryptionFlag
&& g.strongEncryptionFlag == strongEncryptionFlag
&& g.languageEncodingFlag == languageEncodingFlag
&& g.dataDescriptorFlag == dataDescriptorFlag;

return false;
}

@Override


+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java View File

@@ -102,7 +102,7 @@ public class LoadFileTest {
@Test
public void testLoadAFile() throws BuildException {
buildRule.executeTarget("testLoadAFile");
if(!buildRule.getProject().getProperty("testLoadAFile").contains("eh?")) {
if (!buildRule.getProject().getProperty("testLoadAFile").contains("eh?")) {
fail("property is not all in the file");
}
}
@@ -122,7 +122,7 @@ public class LoadFileTest {
@Test
public void testEvalProps() throws BuildException {
buildRule.executeTarget("testEvalProps");
if(!buildRule.getProject().getProperty("testEvalProps").contains("rain")) {
if (!buildRule.getProject().getProperty("testEvalProps").contains("rain")) {
fail("property eval broken");
}
}
@@ -133,7 +133,7 @@ public class LoadFileTest {
@Test
public void testFilterChain() throws BuildException {
buildRule.executeTarget("testFilterChain");
if(!buildRule.getProject().getProperty("testFilterChain").contains("World!")) {
if (!buildRule.getProject().getProperty("testFilterChain").contains("World!")) {
fail("Filter Chain broken");
}
}


Loading…
Cancel
Save