Browse Source

Revert last 5 commits

master
Gintas Grigelionis 6 years ago
parent
commit
551cb55e32
100 changed files with 615 additions and 540 deletions
  1. +24
    -25
      src/main/org/apache/tools/ant/AntClassLoader.java
  2. +4
    -3
      src/main/org/apache/tools/ant/AntTypeDefinition.java
  3. +0
    -1
      src/main/org/apache/tools/ant/BuildException.java
  4. +3
    -3
      src/main/org/apache/tools/ant/ComponentHelper.java
  5. +2
    -2
      src/main/org/apache/tools/ant/DirectoryScanner.java
  6. +0
    -1
      src/main/org/apache/tools/ant/Evaluable.java
  7. +5
    -6
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  8. +16
    -8
      src/main/org/apache/tools/ant/Main.java
  9. +5
    -5
      src/main/org/apache/tools/ant/Project.java
  10. +0
    -1
      src/main/org/apache/tools/ant/ProjectHelper.java
  11. +30
    -20
      src/main/org/apache/tools/ant/PropertyHelper.java
  12. +5
    -3
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  13. +11
    -6
      src/main/org/apache/tools/ant/UnknownElement.java
  14. +1
    -1
      src/main/org/apache/tools/ant/dispatch/DispatchUtils.java
  15. +0
    -2
      src/main/org/apache/tools/ant/filters/BaseFilterReader.java
  16. +10
    -8
      src/main/org/apache/tools/ant/filters/ConcatFilter.java
  17. +0
    -16
      src/main/org/apache/tools/ant/filters/FixCrLfFilter.java
  18. +9
    -5
      src/main/org/apache/tools/ant/filters/HeadFilter.java
  19. +19
    -17
      src/main/org/apache/tools/ant/filters/StripJavaComments.java
  20. +5
    -3
      src/main/org/apache/tools/ant/filters/TabsToSpaces.java
  21. +2
    -8
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  22. +20
    -15
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  23. +0
    -15
      src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
  24. +10
    -6
      src/main/org/apache/tools/ant/listener/MailLogger.java
  25. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
  26. +19
    -10
      src/main/org/apache/tools/ant/taskdefs/Available.java
  27. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  28. +6
    -5
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  29. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Exit.java
  30. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  31. +10
    -9
      src/main/org/apache/tools/ant/taskdefs/Java.java
  32. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  33. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
  34. +9
    -8
      src/main/org/apache/tools/ant/taskdefs/PreSetDef.java
  35. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Recorder.java
  36. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/Redirector.java
  37. +6
    -3
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  38. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/TaskOutputStream.java
  39. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Touch.java
  40. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  41. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  42. +6
    -5
      src/main/org/apache/tools/ant/taskdefs/email/EmailAddress.java
  43. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
  44. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
  45. +0
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  46. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  47. +17
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  48. +9
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
  49. +8
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
  50. +19
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  51. +43
    -25
      src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
  52. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
  53. +42
    -34
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  54. +5
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
  55. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestRequest.java
  56. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
  57. +15
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  58. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
  59. +18
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  60. +8
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
  61. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
  62. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  63. +1
    -1
      src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
  64. +2
    -1
      src/main/org/apache/tools/ant/types/Path.java
  65. +1
    -1
      src/main/org/apache/tools/ant/types/Permissions.java
  66. +4
    -3
      src/main/org/apache/tools/ant/types/RedirectorElement.java
  67. +11
    -9
      src/main/org/apache/tools/ant/types/resources/URLResource.java
  68. +0
    -2
      src/main/org/apache/tools/ant/types/resources/ZipResource.java
  69. +4
    -4
      src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
  70. +0
    -3
      src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java
  71. +1
    -3
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java
  72. +0
    -1
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/HashvalueAlgorithm.java
  73. +1
    -1
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java
  74. +1
    -1
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java
  75. +1
    -1
      src/main/org/apache/tools/ant/util/Base64Converter.java
  76. +1
    -1
      src/main/org/apache/tools/ant/util/DOMElementWriter.java
  77. +1
    -1
      src/main/org/apache/tools/ant/util/FileUtils.java
  78. +4
    -2
      src/main/org/apache/tools/ant/util/GlobPatternMapper.java
  79. +0
    -1
      src/main/org/apache/tools/ant/util/KeepAliveInputStream.java
  80. +0
    -1
      src/main/org/apache/tools/ant/util/KeepAliveOutputStream.java
  81. +5
    -3
      src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
  82. +0
    -7
      src/main/org/apache/tools/ant/util/LazyHashtable.java
  83. +0
    -1
      src/main/org/apache/tools/ant/util/LinkedHashtable.java
  84. +6
    -3
      src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
  85. +0
    -2
      src/main/org/apache/tools/ant/util/StreamUtils.java
  86. +0
    -1
      src/main/org/apache/tools/ant/util/WorkerAnt.java
  87. +1
    -1
      src/main/org/apache/tools/bzip2/BZip2Constants.java
  88. +8
    -8
      src/main/org/apache/tools/bzip2/BlockSort.java
  89. +11
    -6
      src/main/org/apache/tools/bzip2/CBZip2OutputStream.java
  90. +30
    -15
      src/main/org/apache/tools/tar/TarBuffer.java
  91. +1
    -1
      src/main/org/apache/tools/tar/TarInputStream.java
  92. +2
    -2
      src/main/org/apache/tools/tar/TarUtils.java
  93. +0
    -1
      src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
  94. +1
    -1
      src/main/org/apache/tools/zip/ZipEightByteInteger.java
  95. +2
    -1
      src/main/org/apache/tools/zip/ZipFile.java
  96. +1
    -1
      src/main/org/apache/tools/zip/ZipLong.java
  97. +5
    -3
      src/main/org/apache/tools/zip/ZipOutputStream.java
  98. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java
  99. +4
    -4
      src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
  100. +22
    -31
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java

+ 24
- 25
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -126,9 +126,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
* @return <code>true</code> if there are more elements in the * @return <code>true</code> if there are more elements in the
* enumeration; <code>false</code> otherwise. * enumeration; <code>false</code> otherwise.
*/ */
@Override
public boolean hasMoreElements() { public boolean hasMoreElements() {
return this.nextResource != null;
return (this.nextResource != null);
} }


/** /**
@@ -136,7 +135,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
* *
* @return the next resource in the enumeration * @return the next resource in the enumeration
*/ */
@Override
public URL nextElement() { public URL nextElement() {
final URL ret = this.nextResource; final URL ret = this.nextResource;
if (ret == null) { if (ret == null) {
@@ -371,8 +369,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
} catch (final BuildException e) { } catch (final BuildException e) {
// ignore path elements which are invalid // ignore path elements which are invalid
// relative to the project // relative to the project
log("Ignoring path element " + pathElement + " from "
+ "classpath due to exception " + e, Project.MSG_DEBUG);
log("Ignoring path element " + pathElement + " from " +
"classpath due to exception " + e, Project.MSG_DEBUG);
} }
} }
} }
@@ -586,25 +584,27 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo


final Constructor<?>[] cons = theClass.getDeclaredConstructors(); final Constructor<?>[] cons = theClass.getDeclaredConstructors();
//At least one constructor is guaranteed to be there, but check anyway. //At least one constructor is guaranteed to be there, but check anyway.
if (cons != null && cons.length > 0 && cons[0] != null) {
final String[] strs = new String[NUMBER_OF_STRINGS];
try {
cons[0].newInstance((Object[]) strs);
// Expecting an exception to be thrown by this call:
// IllegalArgumentException: wrong number of Arguments
} catch (final Exception e) {
// Ignore - we are interested only in the side
// effect - that of getting the static initializers
// invoked. As we do not want to call a valid
// constructor to get this side effect, an
// attempt is made to call a hopefully
// invalid constructor - come on, nobody
// would have a constructor that takes in
// 256 String arguments ;-)
// (In fact, they can't - according to JVM spec
// section 4.10, the number of method parameters is limited
// to 255 by the definition of a method descriptor.
// Constructors count as methods here.)
if (cons != null) {
if (cons.length > 0 && cons[0] != null) {
final String[] strs = new String[NUMBER_OF_STRINGS];
try {
cons[0].newInstance((Object[]) strs);
// Expecting an exception to be thrown by this call:
// IllegalArgumentException: wrong number of Arguments
} catch (final Exception e) {
// Ignore - we are interested only in the side
// effect - that of getting the static initializers
// invoked. As we do not want to call a valid
// constructor to get this side effect, an
// attempt is made to call a hopefully
// invalid constructor - come on, nobody
// would have a constructor that takes in
// 256 String arguments ;-)
// (In fact, they can't - according to JVM spec
// section 4.10, the number of method parameters is limited
// to 255 by the definition of a method descriptor.
// Constructors count as methods here.)
}
} }
} }
} }
@@ -1523,7 +1523,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void close() { public void close() {
cleanup(); cleanup();
} }


+ 4
- 3
src/main/org/apache/tools/ant/AntTypeDefinition.java View File

@@ -315,7 +315,8 @@ public class AntTypeDefinition {
noArg = false; noArg = false;
} }
//now we instantiate //now we instantiate
T o = ctor.newInstance(noArg ? new Object[0] : new Object[] {project});
T o = ctor.newInstance(
((noArg) ? new Object[0] : new Object[] {project}));


//set up project references. //set up project references.
project.setProjectReference(o); project.setProjectReference(o);
@@ -330,12 +331,12 @@ public class AntTypeDefinition {
* @return true if the definitions are the same. * @return true if the definitions are the same.
*/ */
public boolean sameDefinition(AntTypeDefinition other, Project project) { public boolean sameDefinition(AntTypeDefinition other, Project project) {
return other != null && other.getClass() == getClass()
return (other != null && other.getClass() == getClass()
&& other.getTypeClass(project).equals(getTypeClass(project)) && other.getTypeClass(project).equals(getTypeClass(project))
&& other.getExposedClass(project).equals(getExposedClass(project)) && other.getExposedClass(project).equals(getExposedClass(project))
&& other.restrict == restrict && other.restrict == restrict
&& other.adapterClass == adapterClass && other.adapterClass == adapterClass
&& other.adaptToClass == adaptToClass;
&& other.adaptToClass == adaptToClass);
} }


/** /**


+ 0
- 1
src/main/org/apache/tools/ant/BuildException.java View File

@@ -141,7 +141,6 @@ public class BuildException extends RuntimeException {
* *
* @return the location of the error and the error message * @return the location of the error and the error message
*/ */
@Override
public String toString() { public String toString() {
return location.toString() + getMessage(); return location.toString() + getMessage();
} }


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

@@ -710,9 +710,9 @@ public class ComponentHelper {
} }
Class<?> oldClass = old.getExposedClass(project); Class<?> oldClass = old.getExposedClass(project);
boolean isTask = oldClass != null && Task.class.isAssignableFrom(oldClass); boolean isTask = oldClass != null && Task.class.isAssignableFrom(oldClass);
project.log(String.format("Trying to override old definition of %s %s",
isTask ? "task" : "datatype", name), def.similarDefinition(old,
project) ? Project.MSG_VERBOSE : Project.MSG_WARN);
project.log("Trying to override old definition of "
+ (isTask ? "task " : "datatype ") + name, (def.similarDefinition(old,
project)) ? Project.MSG_VERBOSE : Project.MSG_WARN);
} }
project.log(" +Datatype " + name + " " + def.getClassName(), Project.MSG_DEBUG); project.log(" +Datatype " + name + " " + def.getClassName(), Project.MSG_DEBUG);
antTypeTable.put(name, def); antTypeTable.put(name, def);


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

@@ -1245,8 +1245,8 @@ public class DirectoryScanner
continue; continue;
} }
} catch (IOException e) { } catch (IOException e) {
System.err.println("Failed to determine if " + file + " causes a "
+ "filesystem loop due to symbolic link; continuing");
System.err.println("Failed to determine if " + file + " causes a " +
"filesystem loop due to symbolic link; continuing");
} }


final String[] children = file.list(); final String[] children = file.list();


+ 0
- 1
src/main/org/apache/tools/ant/Evaluable.java View File

@@ -29,7 +29,6 @@ public interface Evaluable<T> extends Supplier<T> {


T eval(); T eval();


@Override
default T get() { default T get() {
return eval(); return eval();
} }


+ 5
- 6
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -218,12 +218,11 @@ public final class IntrospectionHelper {
*/ */
continue; continue;
} }
if (File.class.equals(args[0])
&& (Resource.class.equals(as.type) || FileProvider.class.equals(as.type))) {
/*
Ant Resources/FileProviders override java.io.File
*/
continue;
if (File.class.equals(args[0])) {
// Ant Resources/FileProviders override java.io.File
if (Resource.class.equals(as.type) || FileProvider.class.equals(as.type)) {
continue;
}
} }
/* /*
In cases other than those just explicitly covered, In cases other than those just explicitly covered,


+ 16
- 8
src/main/org/apache/tools/ant/Main.java View File

@@ -737,8 +737,10 @@ public class Main implements AntMain {


for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { for (final ArgumentProcessor processor : processorRegistry.getProcessors()) {
final List<String> extraArgs = extraArguments.get(processor.getClass()); final List<String> extraArgs = extraArguments.get(processor.getClass());
if (extraArgs != null && processor.handleArg(extraArgs)) {
return;
if (extraArgs != null) {
if (processor.handleArg(extraArgs)) {
return;
}
} }
} }


@@ -808,8 +810,10 @@ public class Main implements AntMain {


for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { for (final ArgumentProcessor processor : processorRegistry.getProcessors()) {
final List<String> extraArgs = extraArguments.get(processor.getClass()); final List<String> extraArgs = extraArguments.get(processor.getClass());
if (extraArgs != null && processor.handleArg(project, extraArgs)) {
return;
if (extraArgs != null) {
if (processor.handleArg(project, extraArgs)) {
return;
}
} }
} }


@@ -821,8 +825,10 @@ public class Main implements AntMain {
} }


// make sure that we have a target to execute // make sure that we have a target to execute
if (targets.isEmpty() && project.getDefaultTarget() != null) {
targets.addElement(project.getDefaultTarget());
if (targets.isEmpty()) {
if (project.getDefaultTarget() != null) {
targets.addElement(project.getDefaultTarget());
}
} }


project.executeTargets(targets); project.executeTargets(targets);
@@ -1060,8 +1066,10 @@ public class Main implements AntMain {
props.load(in); props.load(in);
in.close(); in.close();
shortAntVersion = props.getProperty("VERSION"); shortAntVersion = props.getProperty("VERSION");
antVersion = "Apache Ant(TM) version " + shortAntVersion
+ " compiled on " + props.getProperty("DATE");
antVersion = "Apache Ant(TM) version " +
shortAntVersion +
" compiled on " +
props.getProperty("DATE");
} catch (final IOException ioe) { } catch (final IOException ioe) {
throw new BuildException("Could not load the version information:" throw new BuildException("Could not load the version information:"
+ ioe.getMessage()); + ioe.getMessage());


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

@@ -268,7 +268,7 @@ public class Project implements ResourceFactory {
public Project createSubProject() { public Project createSubProject() {
Project subProject = null; Project subProject = null;
try { try {
subProject = getClass().newInstance();
subProject = (getClass().newInstance());
} catch (final Exception e) { } catch (final Exception e) {
subProject = new Project(); subProject = new Project();
} }
@@ -927,7 +927,7 @@ public class Project implements ResourceFactory {
throw new BuildException("Ant cannot work on Java prior to 1.8"); throw new BuildException("Ant cannot work on Java prior to 1.8");
} }
log("Detected Java version: " + javaVersion + " in: " log("Detected Java version: " + javaVersion + " in: "
+ JavaEnvUtils.getJavaHome(), MSG_VERBOSE);
+ System.getProperty("java.home"), MSG_VERBOSE);


log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE); log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
} }
@@ -1716,9 +1716,9 @@ public class Project implements ResourceFactory {
* <code>false</code> otherwise. * <code>false</code> otherwise.
*/ */
public static boolean toBoolean(final String s) { public static boolean toBoolean(final String s) {
return "on".equalsIgnoreCase(s)
return ("on".equalsIgnoreCase(s)
|| "true".equalsIgnoreCase(s) || "true".equalsIgnoreCase(s)
|| "yes".equalsIgnoreCase(s);
|| "yes".equalsIgnoreCase(s));
} }


/** /**
@@ -1828,7 +1828,7 @@ public class Project implements ResourceFactory {
.collect(Collectors.joining(",")) .collect(Collectors.joining(","))
+ " is " + ret, MSG_VERBOSE); + " is " + ret, MSG_VERBOSE);


final Vector<Target> complete = returnAll ? ret : new Vector<>(ret);
final Vector<Target> complete = (returnAll) ? ret : new Vector<>(ret);
for (final String curTarget : targetTable.keySet()) { for (final String curTarget : targetTable.keySet()) {
final String st = state.get(curTarget); final String st = state.get(curTarget);
if (st == null) { if (st == null) {


+ 0
- 1
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -128,7 +128,6 @@ public class ProjectHelper {
return name; return name;
} }


@Override
public String toString() { public String toString() {
return name; return name;
} }


+ 30
- 20
src/main/org/apache/tools/ant/PropertyHelper.java View File

@@ -144,7 +144,8 @@ public class PropertyHelper implements GetProperty {
* @param propertyHelper the invoking PropertyHelper. * @param propertyHelper the invoking PropertyHelper.
* @return true if this entity 'owns' the property. * @return true if this entity 'owns' the property.
*/ */
boolean setNew(String property, Object value, PropertyHelper propertyHelper);
boolean setNew(
String property, Object value, PropertyHelper propertyHelper);


/** /**
* Set a property. * Set a property.
@@ -156,7 +157,8 @@ public class PropertyHelper implements GetProperty {
* @param propertyHelper the invoking PropertyHelper. * @param propertyHelper the invoking PropertyHelper.
* @return true if this entity 'owns' the property. * @return true if this entity 'owns' the property.
*/ */
boolean set(String property, Object value, PropertyHelper propertyHelper);
boolean set(
String property, Object value, PropertyHelper propertyHelper);
} }


//TODO PropertyEnumerator Delegate type, would improve PropertySet //TODO PropertyEnumerator Delegate type, would improve PropertySet
@@ -171,7 +173,6 @@ public class PropertyHelper implements GetProperty {
private final String PREFIX = "toString:"; private final String PREFIX = "toString:";
private final int PREFIX_LEN = PREFIX.length(); private final int PREFIX_LEN = PREFIX.length();


@Override
public Object evaluate(String property, PropertyHelper propertyHelper) { public Object evaluate(String property, PropertyHelper propertyHelper) {
Object o = null; Object o = null;
if (property.startsWith(PREFIX) && propertyHelper.getProject() != null) { if (property.startsWith(PREFIX) && propertyHelper.getProject() != null) {
@@ -181,15 +182,18 @@ public class PropertyHelper implements GetProperty {
} }
}; };


private static final PropertyExpander DEFAULT_EXPANDER = (s, pos, notUsed) -> {
private static final PropertyExpander DEFAULT_EXPANDER =
(s, pos, notUsed) -> {
int index = pos.getIndex(); int index = pos.getIndex();
//directly check near, triggering characters: //directly check near, triggering characters:
if (s.length() - index >= 3 && '$' == s.charAt(index) && '{' == s.charAt(index + 1)) {
if (s.length() - index >= 3 && '$' == s.charAt(index)
&& '{' == s.charAt(index + 1)) {
int start = index + 2; int start = index + 2;
//defer to String.indexOf() for protracted check: //defer to String.indexOf() for protracted check:
int end = s.indexOf('}', start); int end = s.indexOf('}', start);
if (end < 0) { if (end < 0) {
throw new BuildException("Syntax error in property: " + s.substring(index));
throw new BuildException(
"Syntax error in property: " + s.substring(index));
} }
pos.setIndex(end + 1); pos.setIndex(end + 1);
return start == end ? "" : s.substring(start, end); return start == end ? "" : s.substring(start, end);
@@ -198,16 +202,19 @@ public class PropertyHelper implements GetProperty {
}; };


/** dummy */ /** dummy */
private static final PropertyExpander SKIP_DOUBLE_DOLLAR = (s, pos, notUsed) -> {
private static final PropertyExpander SKIP_DOUBLE_DOLLAR =
(s, pos, notUsed) -> {
int index = pos.getIndex(); int index = pos.getIndex();
/* check for $$; if found, advance by one--
* this expander is at the bottom of the stack
* and will thus be the last consulted,
* so the next thing that ParseProperties will do
* is advance the parse position beyond the second $
*/
if (s.length() - index >= 2 && '$' == s.charAt(index) && '$' == s.charAt(++index)) {
pos.setIndex(index);
if (s.length() - index >= 2) {
/* check for $$; if found, advance by one--
* this expander is at the bottom of the stack
* and will thus be the last consulted,
* so the next thing that ParseProperties will do
* is advance the parse position beyond the second $
*/
if ('$' == s.charAt(index) && '$' == s.charAt(++index)) {
pos.setIndex(index);
}
} }
return null; return null;
}; };
@@ -219,7 +226,6 @@ public class PropertyHelper implements GetProperty {
private final String PREFIX = "ant.refid:"; private final String PREFIX = "ant.refid:";
private final int PREFIX_LEN = PREFIX.length(); private final int PREFIX_LEN = PREFIX.length();


@Override
public Object evaluate(String prop, PropertyHelper helper) { public Object evaluate(String prop, PropertyHelper helper) {
return prop.startsWith(PREFIX) && helper.getProject() != null return prop.startsWith(PREFIX) && helper.getProject() != null
? helper.getProject().getReference(prop.substring(PREFIX_LEN)) ? helper.getProject().getReference(prop.substring(PREFIX_LEN))
@@ -273,7 +279,8 @@ public class PropertyHelper implements GetProperty {
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
public static Object getProperty(Project project, String name) { public static Object getProperty(Project project, String name) {
return PropertyHelper.getPropertyHelper(project).getProperty(name);
return PropertyHelper.getPropertyHelper(project)
.getProperty(name);
} }


/** /**
@@ -285,7 +292,8 @@ public class PropertyHelper implements GetProperty {
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
public static void setProperty(Project project, String name, Object value) { public static void setProperty(Project project, String name, Object value) {
PropertyHelper.getPropertyHelper(project).setProperty(name, value, true);
PropertyHelper.getPropertyHelper(project)
.setProperty(name, value, true);
} }


/** /**
@@ -296,8 +304,10 @@ public class PropertyHelper implements GetProperty {
* @param value the value to use. * @param value the value to use.
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
public static void setNewProperty(Project project, String name, Object value) {
PropertyHelper.getPropertyHelper(project).setNewProperty(name, value);
public static void setNewProperty(
Project project, String name, Object value) {
PropertyHelper.getPropertyHelper(project)
.setNewProperty(name, value);
} }


//override facility for subclasses to put custom hashtables in //override facility for subclasses to put custom hashtables in


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

@@ -596,9 +596,11 @@ public class RuntimeConfigurable implements Serializable {
} }


// Text // Text
if (r.characters != null
&& (characters == null || characters.toString().trim().isEmpty())) {
characters = new StringBuffer(r.characters.toString());
if (r.characters != null) {
if (characters == null
|| characters.toString().trim().isEmpty()) {
characters = new StringBuffer(r.characters.toString());
}
} }
} }
} }

+ 11
- 6
src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -346,14 +346,19 @@ public class UnknownElement extends Task {
RuntimeConfigurable childWrapper = parentWrapper.getChild(i); RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
UnknownElement child = it.next(); UnknownElement child = it.next();
try { try {
// fall tru and fail in handlechild (unsupported element)
if (!childWrapper.isEnabled(child) && ih.supportsNestedElement(parentUri,
ProjectHelper.genComponentName(child.getNamespace(), child.getTag()))) {
continue;
if (!childWrapper.isEnabled(child)) {
if (ih.supportsNestedElement(
parentUri, ProjectHelper.genComponentName(
child.getNamespace(), child.getTag()))) {
continue;
}
// fall tru and fail in handlechild (unsupported element)
} }
if (!handleChild(parentUri, ih, parent, child, childWrapper)) {
if (!handleChild(
parentUri, ih, parent, child, childWrapper)) {
if (!(parent instanceof TaskContainer)) { if (!(parent instanceof TaskContainer)) {
ih.throwNotSupported(getProject(), parent, child.getTag());
ih.throwNotSupported(getProject(), parent,
child.getTag());
} else { } else {
// a task container - anything could happen - just add the // a task container - anything could happen - just add the
// child to the container // child to the container


+ 1
- 1
src/main/org/apache/tools/ant/dispatch/DispatchUtils.java View File

@@ -104,7 +104,7 @@ public class DispatchUtils {
} catch (InvocationTargetException ie) { } catch (InvocationTargetException ie) {
Throwable t = ie.getTargetException(); Throwable t = ie.getTargetException();
if (t instanceof BuildException) { if (t instanceof BuildException) {
throw (BuildException) t;
throw ((BuildException) t);
} else { } else {
throw new BuildException(t); throw new BuildException(t);
} }


+ 0
- 2
src/main/org/apache/tools/ant/filters/BaseFilterReader.java View File

@@ -78,7 +78,6 @@ public abstract class BaseFilterReader extends FilterReader {
* *
* @exception IOException If an I/O error occurs * @exception IOException If an I/O error occurs
*/ */
@Override
public final int read(final char[] cbuf, final int off, public final int read(final char[] cbuf, final int off,
final int len) throws IOException { final int len) throws IOException {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
@@ -106,7 +105,6 @@ public abstract class BaseFilterReader extends FilterReader {
* @exception IllegalArgumentException If <code>n</code> is negative. * @exception IllegalArgumentException If <code>n</code> is negative.
* @exception IOException If an I/O error occurs * @exception IOException If an I/O error occurs
*/ */
@Override
public final long skip(final long n) public final long skip(final long n)
throws IOException, IllegalArgumentException { throws IOException, IllegalArgumentException {
if (n < 0L) { if (n < 0L) {


+ 10
- 8
src/main/org/apache/tools/ant/filters/ConcatFilter.java View File

@@ -113,14 +113,16 @@ public final class ConcatFilter extends BaseParamFilterReader
if (ch == -1) { if (ch == -1) {
ch = super.read(); ch = super.read();
} }
// don't call super.close() because that reader is used
// on other places ...
if (ch == -1 && appendReader != null) {
ch = appendReader.read();
if (ch == -1) {
// I am the only one so I have to close the reader
appendReader.close();
appendReader = null;
if (ch == -1) {
// don't call super.close() because that reader is used
// on other places ...
if (appendReader != null) {
ch = appendReader.read();
if (ch == -1) {
// I am the only one so I have to close the reader
appendReader.close();
appendReader = null;
}
} }
} }




+ 0
- 16
src/main/org/apache/tools/ant/filters/FixCrLfFilter.java View File

@@ -442,47 +442,38 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
return in instanceof SimpleFilterReader && ((SimpleFilterReader) in).editsBlocked(); return in instanceof SimpleFilterReader && ((SimpleFilterReader) in).editsBlocked();
} }


@Override
public int read() throws IOException { public int read() throws IOException {
return preemptIndex > 0 ? preempt[--preemptIndex] : in.read(); return preemptIndex > 0 ? preempt[--preemptIndex] : in.read();
} }


@Override
public void close() throws IOException { public void close() throws IOException {
in.close(); in.close();
} }


@Override
public void reset() throws IOException { public void reset() throws IOException {
in.reset(); in.reset();
} }


@Override
public boolean markSupported() { public boolean markSupported() {
return in.markSupported(); return in.markSupported();
} }


@Override
public boolean ready() throws IOException { public boolean ready() throws IOException {
return in.ready(); return in.ready();
} }


@Override
public void mark(int i) throws IOException { public void mark(int i) throws IOException {
in.mark(i); in.mark(i);
} }


@Override
public long skip(long i) throws IOException { public long skip(long i) throws IOException {
return in.skip(i); return in.skip(i);
} }


@Override
public int read(char[] buf) throws IOException { public int read(char[] buf) throws IOException {
return read(buf, 0, buf.length); return read(buf, 0, buf.length);
} }


@Override
public int read(char[] buf, int start, int length) throws IOException { public int read(char[] buf, int start, int length) throws IOException {
int count = 0; int count = 0;
int c = 0; int c = 0;
@@ -521,12 +512,10 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
state = JAVA; state = JAVA;
} }


@Override
public boolean editsBlocked() { public boolean editsBlocked() {
return editsBlocked || super.editsBlocked(); return editsBlocked || super.editsBlocked();
} }


@Override
public int read() throws IOException { public int read() throws IOException {
int thisChar = super.read(); int thisChar = super.read();
// Mask, block from being edited, all characters in constants. // Mask, block from being edited, all characters in constants.
@@ -639,7 +628,6 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
this.fixLast = fixLast; this.fixLast = fixLast;
} }


@Override
public int read() throws IOException { public int read() throws IOException {
int thisChar = super.read(); int thisChar = super.read();


@@ -716,7 +704,6 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
super(in); super(in);
} }


@Override
public int read() throws IOException { public int read() throws IOException {
int thisChar = super.read(); int thisChar = super.read();


@@ -746,7 +733,6 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
} }
} }


@Override
public int read() throws IOException { public int read() throws IOException {
int lookAhead2 = super.read(); int lookAhead2 = super.read();


@@ -771,7 +757,6 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
this.tabLength = tabLength; this.tabLength = tabLength;
} }


@Override
public int read() throws IOException { public int read() throws IOException {
int c = super.read(); int c = super.read();


@@ -851,7 +836,6 @@ public final class FixCrLfFilter extends BaseParamFilterReader implements Chaina
this.tabLength = tabLength; this.tabLength = tabLength;
} }


@Override
public int read() throws IOException { public int read() throws IOException {
int c = super.read(); int c = super.read();




+ 9
- 5
src/main/org/apache/tools/ant/filters/HeadFilter.java View File

@@ -203,13 +203,17 @@ public final class HeadFilter extends BaseParamFilterReader
*/ */
private String headFilter(String line) { private String headFilter(String line) {
linesRead++; linesRead++;
if (skip > 0 && (linesRead - 1) < skip) {
return null;
if (skip > 0) {
if ((linesRead - 1) < skip) {
return null;
}
} }


if (lines > 0 && linesRead > (lines + skip)) {
eof = true;
return null;
if (lines > 0) {
if (linesRead > (lines + skip)) {
eof = true;
return null;
}
} }
return line; return line;
} }


+ 19
- 17
src/main/org/apache/tools/ant/filters/StripJavaComments.java View File

@@ -93,30 +93,32 @@ public final class StripJavaComments
quoted = !quoted; quoted = !quoted;
} else { } else {
quoted = false; quoted = false;
if (!inString && ch == '/') {
ch = in.read();
if (!inString) {
if (ch == '/') { if (ch == '/') {
while (ch != '\n' && ch != -1 && ch != '\r') {
ch = in.read();
}
} else if (ch == '*') {
while (ch != -1) {
ch = in.read();
if (ch == '*') {
ch = in.read();
if (ch == '/') {
while (ch != '\n' && ch != -1 && ch != '\r') {
ch = in.read();
}
} else if (ch == '*') {
while (ch != -1) {
ch = in.read(); ch = in.read();
while (ch == '*') {
if (ch == '*') {
ch = in.read(); ch = in.read();
}
while (ch == '*') {
ch = in.read();
}


if (ch == '/') {
ch = read();
break;
if (ch == '/') {
ch = read();
break;
}
} }
} }
} else {
readAheadCh = ch;
ch = '/';
} }
} else {
readAheadCh = ch;
ch = '/';
} }
} }
} }


+ 5
- 3
src/main/org/apache/tools/ant/filters/TabsToSpaces.java View File

@@ -143,9 +143,11 @@ public final class TabsToSpaces
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (Parameter param : params) { for (Parameter param : params) {
if (param != null && TAB_LENGTH_KEY.equals(param.getName())) {
tabLength = Integer.parseInt(param.getValue());
break;
if (param != null) {
if (TAB_LENGTH_KEY.equals(param.getName())) {
tabLength = Integer.parseInt(param.getValue());
break;
}
} }
} }
} }


+ 2
- 8
src/main/org/apache/tools/ant/filters/TokenFilter.java View File

@@ -40,7 +40,8 @@ import org.apache.tools.ant.util.regexp.RegexpUtil;
* @see ChainableReader * @see ChainableReader
* @see org.apache.tools.ant.DynamicConfigurator * @see org.apache.tools.ant.DynamicConfigurator
*/ */
public class TokenFilter extends BaseFilterReader implements ChainableReader {
public class TokenFilter extends BaseFilterReader
implements ChainableReader {
/** /**
* string filters implement this interface * string filters implement this interface
*/ */
@@ -365,7 +366,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @param line the string to be filtered * @param line the string to be filtered
* @return the filtered line * @return the filtered line
*/ */
@Override
public String filter(String line) { public String filter(String line) {
if (from == null) { if (from == null) {
throw new BuildException("Missing from in stringreplace"); throw new BuildException("Missing from in stringreplace");
@@ -420,7 +420,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @return null if the string does not contain "contains", * @return null if the string does not contain "contains",
* string otherwise * string otherwise
*/ */
@Override
public String filter(String string) { public String filter(String string) {
if (contains == null) { if (contains == null) {
throw new BuildException("Missing contains in containsstring"); throw new BuildException("Missing contains in containsstring");
@@ -489,7 +488,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @param line the string to modify * @param line the string to modify
* @return the modified string * @return the modified string
*/ */
@Override
public String filter(String line) { public String filter(String line) {
initialize(); initialize();


@@ -559,7 +557,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @param string the string to apply filter on * @param string the string to apply filter on
* @return the filtered string * @return the filtered string
*/ */
@Override
public String filter(String string) { public String filter(String string) {
initialize(); initialize();
if (!regexp.matches(string, options)) { if (!regexp.matches(string, options)) {
@@ -579,7 +576,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @param line the string to be trimmed * @param line the string to be trimmed
* @return the trimmed string * @return the trimmed string
*/ */
@Override
public String filter(String line) { public String filter(String line) {
return line.trim(); return line.trim();
} }
@@ -593,7 +589,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @param line the line to modify * @param line the line to modify
* @return the trimmed line * @return the trimmed line
*/ */
@Override
public String filter(String line) { public String filter(String line) {
if (line.trim().isEmpty()) { if (line.trim().isEmpty()) {
return null; return null;
@@ -624,7 +619,6 @@ public class TokenFilter extends BaseFilterReader implements ChainableReader {
* @param string the string to remove the characters from * @param string the string to remove the characters from
* @return the converted string * @return the converted string
*/ */
@Override
public String filter(String string) { public String filter(String string) {
StringBuffer output = new StringBuffer(string.length()); StringBuffer output = new StringBuffer(string.length());
for (int i = 0; i < string.length(); ++i) { for (int i = 0; i < string.length(); ++i) {


+ 20
- 15
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -728,8 +728,10 @@ public class ProjectHelper2 extends ProjectHelper {
String value = attrs.getValue(i); String value = attrs.getValue(i);
switch (attrs.getLocalName(i)) { switch (attrs.getLocalName(i)) {
case "default": case "default":
if (value != null && !value.isEmpty() && !context.isIgnoringProjectTag()) {
project.setDefault(value);
if (value != null && !value.isEmpty()) {
if (!context.isIgnoringProjectTag()) {
project.setDefault(value);
}
} }
break; break;
case "name": case "name":
@@ -739,21 +741,22 @@ public class ProjectHelper2 extends ProjectHelper {
if (!context.isIgnoringProjectTag()) { if (!context.isIgnoringProjectTag()) {
project.setName(value); project.setName(value);
project.addReference(value, project); project.addReference(value, project);
} else if (isInIncludeMode() && !value.isEmpty()
&& getCurrentTargetPrefix() != null
&& getCurrentTargetPrefix().endsWith(
ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) {
String newTargetPrefix = getCurrentTargetPrefix().replace(
ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value);
// help nested include tasks
setCurrentTargetPrefix(newTargetPrefix);
} else if (isInIncludeMode()) {
if (!value.isEmpty() && getCurrentTargetPrefix() != null
&& getCurrentTargetPrefix().endsWith(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) {
String newTargetPrefix = getCurrentTargetPrefix().replace(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value);
// help nested include tasks
setCurrentTargetPrefix(newTargetPrefix);
}
} }
} }
break; break;
case "id": case "id":
// What's the difference between id and name ?
if (value != null && !context.isIgnoringProjectTag()) {
project.addReference(value, project);
if (value != null) {
// What's the difference between id and name ?
if (!context.isIgnoringProjectTag()) {
project.addReference(value, project);
}
} }
break; break;
case "basedir": case "basedir":
@@ -1016,8 +1019,10 @@ public class ProjectHelper2 extends ProjectHelper {
project.addOrReplaceTarget(newName, newTarget); project.addOrReplaceTarget(newName, newTarget);
} }
if (extensionPointMissing != null && extensionPoint == null) { if (extensionPointMissing != null && extensionPoint == null) {
throw new BuildException("onMissingExtensionPoint attribute cannot "
+ "be specified unless extensionOf is specified", target.getLocation());
throw new BuildException("onMissingExtensionPoint attribute cannot " +
"be specified unless extensionOf is specified",
target.getLocation());

} }
if (extensionPoint != null) { if (extensionPoint != null) {
ProjectHelper helper = ProjectHelper helper =


+ 0
- 15
src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java View File

@@ -228,7 +228,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if this method is not overridden, or in * @exception SAXParseException if this method is not overridden, or in
* case of error in an overridden version * case of error in an overridden version
*/ */
@Override
public void startElement(String tag, AttributeList attrs) throws SAXParseException { public void startElement(String tag, AttributeList attrs) throws SAXParseException {
throw new SAXParseException("Unexpected element \"" + tag + "\"", helperImpl.locator); throw new SAXParseException("Unexpected element \"" + tag + "\"", helperImpl.locator);
} }
@@ -245,7 +244,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if this method is not overridden, or in * @exception SAXParseException if this method is not overridden, or in
* case of error in an overridden version * case of error in an overridden version
*/ */
@Override
public void characters(char[] buf, int start, int count) throws SAXParseException { public void characters(char[] buf, int start, int count) throws SAXParseException {
String s = new String(buf, start, count).trim(); String s = new String(buf, start, count).trim();


@@ -265,7 +263,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXException in case of error (not thrown in * @exception SAXException in case of error (not thrown in
* this implementation) * this implementation)
*/ */
@Override
public void endElement(String name) throws SAXException { public void endElement(String name) throws SAXException {
// Let parent resume handling SAX events // Let parent resume handling SAX events
helperImpl.parser.setDocumentHandler(parentHandler); helperImpl.parser.setDocumentHandler(parentHandler);
@@ -293,7 +290,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @param systemId The system identifier provided in the XML * @param systemId The system identifier provided in the XML
* document. Will not be <code>null</code>. * document. Will not be <code>null</code>.
*/ */
@Override
public InputSource resolveEntity(String publicId, String systemId) { public InputSource resolveEntity(String publicId, String systemId) {


helperImpl.project.log("resolving systemId: " + systemId, Project.MSG_VERBOSE); helperImpl.project.log("resolving systemId: " + systemId, Project.MSG_VERBOSE);
@@ -333,7 +329,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if the tag given is not * @exception SAXParseException if the tag given is not
* <code>"project"</code> * <code>"project"</code>
*/ */
@Override
public void startElement(String tag, AttributeList attrs) throws SAXParseException { public void startElement(String tag, AttributeList attrs) throws SAXParseException {
if ("project".equals(tag)) { if ("project".equals(tag)) {
new ProjectHandler(helperImpl, this).init(tag, attrs); new ProjectHandler(helperImpl, this).init(tag, attrs);
@@ -349,7 +344,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @param locator The locator used by the parser. * @param locator The locator used by the parser.
* Will not be <code>null</code>. * Will not be <code>null</code>.
*/ */
@Override
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
helperImpl.locator = locator; helperImpl.locator = locator;
} }
@@ -465,7 +459,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* <code>"property"</code>, <code>"target"</code> * <code>"property"</code>, <code>"target"</code>
* or a data type definition * or a data type definition
*/ */
@Override
public void startElement(String name, AttributeList attrs) throws SAXParseException { public void startElement(String name, AttributeList attrs) throws SAXParseException {
if ("target".equals(name)) { if ("target".equals(name)) {
handleTarget(name, attrs); handleTarget(name, attrs);
@@ -603,7 +596,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if an error occurs when initialising * @exception SAXParseException if an error occurs when initialising
* the appropriate child handler * the appropriate child handler
*/ */
@Override
public void startElement(String name, AttributeList attrs) throws SAXParseException { public void startElement(String name, AttributeList attrs) throws SAXParseException {
handleElement(helperImpl, this, target, name, attrs); handleElement(helperImpl, this, target, name, attrs);
} }
@@ -654,7 +646,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @param start The start element in the array. * @param start The start element in the array.
* @param count The number of characters to read from the array. * @param count The number of characters to read from the array.
*/ */
@Override
public void characters(char[] buf, int start, int count) { public void characters(char[] buf, int start, int count) {
String text = new String(buf, start, count); String text = new String(buf, start, count);
String currentDescription = helperImpl.project.getDescription(); String currentDescription = helperImpl.project.getDescription();
@@ -774,7 +765,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @param start The start element in the array. * @param start The start element in the array.
* @param count The number of characters to read from the array. * @param count The number of characters to read from the array.
*/ */
@Override
public void characters(char[] buf, int start, int count) { public void characters(char[] buf, int start, int count) {
wrapper.addText(buf, start, count); wrapper.addText(buf, start, count);
} }
@@ -792,7 +782,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if an error occurs when initialising * @exception SAXParseException if an error occurs when initialising
* the appropriate child handler * the appropriate child handler
*/ */
@Override
public void startElement(String name, AttributeList attrs) throws SAXParseException { public void startElement(String name, AttributeList attrs) throws SAXParseException {
if (task instanceof TaskContainer) { if (task instanceof TaskContainer) {
// task can contain other tasks - no other nested elements possible // task can contain other tasks - no other nested elements possible
@@ -911,7 +900,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @param start The start element in the array. * @param start The start element in the array.
* @param count The number of characters to read from the array. * @param count The number of characters to read from the array.
*/ */
@Override
public void characters(char[] buf, int start, int count) { public void characters(char[] buf, int start, int count) {
childWrapper.addText(buf, start, count); childWrapper.addText(buf, start, count);
} }
@@ -929,7 +917,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if an error occurs when initialising * @exception SAXParseException if an error occurs when initialising
* the appropriate child handler * the appropriate child handler
*/ */
@Override
public void startElement(String name, AttributeList attrs) throws SAXParseException { public void startElement(String name, AttributeList attrs) throws SAXParseException {
if (child instanceof TaskContainer) { if (child instanceof TaskContainer) {
// taskcontainer nested element can contain other tasks - no other // taskcontainer nested element can contain other tasks - no other
@@ -1012,7 +999,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* *
* @see ProjectHelper#addText(Project,Object,char[],int,int) * @see ProjectHelper#addText(Project,Object,char[],int,int)
*/ */
@Override
public void characters(char[] buf, int start, int count) { public void characters(char[] buf, int start, int count) {
wrapper.addText(buf, start, count); wrapper.addText(buf, start, count);
} }
@@ -1029,7 +1015,6 @@ public class ProjectHelperImpl extends ProjectHelper {
* @exception SAXParseException if an error occurs when initialising * @exception SAXParseException if an error occurs when initialising
* the child handler * the child handler
*/ */
@Override
public void startElement(String name, AttributeList attrs) throws SAXParseException { public void startElement(String name, AttributeList attrs) throws SAXParseException {
new NestedElementHandler(helperImpl, this, element, wrapper, target).init(name, attrs); new NestedElementHandler(helperImpl, this, element, wrapper, target).init(name, attrs);
} }


+ 10
- 6
src/main/org/apache/tools/ant/listener/MailLogger.java View File

@@ -143,13 +143,16 @@ public class MailLogger extends DefaultLogger {
} }
Values values = new Values() Values values = new Values()
.mailhost(getValue(properties, "mailhost", "localhost")) .mailhost(getValue(properties, "mailhost", "localhost"))
.port(Integer.parseInt(getValue(properties, "port",
String.valueOf(MailMessage.DEFAULT_PORT))))
.port(Integer.parseInt(
getValue(
properties, "port",
String.valueOf(MailMessage.DEFAULT_PORT))))
.user(getValue(properties, "user", "")) .user(getValue(properties, "user", ""))
.password(getValue(properties, "password", "")) .password(getValue(properties, "password", ""))
.ssl(Project.toBoolean(getValue(properties, "ssl", "off")))
.ssl(Project.toBoolean(getValue(properties,
"ssl", "off")))
.starttls(Project.toBoolean(getValue(properties, .starttls(Project.toBoolean(getValue(properties,
"starttls.enable", "off")))
"starttls.enable", "off")))
.from(getValue(properties, "from", null)) .from(getValue(properties, "from", null))
.replytoList(getValue(properties, "replyto", "")) .replytoList(getValue(properties, "replyto", ""))
.toList(getValue(properties, prefix + ".to", null)) .toList(getValue(properties, prefix + ".to", null))
@@ -158,8 +161,9 @@ public class MailLogger extends DefaultLogger {
.mimeType(getValue(properties, "mimeType", DEFAULT_MIME_TYPE)) .mimeType(getValue(properties, "mimeType", DEFAULT_MIME_TYPE))
.charset(getValue(properties, "charset", "")) .charset(getValue(properties, "charset", ""))
.body(getValue(properties, prefix + ".body", "")) .body(getValue(properties, prefix + ".body", ""))
.subject(getValue(properties, prefix + ".subject",
success ? "Build Success" : "Build Failure"));
.subject(getValue(
properties, prefix + ".subject",
(success) ? "Build Success" : "Build Failure"));
if (values.user().isEmpty() if (values.user().isEmpty()
&& values.password().isEmpty() && values.password().isEmpty()
&& !values.ssl() && !values.starttls()) { && !values.ssl() && !values.starttls()) {


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

@@ -364,7 +364,7 @@ public abstract class AbstractCvsTask extends Task {
log("Caught exception: " + e.getMessage(), Project.MSG_WARN); log("Caught exception: " + e.getMessage(), Project.MSG_WARN);
} catch (BuildException e) { } catch (BuildException e) {
if (failOnError) { if (failOnError) {
throw e;
throw(e);
} }
Throwable t = e.getCause(); Throwable t = e.getCause();
if (t == null) { if (t == null) {


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

@@ -266,10 +266,12 @@ public class Available extends Task implements Condition {
"At least one of (classname|file|resource) is required", "At least one of (classname|file|resource) is required",
getLocation()); getLocation());
} }
if (type != null && file == null) {
throw new BuildException(
if (type != null) {
if (file == null) {
throw new BuildException(
"The type attribute is only valid when specifying the file attribute.", "The type attribute is only valid when specifying the file attribute.",
getLocation()); getLocation());
}
} }
if (classpath != null) { if (classpath != null) {
classpath.setProject(getProject()); classpath.setProject(getProject());
@@ -340,16 +342,19 @@ public class Available extends Task implements Condition {
// ** full-pathname specified == path in list // ** full-pathname specified == path in list
// ** simple name specified == path in list // ** simple name specified == path in list
if (path.exists() if (path.exists()
&& (filename.equals(p) || filename.equals(path.getName()))) {
&& (filename.equals(p)
|| filename.equals(path.getName()))) {
if (type == null) { if (type == null) {
log("Found: " + path, Project.MSG_VERBOSE); log("Found: " + path, Project.MSG_VERBOSE);
return true; return true;
} }
if (type.isDir() && path.isDirectory()) {
if (type.isDir()
&& path.isDirectory()) {
log("Found directory: " + path, Project.MSG_VERBOSE); log("Found directory: " + path, Project.MSG_VERBOSE);
return true; return true;
} }
if (type.isFile() && path.isFile()) {
if (type.isFile()
&& path.isFile()) {
log("Found file: " + path, Project.MSG_VERBOSE); log("Found file: " + path, Project.MSG_VERBOSE);
return true; return true;
} }
@@ -358,7 +363,8 @@ public class Available extends Task implements Condition {
} }
File parent = path.getParentFile(); File parent = path.getParentFile();
// ** full-pathname specified == parent dir of path in list // ** full-pathname specified == parent dir of path in list
if (parent != null && parent.exists() && filename.equals(parent.getAbsolutePath())) {
if (parent != null && parent.exists()
&& filename.equals(parent.getAbsolutePath())) {
if (type == null) { if (type == null) {
log("Found: " + parent, Project.MSG_VERBOSE); log("Found: " + parent, Project.MSG_VERBOSE);
return true; return true;
@@ -371,14 +377,17 @@ public class Available extends Task implements Condition {
return false; return false;
} }
// ** simple name specified == path in list + name // ** simple name specified == path in list + name
if (path.exists() && path.isDirectory()
&& checkFile(new File(path, filename), filename + " in " + path)) {
return true;
if (path.exists() && path.isDirectory()) {
if (checkFile(new File(path, filename),
filename + " in " + path)) {
return true;
}
} }


// ** simple name specified == parent dir + name // ** simple name specified == parent dir + name
while (searchParents && parent != null && parent.exists()) { while (searchParents && parent != null && parent.exists()) {
if (checkFile(new File(parent, filename), filename + " in " + parent)) {
if (checkFile(new File(parent, filename),
filename + " in " + parent)) {
return true; return true;
} }
parent = parent.getParentFile(); parent = parent.getParentFile();


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

@@ -819,12 +819,12 @@ public class Delete extends MatchingTask {
boolean isFsLoop = false; boolean isFsLoop = false;


try { try {
isFsLoop = Files.isSymbolicLink(f.toPath())
&& FileUtils.getFileUtils().isLeadingPath(f.getAbsoluteFile(),
isFsLoop = Files.isSymbolicLink(f.toPath()) &&
FileUtils.getFileUtils().isLeadingPath(f.getAbsoluteFile(),
d.getAbsoluteFile(), true); d.getAbsoluteFile(), true);
} catch (IOException e) { } catch (IOException e) {
log("Failed to check if " + f + " causes a filesystem loop due to "
+ "symbolic link; continuing");
log("Failed to check if " + f + " causes a filesystem loop due to " +
"symbolic link; continuing");
} }


if (f.isDirectory() && !isFsLoop) { if (f.isDirectory() && !isFsLoop) {


+ 6
- 5
src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -361,12 +361,13 @@ public class ExecuteOn extends ExecTask {
Vector<File> baseDirs = new Vector<>(); Vector<File> baseDirs = new Vector<>();
for (AbstractFileSet fs : filesets) { for (AbstractFileSet fs : filesets) {
String currentType = type; String currentType = type;
if (fs instanceof DirSet && !FileDirBoth.DIR.equals(type)) {
log("Found a nested dirset but type is " + type + ". "
+ "Temporarily switching to type=\"dir\" on the assumption"
+ " that you really did mean <dirset> not <fileset>.",
if (fs instanceof DirSet) {
if (!FileDirBoth.DIR.equals(type)) {
log("Found a nested dirset but type is " + type + ". "
+ "Temporarily switching to type=\"dir\" on the assumption that you really did mean <dirset> not <fileset>.",
Project.MSG_DEBUG); Project.MSG_DEBUG);
currentType = FileDirBoth.DIR;
currentType = FileDirBoth.DIR;
}
} }
File base = fs.getDir(getProject()); File base = fs.getDir(getProject());




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

@@ -134,8 +134,8 @@ public class Exit extends Task {
*/ */
@Override @Override
public void execute() throws BuildException { public void execute() throws BuildException {
boolean fail = nestedConditionPresent() ? testNestedCondition()
: testIfCondition() && testUnlessCondition();
boolean fail = (nestedConditionPresent()) ? testNestedCondition()
: (testIfCondition() && testUnlessCondition());
if (fail) { if (fail) {
String text = null; String text = null;
if (message != null && !message.trim().isEmpty()) { if (message != null && !message.trim().isEmpty()) {
@@ -231,7 +231,7 @@ public class Exit extends Task {
* @return <code>boolean</code>. * @return <code>boolean</code>.
*/ */
private boolean nestedConditionPresent() { private boolean nestedConditionPresent() {
return nestedCondition != null;
return (nestedCondition != null);
} }


} }

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

@@ -420,9 +420,10 @@ public class FixCRLF extends MatchingTask implements ChainableReader {
throws BuildException { throws BuildException {
this.srcFile = srcFile; this.srcFile = srcFile;
try { try {
reader = new BufferedReader(encoding == null ? new FileReader(srcFile)
: new InputStreamReader(Files.newInputStream(srcFile.toPath()),
encoding), INBUFLEN);
reader = new BufferedReader(
((encoding == null) ? new FileReader(srcFile)
: new InputStreamReader(
Files.newInputStream(srcFile.toPath()), encoding)), INBUFLEN);


nextLine(); nextLine();
} catch (IOException e) { } catch (IOException e) {


+ 10
- 9
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -53,9 +53,6 @@ public class Java extends Task {
private static final String TIMEOUT_MESSAGE = private static final String TIMEOUT_MESSAGE =
"Timeout: killed the sub-process"; "Timeout: killed the sub-process";


private static final String WRONG_ATTRIBUTES_MESSAGE =
"Cannot use combination of 'classname', 'jar', 'module', 'sourcefile' attributes in same command";

private CommandlineJava cmdl = new CommandlineJava(); private CommandlineJava cmdl = new CommandlineJava();
private Environment env = new Environment(); private Environment env = new Environment();
private boolean fork = false; private boolean fork = false;
@@ -368,7 +365,8 @@ public class Java extends Task {
public void setJar(File jarfile) throws BuildException { public void setJar(File jarfile) throws BuildException {
if (getCommandLine().getClassname() != null || getCommandLine().getModule() != null if (getCommandLine().getClassname() != null || getCommandLine().getModule() != null
|| getCommandLine().getSourceFile() != null) { || getCommandLine().getSourceFile() != null) {
throw new BuildException(WRONG_ATTRIBUTES_MESSAGE);
throw new BuildException(
"Cannot use combination of 'jar', 'sourcefile', 'classname', 'module' attributes in same command");
} }
getCommandLine().setJar(jarfile.getAbsolutePath()); getCommandLine().setJar(jarfile.getAbsolutePath());
} }
@@ -383,7 +381,7 @@ public class Java extends Task {
public void setClassname(String s) throws BuildException { public void setClassname(String s) throws BuildException {
if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) {
throw new BuildException( throw new BuildException(
"Cannot use combination of 'classname', 'jar', 'sourcefile' attributes in same command");
"Cannot use combination of 'jar', 'classname', sourcefile attributes in same command");
} }
getCommandLine().setClassname(s); getCommandLine().setClassname(s);
} }
@@ -399,7 +397,7 @@ public class Java extends Task {
public void setModule(String module) throws BuildException { public void setModule(String module) throws BuildException {
if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) {
throw new BuildException( throw new BuildException(
"Cannot use combination of 'jar', 'module', 'sourcefile' attributes in same command");
"Cannot use combination of 'jar', 'module', sourcefile attributes in same command");
} }
getCommandLine().setModule(module); getCommandLine().setModule(module);
} }
@@ -414,9 +412,12 @@ public class Java extends Task {
* @since Ant 1.10.5 * @since Ant 1.10.5
*/ */
public void setSourceFile(final String sourceFile) throws BuildException { public void setSourceFile(final String sourceFile) throws BuildException {
if (getCommandLine().getClassname() != null || getCommandLine().getJar() != null
|| getCommandLine().getModule() != null) {
throw new BuildException(WRONG_ATTRIBUTES_MESSAGE);
final String jar = getCommandLine().getJar();
final String className = getCommandLine().getClassname();
final String module = getCommandLine().getModule();
if (jar != null || className != null || module != null) {
throw new BuildException("Cannot use 'sourcefile' in combination with 'jar' or " +
"'module' or 'classname'");
} }
getCommandLine().setSourceFile(sourceFile); getCommandLine().setSourceFile(sourceFile);
} }


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

@@ -123,8 +123,10 @@ public class Jikes {
throw new BuildException("Error running Jikes compiler", e); throw new BuildException("Error running Jikes compiler", e);
} }
} finally { } finally {
if (tmpFile != null && !tmpFile.delete()) {
tmpFile.deleteOnExit();
if (tmpFile != null) {
if (!tmpFile.delete()) {
tmpFile.deleteOnExit();
}
} }
} }
} }


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

@@ -169,9 +169,9 @@ public class JikesOutputParser implements ExecuteStreamHandler {


private void log(String line) { private void log(String line) {
if (!emacsMode) { if (!emacsMode) {
task.log("", error ? Project.MSG_ERR : Project.MSG_WARN);
task.log("", (error ? Project.MSG_ERR : Project.MSG_WARN));
} }
task.log(line, error ? Project.MSG_ERR : Project.MSG_WARN);
task.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN));
} }


/** /**


+ 9
- 8
src/main/org/apache/tools/ant/taskdefs/PreSetDef.java View File

@@ -266,9 +266,9 @@ public class PreSetDef extends AntlibDefinition implements TaskContainer {
*/ */
@Override @Override
public boolean sameDefinition(AntTypeDefinition other, Project project) { public boolean sameDefinition(AntTypeDefinition other, Project project) {
return other != null && other.getClass() == getClass() && parent != null
&& parent.sameDefinition(((PreSetDefinition) other).parent, project)
&& element.similar(((PreSetDefinition) other).element);
return (other != null && other.getClass() == getClass() && parent != null
&& parent.sameDefinition(((PreSetDefinition) other).parent, project)
&& element.similar(((PreSetDefinition) other).element));
} }


/** /**
@@ -279,11 +279,12 @@ public class PreSetDef extends AntlibDefinition implements TaskContainer {
* @return true if the definitions are similar. * @return true if the definitions are similar.
*/ */
@Override @Override
public boolean similarDefinition(AntTypeDefinition other, Project project) {
return other != null && other.getClass().getName().equals(getClass().getName())
&& parent != null
&& parent.similarDefinition(((PreSetDefinition) other).parent, project)
&& element.similar(((PreSetDefinition) other).element);
public boolean similarDefinition(
AntTypeDefinition other, Project project) {
return (other != null && other.getClass().getName().equals(
getClass().getName()) && parent != null
&& parent.similarDefinition(((PreSetDefinition) other).parent, project)
&& element.similar(((PreSetDefinition) other).element));
} }
} }
} }

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

@@ -114,7 +114,7 @@ public class Recorder extends Task implements SubBuildListener {
* @param append if true, append to a previous file. * @param append if true, append to a previous file.
*/ */
public void setAppend(boolean append) { public void setAppend(boolean append) {
this.append = append ? Boolean.TRUE : Boolean.FALSE;
this.append = (append ? Boolean.TRUE : Boolean.FALSE);
} }






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

@@ -695,7 +695,8 @@ public class Redirector {
/** outStreams */ /** outStreams */
private void outStreams() { private void outStreams() {
if (out != null && out.length > 0) { if (out != null && out.length > 0) {
final String logHead = "Output " + (appendOut ? "appended" : "redirected") + " to ";
final String logHead = "Output "
+ ((appendOut) ? "appended" : "redirected") + " to ";
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE, outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE,
appendOut, createEmptyFilesOut); appendOut, createEmptyFilesOut);
} }
@@ -716,7 +717,8 @@ public class Redirector {


private void errorStreams() { private void errorStreams() {
if (error != null && error.length > 0) { if (error != null && error.length > 0) {
final String logHead = "Error " + (appendErr ? "appended" : "redirected") + " to ";
final String logHead = "Error "
+ ((appendErr) ? "appended" : "redirected") + " to ";
errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE, errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE,
appendErr, createEmptyFilesErr); appendErr, createEmptyFilesErr);
} else if (!(logError || outputStream == null) && errorProperty == null) { } else if (!(logError || outputStream == null) && errorProperty == null) {


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

@@ -619,14 +619,17 @@ public class SQLExec extends JDBCTask {
sqlCommand = sqlCommand.trim(); sqlCommand = sqlCommand.trim();


try { try {
if (srcFile == null && sqlCommand.isEmpty() && resources == null && transactions.isEmpty()) {
throw new BuildException(
if (srcFile == null && sqlCommand.isEmpty() && resources == null) {
if (transactions.isEmpty()) {
throw new BuildException(
"Source file or resource collection, transactions or sql statement must be set!", "Source file or resource collection, transactions or sql statement must be set!",
getLocation()); getLocation());
}
} }


if (srcFile != null && !srcFile.isFile()) { if (srcFile != null && !srcFile.isFile()) {
throw new BuildException("Source file " + srcFile + " is not a file!", getLocation());
throw new BuildException("Source file " + srcFile
+ " is not a file!", getLocation());
} }


if (resources != null) { if (resources != null) {


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

@@ -70,7 +70,7 @@ public class TaskOutputStream extends OutputStream {
* @param c the character to write * @param c the character to write
* @throws IOException on error * @throws IOException on error
*/ */
@Override
public void write(int c) throws IOException { public void write(int c) throws IOException {
char cc = (char) c; char cc = (char) c;
if (cc == '\r' || cc == '\n') { if (cc == '\r' || cc == '\n') {


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

@@ -254,7 +254,7 @@ public class Touch extends Task {
} }
} }
log("Setting millis to " + workmillis + " from datetime attribute", log("Setting millis to " + workmillis + " from datetime attribute",
millis < 0 ? Project.MSG_DEBUG : Project.MSG_VERBOSE);
((millis < 0) ? Project.MSG_DEBUG : Project.MSG_VERBOSE));
setMillis(workmillis); setMillis(workmillis);
// only set if successful to this point: // only set if successful to this point:
dateTimeConfigured = true; dateTimeConfigured = true;
@@ -352,7 +352,7 @@ public class Touch extends Task {
private void touch(File file, long modTime) { private void touch(File file, long modTime) {
if (!file.exists()) { if (!file.exists()) {
log("Creating " + file, log("Creating " + file,
verbose ? Project.MSG_INFO : Project.MSG_VERBOSE);
((verbose) ? Project.MSG_INFO : Project.MSG_VERBOSE));
try { try {
FILE_UTILS.createNewFile(file, mkdirs); FILE_UTILS.createNewFile(file, mkdirs);
} catch (IOException ioe) { } catch (IOException ioe) {


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

@@ -761,9 +761,11 @@ public class Zip extends MatchingTask {


// If we've been successful on an update, delete the // If we've been successful on an update, delete the
// temporary file // temporary file
if (doUpdate && !renamedFile.delete()) {
log("Warning: unable to delete temporary file "
if (doUpdate) {
if (!renamedFile.delete()) {
log("Warning: unable to delete temporary file "
+ renamedFile.getName(), Project.MSG_WARN); + renamedFile.getName(), Project.MSG_WARN);
}
} }
success = true; success = true;
} finally { } finally {


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/condition/Os.java View File

@@ -264,12 +264,12 @@ public class Os implements Condition {
boolean isNT = false; boolean isNT = false;
if (isWindows) { if (isWindows) {
//there are only four 9x platforms that we look for //there are only four 9x platforms that we look for
//wince isn't really 9x, but crippled enough to
//be a muchness. Ant doesn't run on CE, anyway.
is9x = OS_NAME.contains("95")
is9x = (OS_NAME.contains("95")
|| OS_NAME.contains("98") || OS_NAME.contains("98")
|| OS_NAME.contains("me") || OS_NAME.contains("me")
|| OS_NAME.contains("ce");
//wince isn't really 9x, but crippled enough to
//be a muchness. Ant doesn't run on CE, anyway.
|| OS_NAME.contains("ce"));
isNT = !is9x; isNT = !is9x;
} }
switch (family) { switch (family) {


+ 6
- 5
src/main/org/apache/tools/ant/taskdefs/email/EmailAddress.java View File

@@ -51,11 +51,12 @@ public class EmailAddress {
int len = email.length(); int len = email.length();


// shortcut for "<address>" // shortcut for "<address>"
if (len > minLen
&& (email.charAt(0) == '<' || email.charAt(1) == '<')
&& (email.charAt(len - 1) == '>' || email.charAt(len - 2) == '>')) {
this.address = trim(email, true);
return;
if (len > minLen) {
if ((email.charAt(0) == '<' || email.charAt(1) == '<')
&& (email.charAt(len - 1) == '>' || email.charAt(len - 2) == '>')) {
this.address = trim(email, true);
return;
}
} }


int paramDepth = 0; int paramDepth = 0;


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

@@ -111,7 +111,8 @@ public class MimeMailer extends Mailer {
return type; return type;
} }
// Must be like "text/plain; charset=windows-1251" // Must be like "text/plain; charset=windows-1251"
return (type != null ? type : "text/plain") + "; charset=" + charset;
return (type != null ? type : "text/plain") +
"; charset=" + charset;
} }


@Override @Override


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

@@ -479,7 +479,7 @@ public class SchemaValidate extends XMLValidateTask {
public int hashCode() { public int hashCode() {
int result; int result;
// CheckStyle:MagicNumber OFF // CheckStyle:MagicNumber OFF
result = namespace == null ? 0 : namespace.hashCode();
result = (namespace == null ? 0 : namespace.hashCode());
result = 29 * result + (file == null ? 0 : file.hashCode()); result = 29 * result + (file == null ? 0 : file.hashCode());
result = 29 * result + (url == null ? 0 : url.hashCode()); result = 29 * result + (url == null ? 0 : url.hashCode());
// CheckStyle:MagicNumber OFF // CheckStyle:MagicNumber OFF


+ 0
- 3
src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java View File

@@ -531,7 +531,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Log an error. * Log an error.
* @param e the exception to log. * @param e the exception to log.
*/ */
@Override
public void error(final TransformerException e) { public void error(final TransformerException e) {
logError(e, "Error"); logError(e, "Error");
} }
@@ -540,7 +539,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Log a fatal error. * Log a fatal error.
* @param e the exception to log. * @param e the exception to log.
*/ */
@Override
public void fatalError(final TransformerException e) { public void fatalError(final TransformerException e) {
logError(e, "Fatal Error"); logError(e, "Fatal Error");
throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e); throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e);
@@ -550,7 +548,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Log a warning. * Log a warning.
* @param e the exception to log. * @param e the exception to log.
*/ */
@Override
public void warning(final TransformerException e) { public void warning(final TransformerException e) {
if (!suppressWarnings) { if (!suppressWarnings) {
logError(e, "Warning"); logError(e, "Warning");


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

@@ -364,7 +364,7 @@ public class XMLValidateTask extends Task {
* @return true when a SAX1 parser is in use * @return true when a SAX1 parser is in use
*/ */
protected boolean isSax1Parser() { protected boolean isSax1Parser() {
return xmlReader instanceof ParserAdapter;
return (xmlReader instanceof ParserAdapter);
} }


/** /**
@@ -599,7 +599,6 @@ public class XMLValidateTask extends Task {
* record a fatal error * record a fatal error
* @param exception the fatal error * @param exception the fatal error
*/ */
@Override
public void fatalError(SAXParseException exception) { public void fatalError(SAXParseException exception) {
failed = true; failed = true;
doLog(exception, Project.MSG_ERR); doLog(exception, Project.MSG_ERR);
@@ -608,7 +607,6 @@ public class XMLValidateTask extends Task {
* receive notification of a recoverable error * receive notification of a recoverable error
* @param exception the error * @param exception the error
*/ */
@Override
public void error(SAXParseException exception) { public void error(SAXParseException exception) {
failed = true; failed = true;
doLog(exception, Project.MSG_ERR); doLog(exception, Project.MSG_ERR);
@@ -617,7 +615,6 @@ public class XMLValidateTask extends Task {
* receive notification of a warning * receive notification of a warning
* @param exception the warning * @param exception the warning
*/ */
@Override
public void warning(SAXParseException exception) { public void warning(SAXParseException exception) {
// depending on implementation, XMLReader can yield hips of warning, // depending on implementation, XMLReader can yield hips of warning,
// only output then if user explicitly asked for it // only output then if user explicitly asked for it
@@ -627,6 +624,7 @@ public class XMLValidateTask extends Task {
} }


private void doLog(SAXParseException e, int logLevel) { private void doLog(SAXParseException e, int logLevel) {

log(getMessage(e), logLevel); log(getMessage(e), logLevel);
} }


@@ -745,4 +743,6 @@ public class XMLValidateTask extends Task {


} // Property } // Property




} }

+ 17
- 10
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -305,12 +305,15 @@ public class Depend extends MatchingTask {


List<String> dependencyList = null; List<String> dependencyList = null;


// try to read the dependency info from the map if it is not out of date
if (cache != null && cacheFileExists
if (cache != null) {
// try to read the dependency info from the map if it is
// not out of date
if (cacheFileExists
&& cacheLastModified > info.absoluteFile.lastModified()) { && cacheLastModified > info.absoluteFile.lastModified()) {
// depFile exists and is newer than the class file
// need to get dependency list from the map.
dependencyList = dependencyMap.get(info.className);
// depFile exists and is newer than the class file
// need to get dependency list from the map.
dependencyList = dependencyMap.get(info.className);
}
} }


if (dependencyList == null) { if (dependencyList == null) {
@@ -509,16 +512,20 @@ public class Depend extends MatchingTask {
* @param affectedClass the name of the affected .class file * @param affectedClass the name of the affected .class file
* @param className the file that is triggering the out of dateness * @param className the file that is triggering the out of dateness
*/ */
private void warnOutOfDateButNotDeleted(ClassFileInfo affectedClassInfo, String affectedClass,
private void warnOutOfDateButNotDeleted(
ClassFileInfo affectedClassInfo, String affectedClass,
String className) { String className) {
if (affectedClassInfo.isUserWarned) { if (affectedClassInfo.isUserWarned) {
return; return;
} }
int level = Project.MSG_WARN; int level = Project.MSG_WARN;
// downgrade warnings on RMI stublike classes, as they are generated by rmic,
// so there is no need to tell the user that their source is missing.
if (!warnOnRmiStubs && isRmiStub(affectedClass, className)) {
level = Project.MSG_VERBOSE;
if (!warnOnRmiStubs) {
//downgrade warnings on RMI stublike classes, as they are generated
//by rmic, so there is no need to tell the user that their source is
//missing.
if (isRmiStub(affectedClass, className)) {
level = Project.MSG_VERBOSE;
}
} }
log("The class " + affectedClass + " in file " log("The class " + affectedClass + " in file "
+ affectedClassInfo.absoluteFile.getPath() + affectedClassInfo.absoluteFile.getPath()


+ 9
- 5
src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java View File

@@ -157,10 +157,12 @@ public class DescriptorHandler extends HandlerBase {
return; return;
} }


if (getClass().getResource(location) != null && publicId != null) {
resourceDTDs.put(publicId, location);
owningTask.log("Mapped publicId " + publicId + " to resource "
if (getClass().getResource(location) != null) {
if (publicId != null) {
resourceDTDs.put(publicId, location);
owningTask.log("Mapped publicId " + publicId + " to resource "
+ location, Project.MSG_VERBOSE); + location, Project.MSG_VERBOSE);
}
} }


try { try {
@@ -381,8 +383,10 @@ public class DescriptorHandler extends HandlerBase {
} }


// Get the value of the <ejb-name> tag. Only the first occurrence. // Get the value of the <ejb-name> tag. Only the first occurrence.
if (currentElement.equals(EJB_NAME) && ejbName == null) {
ejbName = currentText.trim();
if (currentElement.equals(EJB_NAME)) {
if (ejbName == null) {
ejbName = currentText.trim();
}
} }
} }
} }

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

@@ -1081,7 +1081,12 @@ public class IPlanetEjbc {
* be run to bring the stubs and skeletons up to date. * be run to bring the stubs and skeletons up to date.
*/ */
public boolean mustBeRecompiled(File destDir) { public boolean mustBeRecompiled(File destDir) {
return destClassesModified(destDir) < sourceClassesModified(destDir);

long sourceModified = sourceClassesModified(destDir);

long destModified = destClassesModified(destDir);

return (destModified < sourceModified);
} }


/** /**
@@ -1231,7 +1236,8 @@ public class IPlanetEjbc {
* names for the stubs and skeletons to be generated. * names for the stubs and skeletons to be generated.
*/ */
private String[] classesToGenerate() { private String[] classesToGenerate() {
String[] classnames = iiop ? new String[NUM_CLASSES_WITH_IIOP]
String[] classnames = (iiop)
? new String[NUM_CLASSES_WITH_IIOP]
: new String[NUM_CLASSES_WITHOUT_IIOP]; : new String[NUM_CLASSES_WITHOUT_IIOP];


final String remotePkg = remote.getPackageName() + "."; final String remotePkg = remote.getPackageName() + ".";


+ 19
- 17
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java View File

@@ -468,27 +468,29 @@ public class JonasDeploymentTool extends GenericDeploymentTool {


String baseName = null; String baseName = null;


// try to find JOnAS specific convention name
if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)
&& !descriptorFileName.contains(getConfig().baseNameTerminator)) {
if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) {


// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
// Foo<baseNameTerminator>-jonas-ejb-jar.xml].
// try to find JOnAS specific convention name
if (!descriptorFileName.contains(getConfig().baseNameTerminator)) {


String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName;
// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
// Foo<baseNameTerminator>-jonas-ejb-jar.xml].


if (lastSeparatorIndex != -1) {
endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
} else {
endOfBaseName = descriptorFileName.indexOf(".xml");
}
String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName;


if (endOfBaseName != -1) {
baseName = descriptorFileName.substring(0, endOfBaseName);
if (lastSeparatorIndex != -1) {
endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
} else {
endOfBaseName = descriptorFileName.indexOf(".xml");
}

if (endOfBaseName != -1) {
baseName = descriptorFileName.substring(0, endOfBaseName);
}
} }
} }




+ 43
- 25
src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java View File

@@ -190,11 +190,12 @@ public final class Extension {
if (null == manifest) { if (null == manifest) {
return new Extension[0]; return new Extension[0];
} }
return Stream.concat(Optional.ofNullable(manifest.getMainAttributes())
.map(Stream::of).orElse(Stream.empty()),
return Stream
.concat(Optional.ofNullable(manifest.getMainAttributes())
.map(Stream::of).orElse(Stream.empty()),
manifest.getEntries().values().stream()) manifest.getEntries().values().stream())
.map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
.toArray(Extension[]::new);
.map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
.toArray(Extension[]::new);
} }


/** /**
@@ -254,13 +255,15 @@ public final class Extension {
specificationVendor); specificationVendor);
} }


final DeweyDecimal specificationVersion = extension.getSpecificationVersion();
final DeweyDecimal specificationVersion
= extension.getSpecificationVersion();
if (null != specificationVersion) { if (null != specificationVersion) {
attributes.putValue(prefix + SPECIFICATION_VERSION, attributes.putValue(prefix + SPECIFICATION_VERSION,
specificationVersion.toString()); specificationVersion.toString());
} }


final String implementationVendorID = extension.getImplementationVendorID();
final String implementationVendorID
= extension.getImplementationVendorID();
if (null != implementationVendorID) { if (null != implementationVendorID) {
attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID, attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID,
implementationVendorID); implementationVendorID);
@@ -272,7 +275,8 @@ public final class Extension {
implementationVendor); implementationVendor);
} }


final DeweyDecimal implementationVersion = extension.getImplementationVersion();
final DeweyDecimal implementationVersion
= extension.getImplementationVersion();
if (null != implementationVersion) { if (null != implementationVersion) {
attributes.putValue(prefix + IMPLEMENTATION_VERSION, attributes.putValue(prefix + IMPLEMENTATION_VERSION,
implementationVersion.toString()); implementationVersion.toString());
@@ -310,7 +314,8 @@ public final class Extension {


if (null != specificationVersion) { if (null != specificationVersion) {
try { try {
this.specificationVersion = new DeweyDecimal(specificationVersion);
this.specificationVersion
= new DeweyDecimal(specificationVersion);
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
final String error = "Bad specification version format '" final String error = "Bad specification version format '"
+ specificationVersion + "' in '" + extensionName + specificationVersion + "' in '" + extensionName
@@ -418,24 +423,33 @@ public final class Extension {
} }


// Available specification version must be >= required // Available specification version must be >= required
final DeweyDecimal requiredSpecificationVersion = required.getSpecificationVersion();
if (null != requiredSpecificationVersion && (null == specificationVersion
|| !isCompatible(specificationVersion, requiredSpecificationVersion))) {
return REQUIRE_SPECIFICATION_UPGRADE;
final DeweyDecimal requiredSpecificationVersion
= required.getSpecificationVersion();
if (null != requiredSpecificationVersion) {
if (null == specificationVersion
|| !isCompatible(specificationVersion, requiredSpecificationVersion)) {
return REQUIRE_SPECIFICATION_UPGRADE;
}
} }


// Implementation Vendor ID must match // Implementation Vendor ID must match
final String requiredImplementationVendorID = required.getImplementationVendorID();
if (null != requiredImplementationVendorID && (null == implementationVendorID
|| !implementationVendorID.equals(requiredImplementationVendorID))) {
return REQUIRE_VENDOR_SWITCH;
final String requiredImplementationVendorID
= required.getImplementationVendorID();
if (null != requiredImplementationVendorID) {
if (null == implementationVendorID
|| !implementationVendorID.equals(requiredImplementationVendorID)) {
return REQUIRE_VENDOR_SWITCH;
}
} }


// Implementation version must be >= required // Implementation version must be >= required
final DeweyDecimal requiredImplementationVersion = required.getImplementationVersion();
if (null != requiredImplementationVersion && (null == implementationVersion
|| !isCompatible(implementationVersion, requiredImplementationVersion))) {
return REQUIRE_IMPLEMENTATION_UPGRADE;
final DeweyDecimal requiredImplementationVersion
= required.getImplementationVersion();
if (null != requiredImplementationVersion) {
if (null == implementationVersion
|| !isCompatible(implementationVersion, requiredImplementationVersion)) {
return REQUIRE_IMPLEMENTATION_UPGRADE;
}
} }


// This available optional package satisfies the requirements // This available optional package satisfies the requirements
@@ -453,7 +467,7 @@ public final class Extension {
* @return true if the specified extension is compatible with this extension * @return true if the specified extension is compatible with this extension
*/ */
public boolean isCompatibleWith(final Extension required) { public boolean isCompatibleWith(final Extension required) {
return COMPATIBLE == getCompatibilityWith(required);
return (COMPATIBLE == getCompatibilityWith(required));
} }


/** /**
@@ -502,7 +516,8 @@ public final class Extension {
* @param first First version number (dotted decimal) * @param first First version number (dotted decimal)
* @param second Second version number (dotted decimal) * @param second Second version number (dotted decimal)
*/ */
private boolean isCompatible(final DeweyDecimal first, final DeweyDecimal second) {
private boolean isCompatible(final DeweyDecimal first,
final DeweyDecimal second) {
return first.isGreaterThanOrEqual(second); return first.isGreaterThanOrEqual(second);
} }


@@ -515,7 +530,8 @@ public final class Extension {
* EXTENSION_LIST or OPTIONAL_EXTENSION_LIST) * EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
* @return the list of listed extensions * @return the list of listed extensions
*/ */
private static Extension[] getListed(final Manifest manifest, final Attributes.Name listKey) {
private static Extension[] getListed(final Manifest manifest,
final Attributes.Name listKey) {
final List<Extension> results = new ArrayList<>(); final List<Extension> results = new ArrayList<>();
final Attributes mainAttributes = manifest.getMainAttributes(); final Attributes mainAttributes = manifest.getMainAttributes();


@@ -560,7 +576,8 @@ public final class Extension {
* @param onToken the token * @param onToken the token
* @return the resultant array * @return the resultant array
*/ */
private static String[] split(final String string, final String onToken) {
private static String[] split(final String string,
final String onToken) {
final StringTokenizer tokenizer = new StringTokenizer(string, onToken); final StringTokenizer tokenizer = new StringTokenizer(string, onToken);
final String[] result = new String[tokenizer.countTokens()]; final String[] result = new String[tokenizer.countTokens()];


@@ -583,7 +600,8 @@ public final class Extension {
* @param attributes Attributes to searched * @param attributes Attributes to searched
* @return the new Extension object, or null * @return the new Extension object, or null
*/ */
private static Extension getExtension(final String prefix, final Attributes attributes) {
private static Extension getExtension(final String prefix,
final Attributes attributes) {
//WARNING: We trim the values of all the attributes because //WARNING: We trim the values of all the attributes because
//Some extension declarations are badly defined (ie have spaces //Some extension declarations are badly defined (ie have spaces
//after version or vendorID) //after version or vendorID)


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java View File

@@ -83,15 +83,15 @@ public class JavahAdapterFactory {
Path classpath) Path classpath)
throws BuildException { throws BuildException {
if ((JavaEnvUtils.isKaffe() && choice == null) if ((JavaEnvUtils.isKaffe() && choice == null)
|| Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
|| Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
return new Kaffeh(); return new Kaffeh();
} }
if ((JavaEnvUtils.isGij() && choice == null) if ((JavaEnvUtils.isGij() && choice == null)
|| Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
|| Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
return new Gcjh(); return new Gcjh();
} }
if (JavaEnvUtils.isAtLeastJavaVersion("10")
&& (choice == null || ForkingJavah.IMPLEMENTATION_NAME.equals(choice))) {
if (JavaEnvUtils.isAtLeastJavaVersion("10") &&
(choice == null || ForkingJavah.IMPLEMENTATION_NAME.equals(choice))) {
throw new BuildException("javah does not exist under Java 10 and higher," throw new BuildException("javah does not exist under Java 10 and higher,"
+ " use the javac task with nativeHeaderDir instead"); + " use the javac task with nativeHeaderDir instead");
} }


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

@@ -1687,12 +1687,13 @@ public class JUnitTask extends Task {
* @since 1.9.8 * @since 1.9.8
*/ */
private void checkModules() { private void checkModules() {
if ((hasPath(getCommandline().getModulepath())
|| hasPath(getCommandline().getUpgrademodulepath()))
&& (!batchTests.stream().allMatch(BaseTest::getFork)
|| !tests.stream().allMatch(BaseTest::getFork))) {
throw new BuildException(
if (hasPath(getCommandline().getModulepath())
|| hasPath(getCommandline().getUpgrademodulepath())) {
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."); "The module path requires fork attribute to be set to true.");
}
} }
} }


@@ -1942,35 +1943,37 @@ public class JUnitTask extends Task {
private void createClassLoader() { private void createClassLoader() {
final Path userClasspath = getCommandline().getClasspath(); final Path userClasspath = getCommandline().getClasspath();
final Path userModulepath = getCommandline().getModulepath(); final Path userModulepath = getCommandline().getModulepath();
if ((userClasspath != null || userModulepath != null) && (reloading || classLoader == null)) {
deleteClassLoader();
final Path path = new Path(getProject());
if (userClasspath != null) {
path.add((Path) userClasspath.clone());
}
if (userModulepath != null && !hasJunit(path)) {
path.add(expandModulePath(userModulepath));
}
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses
if (userClasspath != null || userModulepath != null) {
if (reloading || classLoader == null) {
deleteClassLoader();
final Path path = new Path(getProject());
if (userClasspath != null) {
path.add((Path) userClasspath.clone());
}
if (userModulepath != null && !hasJunit(path)) {
path.add(expandModulePath(userModulepath));
}
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses
+ " to CLASSPATH", Project.MSG_VERBOSE); + " to CLASSPATH", Project.MSG_VERBOSE);
path.append(antRuntimeClasses);
}
classLoader = getProject().createClassLoader(path);
if (getClass().getClassLoader() != null
path.append(antRuntimeClasses);
}
classLoader = getProject().createClassLoader(path);
if (getClass().getClassLoader() != null
&& getClass().getClassLoader() != Project.class.getClassLoader()) { && getClass().getClassLoader() != Project.class.getClassLoader()) {
classLoader.setParent(getClass().getClassLoader());
}
classLoader.setParentFirst(false);
classLoader.addJavaLibraries();
log("Using CLASSPATH " + classLoader.getClasspath(),
classLoader.setParent(getClass().getClassLoader());
}
classLoader.setParentFirst(false);
classLoader.addJavaLibraries();
log("Using CLASSPATH " + classLoader.getClasspath(),
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
// make sure the test will be accepted as a TestCase
classLoader.addSystemPackageRoot("junit");
// make sure the test annotation are accepted
classLoader.addSystemPackageRoot("org.junit");
// will cause trouble in JDK 1.1 if omitted
classLoader.addSystemPackageRoot("org.apache.tools.ant");
// make sure the test will be accepted as a TestCase
classLoader.addSystemPackageRoot("junit");
// make sure the test annotation are accepted
classLoader.addSystemPackageRoot("org.junit");
// will cause trouble in JDK 1.1 if omitted
classLoader.addSystemPackageRoot("org.apache.tools.ant");
}
} }
} }


@@ -2064,7 +2067,8 @@ public class JUnitTask extends Task {
*/ */
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null || other.getClass() != ForkedTestConfiguration.class) {
if (other == null
|| other.getClass() != ForkedTestConfiguration.class) {
return false; return false;
} }
final ForkedTestConfiguration o = (ForkedTestConfiguration) other; final ForkedTestConfiguration o = (ForkedTestConfiguration) other;
@@ -2072,9 +2076,13 @@ public class JUnitTask extends Task {
&& haltOnError == o.haltOnError && haltOnError == o.haltOnError
&& haltOnFailure == o.haltOnFailure && haltOnFailure == o.haltOnFailure
&& ((errorProperty == null && o.errorProperty == null) && ((errorProperty == null && o.errorProperty == null)
|| (errorProperty != null && errorProperty.equals(o.errorProperty)))
||
(errorProperty != null
&& errorProperty.equals(o.errorProperty)))
&& ((failureProperty == null && o.failureProperty == null) && ((failureProperty == null && o.failureProperty == null)
|| (failureProperty != null && failureProperty.equals(o.failureProperty)));
||
(failureProperty != null
&& failureProperty.equals(o.failureProperty)));
} }


/** /**


+ 5
- 8
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java View File

@@ -206,8 +206,8 @@ public class LauncherSupport {
final Optional<Project> project = this.testExecutionContext.getProject(); final Optional<Project> project = this.testExecutionContext.getProject();
for (final ListenerDefinition applicableListener : applicableListenerElements) { for (final ListenerDefinition applicableListener : applicableListenerElements) {
if (project.isPresent() && !applicableListener.shouldUse(project.get())) { if (project.isPresent() && !applicableListener.shouldUse(project.get())) {
log("Excluding listener " + applicableListener.getClassName() + " since it's not applicable"
+ " in the context of project", null, Project.MSG_DEBUG);
log("Excluding listener " + applicableListener.getClassName() + " since it's not applicable" +
" in the context of project", null, Project.MSG_DEBUG);
continue; continue;
} }
final TestExecutionListener listener = requireTestExecutionListener(applicableListener, classLoader); final TestExecutionListener listener = requireTestExecutionListener(applicableListener, classLoader);
@@ -274,8 +274,7 @@ public class LauncherSupport {
throw new BuildException("Failed to load listener class " + className, e); throw new BuildException("Failed to load listener class " + className, e);
} }
if (!TestExecutionListener.class.isAssignableFrom(klass)) { if (!TestExecutionListener.class.isAssignableFrom(klass)) {
throw new BuildException("Listener class " + className + " is not of type "
+ TestExecutionListener.class.getName());
throw new BuildException("Listener class " + className + " is not of type " + TestExecutionListener.class.getName());
} }
try { try {
return (TestExecutionListener) klass.newInstance(); return (TestExecutionListener) klass.newInstance();
@@ -309,8 +308,7 @@ public class LauncherSupport {
// if the test is configured to halt on test failures, throw a build error // if the test is configured to halt on test failures, throw a build error
final String errorMessage; final String errorMessage;
if (test instanceof NamedTest) { if (test instanceof NamedTest) {
errorMessage = "Test " + ((NamedTest) test).getName() + " has "
+ summary.getTestsFailedCount() + " failure(s)";
errorMessage = "Test " + ((NamedTest) test).getName() + " has " + summary.getTestsFailedCount() + " failure(s)";
} else { } else {
errorMessage = "Some test(s) have failure(s)"; errorMessage = "Some test(s) have failure(s)";
} }
@@ -368,8 +366,7 @@ public class LauncherSupport {
final Thread sysErrStreamer = new Thread(streamer); final Thread sysErrStreamer = new Thread(streamer);
sysErrStreamer.setDaemon(true); sysErrStreamer.setDaemon(true);
sysErrStreamer.setName("junitlauncher-syserr-stream-reader"); sysErrStreamer.setName("junitlauncher-syserr-stream-reader");
sysErrStreamer.setUncaughtExceptionHandler((t, e) -> this.log("Failed in syserr streaming",
e, Project.MSG_INFO));
sysErrStreamer.setUncaughtExceptionHandler((t, e) -> this.log("Failed in syserr streaming", e, Project.MSG_INFO));
sysErrStreamer.start(); sysErrStreamer.start();
break; break;
} }


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

@@ -82,7 +82,6 @@ final class TestRequest implements AutoCloseable {
return Collections.unmodifiableList(this.interestedInSysErr); return Collections.unmodifiableList(this.interestedInSysErr);
} }


@Override
public void close() throws Exception { public void close() throws Exception {
if (this.closables.isEmpty()) { if (this.closables.isEmpty()) {
return; return;


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java View File

@@ -87,8 +87,8 @@ public class JUnitLauncherTask extends Task {
final Project project = getProject(); final Project project = getProject();
for (final TestDefinition test : this.tests) { for (final TestDefinition test : this.tests) {
if (!test.shouldRun(project)) { if (!test.shouldRun(project)) {
log("Excluding test " + test + " since it's considered not to run "
+ "in context of project " + project, Project.MSG_DEBUG);
log("Excluding test " + test + " since it's considered not to run " +
"in context of project " + project, Project.MSG_DEBUG);
continue; continue;
} }
if (test.getForkDefinition() != null) { if (test.getForkDefinition() != null) {
@@ -214,8 +214,8 @@ public class JUnitLauncherTask extends Task {
try { try {
projectPropsPath = dumpProjectProperties(); projectPropsPath = dumpProjectProperties();
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Could not create the necessary properties file while forking"
+ " a process for a test", e);
throw new BuildException("Could not create the necessary properties file while forking a process" +
" for a test", e);
} }
// --properties <path-to-properties-file> // --properties <path-to-properties-file>
commandlineJava.createArgument().setValue(Constants.ARG_PROPERTIES); commandlineJava.createArgument().setValue(Constants.ARG_PROPERTIES);


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

@@ -710,25 +710,26 @@ public class FTP extends Task implements FTPTaskConfig {
boolean candidateFound = false; boolean candidateFound = false;
String target = null; String target = null;
for (int icounter = 0; icounter < array.length; icounter++) { for (int icounter = 0; icounter < array.length; icounter++) {
if (array[icounter] != null && array[icounter].isDirectory()
&& !".".equals(array[icounter].getName())
if (array[icounter] != null && array[icounter].isDirectory()) {
if (!".".equals(array[icounter].getName())
&& !"..".equals(array[icounter].getName())) { && !"..".equals(array[icounter].getName())) {
candidateFound = true;
target = fiddleName(array[icounter].getName());
getProject().log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
candidateFound = true;
target = fiddleName(array[icounter].getName());
getProject().log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
&& pcounter != icounter && pcounter != icounter
&& target.equals(array[pcounter].getName())) { && target.equals(array[pcounter].getName())) {
candidateFound = false;
candidateFound = false;
break;
}
}
if (candidateFound) {
break; break;
} }
} }
if (candidateFound) {
break;
}
} }
} }
if (candidateFound) { if (candidateFound) {
@@ -875,7 +876,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @return true if the file exists * @return true if the file exists
*/ */
public boolean exists() { public boolean exists() {
return ftpFile != null;
return (ftpFile != null);
} }


/** /**


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

@@ -72,8 +72,8 @@ class FTPConfigurator {
if (!serverLanguageCodeConfig.isEmpty() if (!serverLanguageCodeConfig.isEmpty()
&& !FTPClientConfig.getSupportedLanguageCodes() && !FTPClientConfig.getSupportedLanguageCodes()
.contains(serverLanguageCodeConfig)) { .contains(serverLanguageCodeConfig)) {
throw new BuildException("unsupported language code"
+ serverLanguageCodeConfig);
throw new BuildException("unsupported language code" +
serverLanguageCodeConfig);
} }
config.setServerLanguageCode(serverLanguageCodeConfig); config.setServerLanguageCode(serverLanguageCodeConfig);
task.log("custom config: server language code = " task.log("custom config: server language code = "


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

@@ -611,25 +611,26 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
boolean candidateFound = false; boolean candidateFound = false;
String target = null; String target = null;
for (int icounter = 0; icounter < array.length; icounter++) { for (int icounter = 0; icounter < array.length; icounter++) {
if (array[icounter] != null && array[icounter].isDirectory()
&& !".".equals(array[icounter].getName())
if (array[icounter] != null && array[icounter].isDirectory()) {
if (!".".equals(array[icounter].getName())
&& !"..".equals(array[icounter].getName())) { && !"..".equals(array[icounter].getName())) {
candidateFound = true;
target = fiddleName(array[icounter].getName());
task.log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
candidateFound = true;
target = fiddleName(array[icounter].getName());
task.log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
&& pcounter != icounter && pcounter != icounter
&& target.equals(array[pcounter].getName())) { && target.equals(array[pcounter].getName())) {
candidateFound = false;
candidateFound = false;
break;
}
}
if (candidateFound) {
break; break;
} }
} }
if (candidateFound) {
break;
}
} }
} }
if (candidateFound) { if (candidateFound) {
@@ -1297,10 +1298,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (i >= 0) { if (i >= 0) {
String cwd = ftp.printWorkingDirectory(); String cwd = ftp.printWorkingDirectory();
String parent = dir.getParent(); String parent = dir.getParent();
if (parent != null && !ftp.changeWorkingDirectory(resolveFile(parent))) {
throw new BuildException(
if (parent != null) {
if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
throw new BuildException(
"could not change to directory: %s", "could not change to directory: %s",
ftp.getReplyString()); ftp.getReplyString());
}
} }


while (i >= 0) { while (i >= 0) {


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

@@ -134,8 +134,10 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
final String remoteFile, final String remoteFile,
final File localFile) throws SftpException { final File localFile) throws SftpException {
String pwd = remoteFile; String pwd = remoteFile;
if (remoteFile.lastIndexOf('/') != -1 && remoteFile.length() > 1) {
pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
if (remoteFile.lastIndexOf('/') != -1) {
if (remoteFile.length() > 1) {
pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
}
} }
channel.cd(pwd); channel.cd(pwd);
if (!localFile.exists()) { if (!localFile.exists()) {
@@ -166,8 +168,10 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
if (!localFile.exists()) { if (!localFile.exists()) {
final String path = localFile.getAbsolutePath(); final String path = localFile.getAbsolutePath();
final int i = path.lastIndexOf(File.pathSeparator); final int i = path.lastIndexOf(File.pathSeparator);
if (i != -1 && path.length() > File.pathSeparator.length()) {
new File(path.substring(0, i)).mkdirs();
if (i != -1) {
if (path.length() > File.pathSeparator.length()) {
new File(path.substring(0, i)).mkdirs();
}
} }
} }




+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java View File

@@ -198,15 +198,16 @@ public class Symlink extends DispatchTask {
public void recreate() throws BuildException { public void recreate() throws BuildException {
try { try {
if (fileSets.isEmpty()) { if (fileSets.isEmpty()) {
handleError("File set identifying link file(s) required for action recreate");
handleError(
"File set identifying link file(s) required for action recreate");
return; return;
} }
final Properties links = loadLinks(fileSets); final Properties links = loadLinks(fileSets);
for (final String lnk : links.stringPropertyNames()) { for (final String lnk : links.stringPropertyNames()) {
final String res = links.getProperty(lnk); final String res = links.getProperty(lnk);
try { try {
if (Files.isSymbolicLink(Paths.get(lnk))
&& new File(lnk).getCanonicalPath().equals(new File(res).getCanonicalPath())) {
if (Files.isSymbolicLink(Paths.get(lnk)) &&
new File(lnk).getCanonicalPath().equals(new File(res).getCanonicalPath())) {
// it's already a symlink and the symlink target is the same // it's already a symlink and the symlink target is the same
// as the target noted in the properties file. So there's no // as the target noted in the properties file. So there's no
// need to recreate it // need to recreate it
@@ -215,8 +216,7 @@ public class Symlink extends DispatchTask {
continue; continue;
} }
} catch (IOException e) { } catch (IOException e) {
final String errMessage = "Failed to check if path " + lnk
+ " is a symbolic link, linking to " + res;
final String errMessage = "Failed to check if path " + lnk + " is a symbolic link, linking to " + res;
if (failonerror) { if (failonerror) {
throw new BuildException(errMessage, e); throw new BuildException(errMessage, e);
} }


+ 4
- 3
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -351,9 +351,10 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
attributes.log("Compilation " + cmd.describeArguments(), attributes.log("Compilation " + cmd.describeArguments(),
Project.MSG_VERBOSE); Project.MSG_VERBOSE);


String niceSourceList = (compileList.size() == 1 ? "File" : "Files") + " to be compiled:"
+ compileList.stream().peek(arg -> cmd.createArgument().setValue(arg))
.collect(Collectors.joining(" "));
String niceSourceList = (compileList.size() == 1 ? "File" : "Files") +
" to be compiled:" +
compileList.stream().peek(arg -> cmd.createArgument().setValue(arg))
.collect(Collectors.joining(" "));
attributes.log(niceSourceList, Project.MSG_VERBOSE); attributes.log(niceSourceList, Project.MSG_VERBOSE);
} }




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

@@ -103,7 +103,7 @@ public abstract class EnumeratedAttribute {
* @return true if the value is valid * @return true if the value is valid
*/ */
public final boolean containsValue(String value) { public final boolean containsValue(String value) {
return indexOfValue(value) != -1;
return (indexOfValue(value) != -1);
} }


/** /**


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

@@ -331,7 +331,8 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
* @param tryUserDir if true try the user directory if the file is not present * @param tryUserDir if true try the user directory if the file is not present
*/ */
public void addExisting(Path source, boolean tryUserDir) { public void addExisting(Path source, boolean tryUserDir) {
File userDir = tryUserDir ? new File(System.getProperty("user.dir")) : null;
File userDir = (tryUserDir) ? new File(System.getProperty("user.dir"))
: null;


for (String name : source.list()) { for (String name : source.list()) {
File f = resolveFile(getProject(), name); File f = resolveFile(getProject(), name);


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

@@ -348,7 +348,7 @@ public class Permissions {
*/ */
@Override @Override
public String toString() { public String toString() {
return String.format("Permission: %s (\"%s\", \"%s\")", className, name, actions);
return ("Permission: " + className + " (\"" + name + "\", \"" + actions + "\")");
} }
} }
} }

+ 4
- 3
src/main/org/apache/tools/ant/types/RedirectorElement.java View File

@@ -342,7 +342,7 @@ public class RedirectorElement extends DataType {
if (isReference()) { if (isReference()) {
throw tooManyAttributes(); throw tooManyAttributes();
} }
this.append = append ? Boolean.TRUE : Boolean.FALSE;
this.append = ((append) ? Boolean.TRUE : Boolean.FALSE);
} }


/** /**
@@ -356,7 +356,7 @@ public class RedirectorElement extends DataType {
if (isReference()) { if (isReference()) {
throw tooManyAttributes(); throw tooManyAttributes();
} }
this.alwaysLog = alwaysLog ? Boolean.TRUE : Boolean.FALSE;
this.alwaysLog = ((alwaysLog) ? Boolean.TRUE : Boolean.FALSE);
} }


/** /**
@@ -368,7 +368,8 @@ public class RedirectorElement extends DataType {
if (isReference()) { if (isReference()) {
throw tooManyAttributes(); throw tooManyAttributes();
} }
this.createEmptyFiles = createEmptyFiles ? Boolean.TRUE : Boolean.FALSE;
this.createEmptyFiles = ((createEmptyFiles)
? Boolean.TRUE : Boolean.FALSE);
} }


/** /**


+ 11
- 9
src/main/org/apache/tools/ant/types/resources/URLResource.java View File

@@ -145,15 +145,17 @@ public class URLResource extends Resource implements URLProvider {
if (isReference()) { if (isReference()) {
return ((URLResource) getCheckedRef()).getURL(); return ((URLResource) getCheckedRef()).getURL();
} }
if (url == null && baseURL != null) {
if (relPath == null) {
throw new BuildException("must provide relativePath"
+ " attribute when using baseURL.");
}
try {
url = new URL(baseURL, relPath);
} catch (MalformedURLException e) {
throw new BuildException(e);
if (url == null) {
if (baseURL != null) {
if (relPath == null) {
throw new BuildException("must provide relativePath"
+ " attribute when using baseURL.");
}
try {
url = new URL(baseURL, relPath);
} catch (MalformedURLException e) {
throw new BuildException(e);
}
} }
} }
return url; return url;


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

@@ -137,12 +137,10 @@ public class ZipResource extends ArchiveResource {
+ getArchive()); + getArchive());
} }
return new FilterInputStream(z.getInputStream(ze)) { return new FilterInputStream(z.getInputStream(ze)) {
@Override
public void close() throws IOException { public void close() throws IOException {
FileUtils.close(in); FileUtils.close(in);
z.close(); z.close();
} }
@Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
try { try {
close(); close();


+ 4
- 4
src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java View File

@@ -278,8 +278,8 @@ public final class SelectorUtils {
} }
// Find the pattern between padIdxStart & padIdxTmp in str between // Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd // strIdxStart & strIdxEnd
int patLength = patIdxTmp - patIdxStart - 1;
int strLength = strIdxEnd - strIdxStart + 1;
int patLength = (patIdxTmp - patIdxStart - 1);
int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1; int foundIdx = -1;
strLoop: strLoop:
for (int i = 0; i <= strLength - patLength; i++) { for (int i = 0; i <= strLength - patLength; i++) {
@@ -433,8 +433,8 @@ public final class SelectorUtils {
} }
// Find the pattern between padIdxStart & padIdxTmp in str between // Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd // strIdxStart & strIdxEnd
int patLength = patIdxTmp - patIdxStart - 1;
int strLength = strIdxEnd - strIdxStart + 1;
int patLength = (patIdxTmp - patIdxStart - 1);
int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1; int foundIdx = -1;
strLoop: strLoop:
for (int i = 0; i <= strLength - patLength; i++) { for (int i = 0; i <= strLength - patLength; i++) {


+ 0
- 3
src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java View File

@@ -89,7 +89,6 @@ public class TokenizedPattern {
/** /**
* @return The pattern String * @return The pattern String
*/ */
@Override
public String toString() { public String toString() {
return pattern; return pattern;
} }
@@ -103,13 +102,11 @@ public class TokenizedPattern {
* *
* @param o Object * @param o Object
*/ */
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof TokenizedPattern return o instanceof TokenizedPattern
&& pattern.equals(((TokenizedPattern) o).pattern); && pattern.equals(((TokenizedPattern) o).pattern);
} }


@Override
public int hashCode() { public int hashCode() {
return pattern.hashCode(); return pattern.hashCode();
} }


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

@@ -38,7 +38,6 @@ public class EqualComparator implements Comparator<Object> {
* @param o2 the second object * @param o2 the second object
* @return 0, if both are equal, otherwise 1 * @return 0, if both are equal, otherwise 1
*/ */
@Override
public int compare(Object o1, Object o2) { public int compare(Object o1, Object o2) {
if (o1 == null) { if (o1 == null) {
if (o2 == null) { if (o2 == null) {
@@ -46,14 +45,13 @@ public class EqualComparator implements Comparator<Object> {
} }
return 0; return 0;
} }
return o1.equals(o2) ? 0 : 1;
return (o1.equals(o2)) ? 0 : 1;
} }


/** /**
* Override Object.toString(). * Override Object.toString().
* @return information about this comparator * @return information about this comparator
*/ */
@Override
public String toString() { public String toString() {
return "EqualComparator"; return "EqualComparator";
} }


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

@@ -73,7 +73,6 @@ public class HashvalueAlgorithm implements Algorithm {
* Override Object.toString(). * Override Object.toString().
* @return information about this comparator * @return information about this comparator
*/ */
@Override
public String toString() { public String toString() {
return "HashvalueAlgorithm"; return "HashvalueAlgorithm";
} }


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

@@ -459,7 +459,7 @@ public class ModifiedSelector extends BaseExtendSelector
+ resource.getName() + resource.getName()
+ "' does not provide an InputStream, so it is not checked. " + "' does not provide an InputStream, so it is not checked. "
+ "According to 'selres' attribute value it is " + "According to 'selres' attribute value it is "
+ (selectResourcesWithoutInputStream ? "" : " not")
+ ((selectResourcesWithoutInputStream) ? "" : " not")
+ "selected.", Project.MSG_INFO); + "selected.", Project.MSG_INFO);
return selectResourcesWithoutInputStream; return selectResourcesWithoutInputStream;
} catch (Exception e) { } catch (Exception e) {


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

@@ -118,7 +118,7 @@ public class PropertiesfileCache implements Cache {
*/ */
@Override @Override
public boolean isValid() { public boolean isValid() {
return cachefile != null;
return (cachefile != null);
} }






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

@@ -91,7 +91,7 @@ public class Base64Converter {
out[outIndex++] = ALPHABET[bits6]; out[outIndex++] = ALPHABET[bits6];
bits6 = (bits24 & POS_1_MASK) >> POS_1_SHIFT; bits6 = (bits24 & POS_1_MASK) >> POS_1_SHIFT;
out[outIndex++] = ALPHABET[bits6]; out[outIndex++] = ALPHABET[bits6];
bits6 = bits24 & POS_0_MASK;
bits6 = (bits24 & POS_0_MASK);
out[outIndex++] = ALPHABET[bits6]; out[outIndex++] = ALPHABET[bits6];
} }
if (octetString.length - i == 2) { if (octetString.length - i == 2) {


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

@@ -515,7 +515,7 @@ public class DOMElementWriter {
int prevEnd = 0; int prevEnd = 0;
int cdataEndPos = value.indexOf("]]>"); int cdataEndPos = value.indexOf("]]>");
while (prevEnd < len) { while (prevEnd < len) {
final int end = cdataEndPos < 0 ? len : cdataEndPos;
final int end = (cdataEndPos < 0 ? len : cdataEndPos);
// Write out stretches of legal characters in the range [prevEnd, end). // Write out stretches of legal characters in the range [prevEnd, end).
int prevLegalCharPos = prevEnd; int prevLegalCharPos = prevEnd;
while (prevLegalCharPos < end) { while (prevLegalCharPos < end) {


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

@@ -1181,7 +1181,7 @@ public class FileUtils {
if (!l.endsWith(File.separator)) { if (!l.endsWith(File.separator)) {
l += File.separator; l += File.separator;
} }
return p.startsWith(l) ? p.substring(l.length()) : p;
return (p.startsWith(l)) ? p.substring(l.length()) : p;
} }


/** /**


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

@@ -198,8 +198,10 @@ public class GlobPatternMapper implements FileNameMapper {
if (!caseSensitive) { if (!caseSensitive) {
name = name.toLowerCase(); name = name.toLowerCase();
} }
if (handleDirSep && name.contains("\\")) {
name = name.replace('\\', '/');
if (handleDirSep) {
if (name.contains("\\")) {
name = name.replace('\\', '/');
}
} }
return name; return name;
} }


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

@@ -50,7 +50,6 @@ public class KeepAliveInputStream extends FilterInputStream {
* This method does nothing. * This method does nothing.
* @throws IOException as we are overriding FilterInputStream. * @throws IOException as we are overriding FilterInputStream.
*/ */
@Override
public void close() throws IOException { public void close() throws IOException {
// do not close the stream // do not close the stream
} }


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

@@ -50,7 +50,6 @@ public class KeepAliveOutputStream extends FilterOutputStream {
* This method does nothing. * This method does nothing.
* @throws IOException as we are overriding FilterOutputStream. * @throws IOException as we are overriding FilterOutputStream.
*/ */
@Override
public void close() throws IOException { public void close() throws IOException {
// do not close the stream // do not close the stream
} }


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

@@ -294,9 +294,11 @@ public class LayoutPreservingProperties extends Properties {
boolean writtenSep = false; boolean writtenSep = false;
for (LogicalLine line : logicalLines.subList(skipLines, totalLines)) { for (LogicalLine line : logicalLines.subList(skipLines, totalLines)) {
if (line instanceof Pair) { if (line instanceof Pair) {
if (((Pair) line).isNew() && !writtenSep) {
osw.write(eol);
writtenSep = true;
if (((Pair) line).isNew()) {
if (!writtenSep) {
osw.write(eol);
writtenSep = true;
}
} }
osw.write(line.toString() + eol); osw.write(line.toString() + eol);
} else if (line != null) { } else if (line != null) {


+ 0
- 7
src/main/org/apache/tools/ant/util/LazyHashtable.java View File

@@ -55,7 +55,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* Get a enumeration over the elements. * Get a enumeration over the elements.
* @return an enumeration. * @return an enumeration.
*/ */
@Override
public Enumeration<V> elements() { public Enumeration<V> elements() {
initAll(); initAll();
return super.elements(); return super.elements();
@@ -65,7 +64,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* Check if the table is empty. * Check if the table is empty.
* @return true if it is. * @return true if it is.
*/ */
@Override
public boolean isEmpty() { public boolean isEmpty() {
initAll(); initAll();
return super.isEmpty(); return super.isEmpty();
@@ -75,7 +73,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* Get the size of the table. * Get the size of the table.
* @return the size. * @return the size.
*/ */
@Override
public int size() { public int size() {
initAll(); initAll();
return super.size(); return super.size();
@@ -86,7 +83,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* @param value the value to look for. * @param value the value to look for.
* @return true if the table contains the value. * @return true if the table contains the value.
*/ */
@Override
public boolean contains(Object value) { public boolean contains(Object value) {
initAll(); initAll();
return super.contains(value); return super.contains(value);
@@ -97,7 +93,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* @param value the key to look for. * @param value the key to look for.
* @return true if the table contains key. * @return true if the table contains key.
*/ */
@Override
public boolean containsKey(Object value) { public boolean containsKey(Object value) {
initAll(); initAll();
return super.containsKey(value); return super.containsKey(value);
@@ -108,7 +103,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* @param value the value to look for. * @param value the value to look for.
* @return true if the table contains the value. * @return true if the table contains the value.
*/ */
@Override
public boolean containsValue(Object value) { public boolean containsValue(Object value) {
return contains(value); return contains(value);
} }
@@ -117,7 +111,6 @@ public class LazyHashtable<K, V> extends Hashtable<K, V> {
* Get an enumeration over the keys. * Get an enumeration over the keys.
* @return an enumeration. * @return an enumeration.
*/ */
@Override
public Enumeration<K> keys() { public Enumeration<K> keys() {
initAll(); initAll();
return super.keys(); return super.keys();


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

@@ -59,7 +59,6 @@ public class LinkedHashtable<K, V> extends Hashtable<K, V> {
map = new LinkedHashMap<>(m); map = new LinkedHashMap<>(m);
} }


@Override
public synchronized void clear() { public synchronized void clear() {
map.clear(); map.clear();
} }


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

@@ -118,10 +118,13 @@ public class RegexpPatternMapper implements FileNameMapper {
if (sourceFileName == null) { if (sourceFileName == null) {
return null; return null;
} }
if (handleDirSep && sourceFileName.contains("\\")) {
sourceFileName = sourceFileName.replace('\\', '/');
if (handleDirSep) {
if (sourceFileName.contains("\\")) {
sourceFileName = sourceFileName.replace('\\', '/');
}
} }
if (reg == null || to == null || !reg.matches(sourceFileName, regexpOptions)) {
if (reg == null || to == null
|| !reg.matches(sourceFileName, regexpOptions)) {
return null; return null;
} }
return new String[] {replaceReferences(sourceFileName)}; return new String[] {replaceReferences(sourceFileName)};


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

@@ -36,7 +36,6 @@ public class StreamUtils {
public static <T> Stream<T> enumerationAsStream(Enumeration<T> e) { public static <T> Stream<T> enumerationAsStream(Enumeration<T> e) {
return StreamSupport.stream( return StreamSupport.stream(
new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) { new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) {
@Override
public boolean tryAdvance(Consumer<? super T> action) { public boolean tryAdvance(Consumer<? super T> action) {
if (e.hasMoreElements()) { if (e.hasMoreElements()) {
action.accept(e.nextElement()); action.accept(e.nextElement());
@@ -44,7 +43,6 @@ public class StreamUtils {
} }
return false; return false;
} }
@Override
public void forEachRemaining(Consumer<? super T> action) { public void forEachRemaining(Consumer<? super T> action) {
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
action.accept(e.nextElement()); action.accept(e.nextElement());


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

@@ -157,7 +157,6 @@ public class WorkerAnt extends Thread {
* Run the task, which is skipped if null. * Run the task, which is skipped if null.
* When invoked again, the task is re-run. * When invoked again, the task is re-run.
*/ */
@Override
public void run() { public void run() {
try { try {
if (task != null) { if (task != null) {


+ 1
- 1
src/main/org/apache/tools/bzip2/BZip2Constants.java View File

@@ -42,7 +42,7 @@ public interface BZip2Constants {
int N_GROUPS = 6; int N_GROUPS = 6;
int G_SIZE = 50; int G_SIZE = 50;
int N_ITERS = 4; int N_ITERS = 4;
int MAX_SELECTORS = 2 + 900000 / G_SIZE;
int MAX_SELECTORS = (2 + (900000 / G_SIZE));
int NUM_OVERSHOOT_BYTES = 20; int NUM_OVERSHOOT_BYTES = 20;


/** /**


+ 8
- 8
src/main/org/apache/tools/bzip2/BlockSort.java View File

@@ -686,17 +686,17 @@ class BlockSort {
i2 -= lastPlus1; i2 -= lastPlus1;
} }
workDoneShadow++; workDoneShadow++;
} else if (quadrant[i1 + 3] > quadrant[i2 + 3]) {
} else if ((quadrant[i1 + 3] > quadrant[i2 + 3])) {
continue HAMMER; continue HAMMER;
} else { } else {
break HAMMER; break HAMMER;
} }
} else if ((block[i2 + 4] & 0xff) < (block[i1 + 4] & 0xff)) {
} else if ((block[i1 + 4] & 0xff) > (block[i2 + 4] & 0xff)) {
continue HAMMER; continue HAMMER;
} else { } else {
break HAMMER; break HAMMER;
} }
} else if (quadrant[i1 + 2] > quadrant[i2 + 2]) {
} else if ((quadrant[i1 + 2] > quadrant[i2 + 2])) {
continue HAMMER; continue HAMMER;
} else { } else {
break HAMMER; break HAMMER;
@@ -706,7 +706,7 @@ class BlockSort {
} else { } else {
break HAMMER; break HAMMER;
} }
} else if (quadrant[i1 + 1] > quadrant[i2 + 1]) {
} else if ((quadrant[i1 + 1] > quadrant[i2 + 1])) {
continue HAMMER; continue HAMMER;
} else { } else {
break HAMMER; break HAMMER;
@@ -716,7 +716,7 @@ class BlockSort {
} else { } else {
break HAMMER; break HAMMER;
} }
} else if (quadrant[i1] > quadrant[i2]) {
} else if ((quadrant[i1] > quadrant[i2])) {
continue HAMMER; continue HAMMER;
} else { } else {
break HAMMER; break HAMMER;
@@ -900,8 +900,8 @@ class BlockSort {
} }
} }


private static final int SETMASK = 1 << 21;
private static final int CLEARMASK = ~SETMASK;
private static final int SETMASK = (1 << 21);
private static final int CLEARMASK = (~SETMASK);


final void mainSort(final CBZip2OutputStream.Data dataShadow, final void mainSort(final CBZip2OutputStream.Data dataShadow,
final int lastShadow) { final int lastShadow) {
@@ -1024,7 +1024,7 @@ class BlockSort {
copy[j] = ftab[(j << 8) + ss] & CLEARMASK; copy[j] = ftab[(j << 8) + ss] & CLEARMASK;
} }


for (int j = ftab[ss << 8] & CLEARMASK, hj = ftab[ss + 1 << 8] & CLEARMASK; j < hj; j++) {
for (int j = ftab[ss << 8] & CLEARMASK, hj = (ftab[(ss + 1) << 8] & CLEARMASK); j < hj; j++) {
final int fmap_j = fmap[j]; final int fmap_j = fmap[j];
c1 = block[fmap_j] & 0xff; c1 = block[fmap_j] & 0xff;
if (!bigDone[c1]) { if (!bigDone[c1]) {


+ 11
- 6
src/main/org/apache/tools/bzip2/CBZip2OutputStream.java View File

@@ -143,14 +143,14 @@ public class CBZip2OutputStream extends OutputStream
* purposes. If you don't know what it means then you don't need * purposes. If you don't know what it means then you don't need
* it. * it.
*/ */
protected static final int SETMASK = 1 << 21;
protected static final int SETMASK = (1 << 21);


/** /**
* This constant is accessible by subclasses for historical * This constant is accessible by subclasses for historical
* purposes. If you don't know what it means then you don't need * purposes. If you don't know what it means then you don't need
* it. * it.
*/ */
protected static final int CLEARMASK = ~SETMASK;
protected static final int CLEARMASK = (~SETMASK);


/** /**
* This constant is accessible by subclasses for historical * This constant is accessible by subclasses for historical
@@ -322,9 +322,14 @@ public class CBZip2OutputStream extends OutputStream


final int weight_n1 = weight[n1]; final int weight_n1 = weight[n1];
final int weight_n2 = weight[n2]; final int weight_n2 = weight[n2];
weight[nNodes] = (weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)
| 1 + ((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)
? weight_n1 & 0x000000ff : weight_n2 & 0x000000ff);
weight[nNodes] = (((weight_n1 & 0xffffff00)
+ (weight_n2 & 0xffffff00))
|
(1 + (((weight_n1 & 0x000000ff)
> (weight_n2 & 0x000000ff))
? (weight_n1 & 0x000000ff)
: (weight_n2 & 0x000000ff))
));


parent[nNodes] = -1; parent[nNodes] = -1;
nHeap++; nHeap++;
@@ -1560,7 +1565,7 @@ public class CBZip2OutputStream extends OutputStream
super(); super();


final int n = blockSize100k * BZip2Constants.baseBlockSize; final int n = blockSize100k * BZip2Constants.baseBlockSize;
this.block = new byte[n + 1 + NUM_OVERSHOOT_BYTES];
this.block = new byte[(n + 1 + NUM_OVERSHOOT_BYTES)];
this.fmap = new int[n]; this.fmap = new int[n];
this.sfmap = new char[2 * n]; this.sfmap = new char[2 * n];
} }


+ 30
- 15
src/main/org/apache/tools/tar/TarBuffer.java View File

@@ -44,10 +44,10 @@ import java.util.Arrays;
public class TarBuffer { public class TarBuffer {


/** Default record size */ /** Default record size */
public static final int DEFAULT_RCDSIZE = 512;
public static final int DEFAULT_RCDSIZE = (512);


/** Default block size */ /** Default block size */
public static final int DEFAULT_BLKSIZE = DEFAULT_RCDSIZE * 20;
public static final int DEFAULT_BLKSIZE = (DEFAULT_RCDSIZE * 20);


private InputStream inStream; private InputStream inStream;
private OutputStream outStream; private OutputStream outStream;
@@ -123,7 +123,7 @@ public class TarBuffer {
this.debug = false; this.debug = false;
this.blockSize = blockSize; this.blockSize = blockSize;
this.recordSize = recordSize; this.recordSize = recordSize;
this.recsPerBlock = this.blockSize / this.recordSize;
this.recsPerBlock = (this.blockSize / this.recordSize);
this.blockBuffer = new byte[this.blockSize]; this.blockBuffer = new byte[this.blockSize];


if (this.inStream != null) { if (this.inStream != null) {
@@ -183,7 +183,8 @@ public class TarBuffer {
*/ */
public void skipRecord() throws IOException { public void skipRecord() throws IOException {
if (debug) { if (debug) {
System.err.printf("SkipRecord: recIdx = %d blkIdx = %d%n", currRecIdx, currBlkIdx);
System.err.println("SkipRecord: recIdx = " + currRecIdx
+ " blkIdx = " + currBlkIdx);
} }


if (inStream == null) { if (inStream == null) {
@@ -205,7 +206,8 @@ public class TarBuffer {
*/ */
public byte[] readRecord() throws IOException { public byte[] readRecord() throws IOException {
if (debug) { if (debug) {
System.err.printf("ReadRecord: recIdx = %d blkIdx = %d%n", currRecIdx, currBlkIdx);
System.err.println("ReadRecord: recIdx = " + currRecIdx
+ " blkIdx = " + currBlkIdx);
} }


if (inStream == null) { if (inStream == null) {
@@ -221,7 +223,9 @@ public class TarBuffer {


byte[] result = new byte[recordSize]; byte[] result = new byte[recordSize];


System.arraycopy(blockBuffer, currRecIdx * recordSize, result, 0, recordSize);
System.arraycopy(blockBuffer,
(currRecIdx * recordSize), result, 0,
recordSize);


currRecIdx++; currRecIdx++;


@@ -246,7 +250,8 @@ public class TarBuffer {
int bytesNeeded = blockSize; int bytesNeeded = blockSize;


while (bytesNeeded > 0) { while (bytesNeeded > 0) {
long numBytes = inStream.read(blockBuffer, offset, bytesNeeded);
long numBytes = inStream.read(blockBuffer, offset,
bytesNeeded);


// //
// NOTE // NOTE
@@ -282,9 +287,12 @@ public class TarBuffer {
offset += numBytes; offset += numBytes;
bytesNeeded -= numBytes; bytesNeeded -= numBytes;


if (numBytes != blockSize && debug) {
System.err.printf("ReadBlock: INCOMPLETE READ %d of %d bytes read.%n",
numBytes, blockSize);
if (numBytes != blockSize) {
if (debug) {
System.err.println("ReadBlock: INCOMPLETE READ "
+ numBytes + " of " + blockSize
+ " bytes read.");
}
} }
} }


@@ -320,7 +328,8 @@ public class TarBuffer {
*/ */
public void writeRecord(byte[] record) throws IOException { public void writeRecord(byte[] record) throws IOException {
if (debug) { if (debug) {
System.err.printf("WriteRecord: recIdx = %d blkIdx = %d%n", currRecIdx, currBlkIdx);
System.err.println("WriteRecord: recIdx = " + currRecIdx
+ " blkIdx = " + currBlkIdx);
} }


if (outStream == null) { if (outStream == null) {
@@ -341,7 +350,9 @@ public class TarBuffer {
writeBlock(); writeBlock();
} }


System.arraycopy(record, 0, blockBuffer, currRecIdx * recordSize, recordSize);
System.arraycopy(record, 0, blockBuffer,
(currRecIdx * recordSize),
recordSize);


currRecIdx++; currRecIdx++;
} }
@@ -357,7 +368,8 @@ public class TarBuffer {
*/ */
public void writeRecord(byte[] buf, int offset) throws IOException { public void writeRecord(byte[] buf, int offset) throws IOException {
if (debug) { if (debug) {
System.err.printf("WriteRecord: recIdx = %d blkIdx = %d%n", currRecIdx, currBlkIdx);
System.err.println("WriteRecord: recIdx = " + currRecIdx
+ " blkIdx = " + currBlkIdx);
} }


if (outStream == null) { if (outStream == null) {
@@ -378,7 +390,9 @@ public class TarBuffer {
writeBlock(); writeBlock();
} }


System.arraycopy(buf, offset, blockBuffer, currRecIdx * recordSize, recordSize);
System.arraycopy(buf, offset, blockBuffer,
(currRecIdx * recordSize),
recordSize);


currRecIdx++; currRecIdx++;
} }
@@ -433,7 +447,8 @@ public class TarBuffer {
if (outStream != null) { if (outStream != null) {
flushBlock(); flushBlock();


if (outStream != System.out && outStream != System.err) {
if (outStream != System.out
&& outStream != System.err) {
outStream.close(); outStream.close();


outStream = null; outStream = null;


+ 1
- 1
src/main/org/apache/tools/tar/TarInputStream.java View File

@@ -215,7 +215,7 @@ public class TarInputStream extends FilterInputStream {
} }
skip -= numRead; skip -= numRead;
} }
return numToSkip - skip;
return (numToSkip - skip);
} }


/** /**


+ 2
- 2
src/main/org/apache/tools/tar/TarUtils.java View File

@@ -493,8 +493,8 @@ public class TarUtils {
final long max = 1L << bits; final long max = 1L << bits;
long val = Math.abs(value); long val = Math.abs(value);
if (val >= max) { if (val >= max) {
throw new IllegalArgumentException("Value " + value
+ " is too large for " + length + " byte field.");
throw new IllegalArgumentException("Value " + value +
" is too large for " + length + " byte field.");
} }
if (negative) { if (negative) {
val ^= max - 1; val ^= max - 1;


+ 0
- 1
src/main/org/apache/tools/zip/Simple8BitZipEncoding.java View File

@@ -58,7 +58,6 @@ class Simple8BitZipEncoding implements ZipEncoding {
this.unicode = unicode; this.unicode = unicode;
} }


@Override
public int compareTo(final Simple8BitChar a) { public int compareTo(final Simple8BitChar a) {
return this.unicode - a.unicode; return this.unicode - a.unicode;
} }


+ 1
- 1
src/main/org/apache/tools/zip/ZipEightByteInteger.java View File

@@ -136,7 +136,7 @@ public final class ZipEightByteInteger {
public static byte[] getBytes(BigInteger value) { public static byte[] getBytes(BigInteger value) {
byte[] result = new byte[8]; byte[] result = new byte[8];
long val = value.longValue(); long val = value.longValue();
result[0] = (byte) (val & BYTE_MASK);
result[0] = (byte) ((val & BYTE_MASK));
result[BYTE_1] = (byte) ((val & BYTE_1_MASK) >> BYTE_1_SHIFT); result[BYTE_1] = (byte) ((val & BYTE_1_MASK) >> BYTE_1_SHIFT);
result[BYTE_2] = (byte) ((val & BYTE_2_MASK) >> BYTE_2_SHIFT); result[BYTE_2] = (byte) ((val & BYTE_2_MASK) >> BYTE_2_SHIFT);
result[BYTE_3] = (byte) ((val & BYTE_3_MASK) >> BYTE_3_SHIFT); result[BYTE_3] = (byte) ((val & BYTE_3_MASK) >> BYTE_3_SHIFT);


+ 2
- 1
src/main/org/apache/tools/zip/ZipFile.java View File

@@ -1003,7 +1003,8 @@ public class ZipFile implements Closeable {
if (ent2 == null) { if (ent2 == null) {
return -1; return -1;
} }
final long val = ent1.getOffsetEntry().headerOffset - ent2.getOffsetEntry().headerOffset;
final long val = (ent1.getOffsetEntry().headerOffset
- ent2.getOffsetEntry().headerOffset);
return val == 0 ? 0 : val < 0 ? -1 : +1; return val == 0 ? 0 : val < 0 ? -1 : +1;
}; };




+ 1
- 1
src/main/org/apache/tools/zip/ZipLong.java View File

@@ -127,7 +127,7 @@ public final class ZipLong implements Cloneable {
* must be non-negative and no larger than <tt>buf.length-4</tt> * must be non-negative and no larger than <tt>buf.length-4</tt>
*/ */
public static void putLong(long value, byte[] buf, int offset) { public static void putLong(long value, byte[] buf, int offset) {
buf[offset++] = (byte) (value & BYTE_MASK);
buf[offset++] = (byte) ((value & BYTE_MASK));
buf[offset++] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT); buf[offset++] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT);
buf[offset++] = (byte) ((value & BYTE_2_MASK) >> BYTE_2_SHIFT); buf[offset++] = (byte) ((value & BYTE_2_MASK) >> BYTE_2_SHIFT);
buf[offset] = (byte) ((value & BYTE_3_MASK) >> BYTE_3_SHIFT); buf[offset] = (byte) ((value & BYTE_3_MASK) >> BYTE_3_SHIFT);


+ 5
- 3
src/main/org/apache/tools/zip/ZipOutputStream.java View File

@@ -1565,8 +1565,8 @@ public class ZipOutputStream extends FilterOutputStream {
} }
// requires version 2 as we are going to store length info // requires version 2 as we are going to store length info
// in the data descriptor // in the data descriptor
return isDeflatedToOutputStream(zipMethod)
? DATA_DESCRIPTOR_MIN_VERSION : INITIAL_VERSION;
return (isDeflatedToOutputStream(zipMethod))
? DATA_DESCRIPTOR_MIN_VERSION : INITIAL_VERSION;
} }


private boolean isDeflatedToOutputStream(int zipMethod) { private boolean isDeflatedToOutputStream(int zipMethod) {
@@ -1613,7 +1613,9 @@ public class ZipOutputStream extends FilterOutputStream {
* @return boolean * @return boolean
*/ */
private boolean hasZip64Extra(ZipEntry ze) { private boolean hasZip64Extra(ZipEntry ze) {
return ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID) != null;
return ze.getExtraField(Zip64ExtendedInformationExtraField
.HEADER_ID)
!= null;
} }


/** /**


+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/ExecStreamRedirectorTest.java View File

@@ -60,8 +60,8 @@ public class ExecStreamRedirectorTest {
if (dirListingOutput != null) { if (dirListingOutput != null) {
// Compare the directory listing that was redirected to these files. // Compare the directory listing that was redirected to these files.
// All files should have the same content. // All files should have the same content.
assertTrue("Redirected output in file " + redirectedOutputFile
+ " doesn't match content in other redirected output file(s)",
assertTrue("Redirected output in file " + redirectedOutputFile +
" doesn't match content in other redirected output file(s)",
Arrays.equals(dirListingOutput, redirectedOutput)); Arrays.equals(dirListingOutput, redirectedOutput));
} }
dirListingOutput = redirectedOutput; dirListingOutput = redirectedOutput;


+ 4
- 4
src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java View File

@@ -108,28 +108,28 @@ public class JavaTest {
@Test @Test
public void testJarAndClassName() { public void testJarAndClassName() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of 'classname', 'jar', 'sourcefile'");
thrown.expectMessage("Cannot use combination of ");
buildRule.executeTarget("testJarAndClassName"); buildRule.executeTarget("testJarAndClassName");
} }


@Test @Test
public void testClassnameAndJar() { public void testClassnameAndJar() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of 'classname', 'jar', 'module'");
thrown.expectMessage("Cannot use combination of ");
buildRule.executeTarget("testClassnameAndJar"); buildRule.executeTarget("testClassnameAndJar");
} }


@Test @Test
public void testJarAndModule() { public void testJarAndModule() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of 'jar', 'module', 'sourcefile'");
thrown.expectMessage("Cannot use combination of ");
buildRule.executeTarget("testJarAndModule"); buildRule.executeTarget("testJarAndModule");
} }


@Test @Test
public void testModuleAndJar() { public void testModuleAndJar() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of 'classname', 'jar', 'module'");
thrown.expectMessage("Cannot use combination of ");
buildRule.executeTarget("testModuleAndJar"); buildRule.executeTarget("testModuleAndJar");
} }




+ 22
- 31
src/tests/junit/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTaskTest.java View File

@@ -102,8 +102,7 @@ public class JUnitLauncherTaskTest {
final Path trackerFile = setupTrackerProperty(targetName); final Path trackerFile = setupTrackerProperty(targetName);
buildRule.executeTarget(targetName); buildRule.executeTarget(targetName);
// make sure the right test(s) were run // make sure the right test(s) were run
Assert.assertTrue("JUnit4SampleTest test was expected to be run", wasTestRun(trackerFile,
JUnit4SampleTest.class.getName()));
Assert.assertTrue("JUnit4SampleTest test was expected to be run", wasTestRun(trackerFile, JUnit4SampleTest.class.getName()));
Assert.assertTrue("JUnit4SampleTest#testFoo was expected to succeed", verifySuccess(trackerFile, Assert.assertTrue("JUnit4SampleTest#testFoo was expected to succeed", verifySuccess(trackerFile,
JUnit4SampleTest.class.getName(), "testFoo")); JUnit4SampleTest.class.getName(), "testFoo"));
} }
@@ -170,8 +169,7 @@ public class JUnitLauncherTaskTest {
JupiterSampleTest.class.getName(), "testFails")); JupiterSampleTest.class.getName(), "testFails"));
Assert.assertTrue("JupiterSampleTest#testSkipped was expected to be skipped", verifySkipped(trackerFile, Assert.assertTrue("JupiterSampleTest#testSkipped was expected to be skipped", verifySkipped(trackerFile,
JupiterSampleTest.class.getName(), "testSkipped")); JupiterSampleTest.class.getName(), "testSkipped"));
Assert.assertFalse("ForkedTest wasn't expected to be run", wasTestRun(trackerFile,
ForkedTest.class.getName()));
Assert.assertFalse("ForkedTest wasn't expected to be run", wasTestRun(trackerFile, ForkedTest.class.getName()));
} }


/** /**
@@ -194,9 +192,9 @@ public class JUnitLauncherTaskTest {
} }


/** /**
* Tests that in a forked mode execution of tests, when the {@code includeJUnitPlatformLibraries}
* attribute is set to false, then the execution of such tests fails with a classloading error
* for the JUnit platform classes
* Tests that in a forked mode execution of tests, when the {@code includeJUnitPlatformLibraries} attribute
* is set to false, then the execution of such tests fails with a classloading error for the JUnit platform
* classes
* *
* @throws Exception * @throws Exception
*/ */
@@ -205,8 +203,8 @@ public class JUnitLauncherTaskTest {
final String targetName = "test-junit-platform-lib-excluded"; final String targetName = "test-junit-platform-lib-excluded";
try { try {
buildRule.executeTarget(targetName); buildRule.executeTarget(targetName);
Assert.fail(targetName + " was expected to fail since JUnit platform libraries "
+ "weren't included in the classpath of the forked JVM");
Assert.fail(targetName + " was expected to fail since JUnit platform libraries " +
"weren't included in the classpath of the forked JVM");
} catch (BuildException be) { } catch (BuildException be) {
// expect a ClassNotFoundException for a JUnit platform class // expect a ClassNotFoundException for a JUnit platform class
final String cnfeMessage = ClassNotFoundException.class.getName() + ": org.junit.platform"; final String cnfeMessage = ClassNotFoundException.class.getName() + ": org.junit.platform";
@@ -215,14 +213,13 @@ public class JUnitLauncherTaskTest {
} }
} }
final String exclusionLogMsg = "Excluding JUnit platform libraries"; final String exclusionLogMsg = "Excluding JUnit platform libraries";
Assert.assertTrue("JUnit platform libraries weren't excluded from classpath",
buildRule.getFullLog().contains(exclusionLogMsg));
Assert.assertTrue("JUnit platform libraries weren't excluded from classpath", buildRule.getFullLog().contains(exclusionLogMsg));
} }


/** /**
* Tests that in a forked mode execution of tests, when the {@code includeAntRuntimeLibraries}
* attribute is set to false, then the execution of such tests fails with a classloading error
* for the Ant runtime classes
* Tests that in a forked mode execution of tests, when the {@code includeAntRuntimeLibraries} attribute
* is set to false, then the execution of such tests fails with a classloading error for the Ant runtime
* classes
* *
* @throws Exception * @throws Exception
*/ */
@@ -231,8 +228,8 @@ public class JUnitLauncherTaskTest {
final String targetName = "test-junit-ant-runtime-lib-excluded"; final String targetName = "test-junit-ant-runtime-lib-excluded";
try { try {
buildRule.executeTarget(targetName); buildRule.executeTarget(targetName);
Assert.fail(targetName + " was expected to fail since JUnit platform libraries "
+ "weren't included in the classpath of the forked JVM");
Assert.fail(targetName + " was expected to fail since JUnit platform libraries " +
"weren't included in the classpath of the forked JVM");
} catch (BuildException be) { } catch (BuildException be) {
// expect a Error due to missing main class (which is part of Ant runtime libraries // expect a Error due to missing main class (which is part of Ant runtime libraries
// that we excluded) // that we excluded)
@@ -242,15 +239,13 @@ public class JUnitLauncherTaskTest {
} }
} }
final String exclusionLogMsg = "Excluding Ant runtime libraries"; final String exclusionLogMsg = "Excluding Ant runtime libraries";
Assert.assertTrue("Ant runtime libraries weren't excluded from classpath",
buildRule.getFullLog().contains(exclusionLogMsg));
Assert.assertTrue("Ant runtime libraries weren't excluded from classpath", buildRule.getFullLog().contains(exclusionLogMsg));
} }




/** /**
* Tests that in a forked mode execution, with {@code includeJUnitPlatformLibraries} attribute
* set to false and with the test classpath explicitly including JUnit platform library jars,
* the tests are executed successfully
* Tests that in a forked mode execution, with {@code includeJUnitPlatformLibraries} attribute set to false
* and with the test classpath explicitly including JUnit platform library jars, the tests are executed successfully
* *
* @throws Exception * @throws Exception
*/ */
@@ -260,8 +255,7 @@ public class JUnitLauncherTaskTest {
final Path trackerFile = setupTrackerProperty(targetName); final Path trackerFile = setupTrackerProperty(targetName);
buildRule.executeTarget(targetName); buildRule.executeTarget(targetName);
final String exclusionLogMsg = "Excluding JUnit platform libraries"; final String exclusionLogMsg = "Excluding JUnit platform libraries";
Assert.assertTrue("JUnit platform libraries weren't excluded from classpath",
buildRule.getFullLog().contains(exclusionLogMsg));
Assert.assertTrue("JUnit platform libraries weren't excluded from classpath", buildRule.getFullLog().contains(exclusionLogMsg));
Assert.assertTrue("JupiterSampleTest#testSucceeds was expected to succeed", verifySuccess(trackerFile, Assert.assertTrue("JupiterSampleTest#testSucceeds was expected to succeed", verifySuccess(trackerFile,
JupiterSampleTest.class.getName(), "testSucceeds")); JupiterSampleTest.class.getName(), "testSucceeds"));
Assert.assertTrue("JupiterSampleTest#testFails was expected to fail", verifyFailed(trackerFile, Assert.assertTrue("JupiterSampleTest#testFails was expected to fail", verifyFailed(trackerFile,
@@ -269,9 +263,8 @@ public class JUnitLauncherTaskTest {
} }


/** /**
* Tests that in a forked mode execution, with {@code includeAntRuntimeLibraries} attribute
* set to false and with the test classpath explicitly including Ant runtime library jars,
* the tests are executed successfully
* Tests that in a forked mode execution, with {@code includeAntRuntimeLibraries} attribute set to false
* and with the test classpath explicitly including Ant runtime library jars, the tests are executed successfully
* *
* @throws Exception * @throws Exception
*/ */
@@ -288,8 +281,7 @@ public class JUnitLauncherTaskTest {
// run the target // run the target
buildRule.executeTarget(targetName); buildRule.executeTarget(targetName);
final String exclusionLogMsg = "Excluding Ant runtime libraries"; final String exclusionLogMsg = "Excluding Ant runtime libraries";
Assert.assertTrue("Ant runtime libraries weren't excluded from classpath",
buildRule.getFullLog().contains(exclusionLogMsg));
Assert.assertTrue("Ant runtime libraries weren't excluded from classpath", buildRule.getFullLog().contains(exclusionLogMsg));
Assert.assertTrue("JupiterSampleTest#testSucceeds was expected to succeed", verifySuccess(trackerFile, Assert.assertTrue("JupiterSampleTest#testSucceeds was expected to succeed", verifySuccess(trackerFile,
JupiterSampleTest.class.getName(), "testSucceeds")); JupiterSampleTest.class.getName(), "testSucceeds"));
Assert.assertTrue("JupiterSampleTest#testFails was expected to fail", verifyFailed(trackerFile, Assert.assertTrue("JupiterSampleTest#testFails was expected to fail", verifyFailed(trackerFile,
@@ -303,9 +295,8 @@ public class JUnitLauncherTaskTest {
} }


/** /**
* Tests that in a forked mode execution, with {@code includeAntRuntimeLibraries} and
* {@code includeJUnitPlatformLibraries} attributes set to false and with the test classpath
* explicitly including Ant runtime and JUnit platform library jars,
* Tests that in a forked mode execution, with {@code includeAntRuntimeLibraries} and {@code includeJUnitPlatformLibraries}
* attributes set to false and with the test classpath explicitly including Ant runtime and JUnit platform library jars,
* the tests are executed successfully * the tests are executed successfully
* *
* @throws Exception * @throws Exception


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save