Browse Source

Checkstyle: whitespace, line continuation and modifier idiosyncrasies

master
Gintas Grigelionis 7 years ago
parent
commit
7f1e7628b3
100 changed files with 492 additions and 608 deletions
  1. +4
    -4
      src/main/org/apache/tools/ant/ComponentHelper.java
  2. +1
    -1
      src/main/org/apache/tools/ant/DemuxOutputStream.java
  3. +33
    -55
      src/main/org/apache/tools/ant/DirectoryScanner.java
  4. +1
    -1
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  5. +4
    -4
      src/main/org/apache/tools/ant/Project.java
  6. +1
    -2
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  7. +1
    -2
      src/main/org/apache/tools/ant/UnknownElement.java
  8. +1
    -1
      src/main/org/apache/tools/ant/XmlLogger.java
  9. +1
    -1
      src/main/org/apache/tools/ant/filters/BaseFilterReader.java
  10. +5
    -4
      src/main/org/apache/tools/ant/filters/ReplaceTokens.java
  11. +10
    -10
      src/main/org/apache/tools/ant/launch/Launcher.java
  12. +1
    -2
      src/main/org/apache/tools/ant/launch/Locator.java
  13. +3
    -5
      src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java
  14. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Ant.java
  15. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Available.java
  16. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/BZip2.java
  17. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/BindTargets.java
  18. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/CVSPass.java
  19. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Checksum.java
  20. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Classloader.java
  21. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Definer.java
  22. +25
    -32
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  23. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/EchoXML.java
  24. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  25. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  26. +14
    -26
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  27. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  28. +31
    -39
      src/main/org/apache/tools/ant/taskdefs/Get.java
  29. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/HostInfo.java
  30. +8
    -10
      src/main/org/apache/tools/ant/taskdefs/Input.java
  31. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  32. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  33. +6
    -6
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  34. +6
    -6
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java
  35. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Length.java
  36. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
  37. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Move.java
  38. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/PathConvert.java
  39. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  40. +8
    -10
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  41. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/SetPermissions.java
  42. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/StreamPumper.java
  43. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  44. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Tar.java
  45. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/Touch.java
  46. +10
    -21
      src/main/org/apache/tools/ant/taskdefs/Tstamp.java
  47. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Untar.java
  48. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  49. +12
    -12
      src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
  50. +10
    -10
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  51. +20
    -26
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  52. +4
    -7
      src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java
  53. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
  54. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
  55. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Http.java
  56. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java
  57. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
  58. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/email/Message.java
  59. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/launcher/Java13CommandLauncher.java
  60. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java
  61. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  62. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
  63. +3
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  64. +5
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
  65. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  66. +20
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  67. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
  68. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java
  69. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
  70. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
  71. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  72. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
  73. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java
  74. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  75. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/OrionDeploymentTool.java
  76. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java
  77. +7
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
  78. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
  79. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
  80. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  81. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java
  82. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
  83. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
  84. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
  85. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java
  86. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
  87. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
  88. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
  89. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/IgnoredTestResult.java
  90. +11
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  91. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java
  92. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java
  93. +49
    -69
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  94. +19
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrash.java
  95. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/BuiltinNative2Ascii.java
  96. +21
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  97. +24
    -24
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  98. +10
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
  99. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
  100. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java

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

@@ -59,7 +59,7 @@ import org.apache.tools.ant.util.FileUtils;
*/ */
public class ComponentHelper { public class ComponentHelper {
/** Map of component name to lists of restricted definitions */ /** Map of component name to lists of restricted definitions */
private Map<String, List<AntTypeDefinition>> restrictedDefinitions = new HashMap<>();
private Map<String, List<AntTypeDefinition>> restrictedDefinitions = new HashMap<>();


/** Map from component name to anttypedefinition */ /** Map from component name to anttypedefinition */
private final Hashtable<String, AntTypeDefinition> antTypeTable = new Hashtable<>(); private final Hashtable<String, AntTypeDefinition> antTypeTable = new Hashtable<>();
@@ -146,8 +146,8 @@ public class ComponentHelper {
if (project == null) { if (project == null) {
return null; return null;
} }
// Singleton for now, it may change ( per/classloader )
ComponentHelper ph = (ComponentHelper) project.getReference(COMPONENT_HELPER_REFERENCE);
// Singleton for now, it may change (per/classloader)
ComponentHelper ph = project.getReference(COMPONENT_HELPER_REFERENCE);
if (ph != null) { if (ph != null) {
return ph; return ph;
} }
@@ -969,7 +969,7 @@ public class ComponentHelper {
out.println("Cause: The constructor threw the exception"); out.println("Cause: The constructor threw the exception");
out.println(t.toString()); out.println(t.toString());
t.printStackTrace(out); //NOSONAR t.printStackTrace(out); //NOSONAR
} catch (NoClassDefFoundError ncdfe) {
} catch (NoClassDefFoundError ncdfe) {
jars = true; jars = true;
out.println("Cause: A class needed by class " + classname out.println("Cause: A class needed by class " + classname
+ " cannot be found: "); + " cannot be found: ");


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

@@ -122,7 +122,7 @@ public class DemuxOutputStream extends OutputStream {
*/ */
private void removeBuffer() { private void removeBuffer() {
Thread current = Thread.currentThread(); Thread current = Thread.currentThread();
buffers.remove (current);
buffers.remove(current);
} }


/** /**


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

@@ -765,8 +765,8 @@ public class DirectoryScanner
if (excludes == null) { if (excludes == null) {
this.excludes = null; this.excludes = null;
} else { } else {
this.excludes = Stream.of(excludes)
.map(DirectoryScanner::normalizePattern).toArray(String[]::new);
this.excludes = Stream.of(excludes).map(DirectoryScanner::normalizePattern)
.toArray(String[]::new);
} }
} }


@@ -788,11 +788,9 @@ public class DirectoryScanner
if (this.excludes == null || this.excludes.length == 0) { if (this.excludes == null || this.excludes.length == 0) {
setExcludes(excludes); setExcludes(excludes);
} else { } else {
this.excludes = Stream
.concat(Stream.of(this.excludes),
Stream.of(excludes)
.map(DirectoryScanner::normalizePattern))
.toArray(String[]::new);
this.excludes = Stream.concat(Stream.of(this.excludes),
Stream.of(excludes).map(DirectoryScanner::normalizePattern))
.toArray(String[]::new);
} }
} }
} }
@@ -853,8 +851,7 @@ public class DirectoryScanner
while (scanning) { while (scanning) {
try { try {
scanLock.wait(); scanLock.wait();
} catch (final InterruptedException e) {
continue;
} catch (final InterruptedException ignored) {
} }
} }
if (illegal != null) { if (illegal != null) {
@@ -872,8 +869,7 @@ public class DirectoryScanner


// set in/excludes to reasonable defaults if needed: // set in/excludes to reasonable defaults if needed:
final boolean nullIncludes = includes == null; final boolean nullIncludes = includes == null;
includes = nullIncludes
? new String[] { SelectorUtils.DEEP_TREE_MATCH } : includes;
includes = nullIncludes ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes;
final boolean nullExcludes = excludes == null; final boolean nullExcludes = excludes == null;
excludes = nullExcludes ? new String[0] : excludes; excludes = nullExcludes ? new String[0] : excludes;


@@ -948,8 +944,7 @@ public class DirectoryScanner
for (TokenizedPattern includePattern : includePatterns) { for (TokenizedPattern includePattern : includePatterns) {
final String pattern = includePattern.toString(); final String pattern = includePattern.toString();
if (!shouldSkipPattern(pattern)) { if (!shouldSkipPattern(pattern)) {
newroots.put(includePattern.rtrimWildcardTokens(),
pattern);
newroots.put(includePattern.rtrimWildcardTokens(), pattern);
} }
} }
for (final Map.Entry<String, TokenizedPath> entry : includeNonPatterns for (final Map.Entry<String, TokenizedPath> entry : includeNonPatterns
@@ -978,8 +973,7 @@ public class DirectoryScanner
for (final Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) { for (final Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) {
TokenizedPath currentPath = entry.getKey(); TokenizedPath currentPath = entry.getKey();
String currentelement = currentPath.toString(); String currentelement = currentPath.toString();
if (basedir == null
&& !FileUtils.isAbsolutePath(currentelement)) {
if (basedir == null && !FileUtils.isAbsolutePath(currentelement)) {
continue; continue;
} }
File myfile = new File(basedir, currentelement); File myfile = new File(basedir, currentelement);
@@ -998,10 +992,8 @@ public class DirectoryScanner
if (myfile != null && basedir != null) { if (myfile != null && basedir != null) {
currentelement = FILE_UTILS.removeLeadingPath( currentelement = FILE_UTILS.removeLeadingPath(
basedir, myfile); basedir, myfile);
if (!currentPath.toString()
.equals(currentelement)) {
currentPath =
new TokenizedPath(currentelement);
if (!currentPath.toString().equals(currentelement)) {
currentPath = new TokenizedPath(currentelement);
} }
} }
} }
@@ -1117,8 +1109,7 @@ public class DirectoryScanner


// set in/excludes to reasonable defaults if needed: // set in/excludes to reasonable defaults if needed:
final boolean nullIncludes = (includes == null); final boolean nullIncludes = (includes == null);
includes = nullIncludes
? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes;
includes = nullIncludes ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes;
final boolean nullExcludes = (excludes == null); final boolean nullExcludes = (excludes == null);
excludes = nullExcludes ? new String[0] : excludes; excludes = nullExcludes ? new String[0] : excludes;


@@ -1288,10 +1279,8 @@ public class DirectoryScanner
} else { } else {
everythingIncluded = false; everythingIncluded = false;
dirsNotIncluded.addElement(name); dirsNotIncluded.addElement(name);
if (fast && couldHoldIncluded(newPath)
&& !contentsExcluded(newPath)) {
scandir(file, newPath, fast, children,
directoryNamesFollowed);
if (fast && couldHoldIncluded(newPath) && !contentsExcluded(newPath)) {
scandir(file, newPath, fast, children, directoryNamesFollowed);
} }
} }
if (!fast) { if (!fast) {
@@ -1345,10 +1334,8 @@ public class DirectoryScanner
} }


private void accountForNotFollowedSymlink(final TokenizedPath name, final File file) { private void accountForNotFollowedSymlink(final TokenizedPath name, final File file) {
if (!isExcluded(name) &&
(isIncluded(name)
|| (file.isDirectory() && couldHoldIncluded(name)
&& !contentsExcluded(name)))) {
if (!isExcluded(name) && (isIncluded(name)
|| (file.isDirectory() && couldHoldIncluded(name) && !contentsExcluded(name)))) {
notFollowedSymlinks.add(file.getAbsolutePath()); notFollowedSymlinks.add(file.getAbsolutePath());
} }
} }
@@ -1376,7 +1363,7 @@ public class DirectoryScanner
* Test whether or not a name matches against at least one include * Test whether or not a name matches against at least one include
* pattern. * pattern.
* *
* @param name The name to match. Must not be <code>null</code>.
* @param name The path to match. Must not be <code>null</code>.
* @return <code>true</code> when the name matches against at least one * @return <code>true</code> when the name matches against at least one
* include pattern, or <code>false</code> otherwise. * include pattern, or <code>false</code> otherwise.
*/ */
@@ -1400,8 +1387,7 @@ public class DirectoryScanner
toMatch = toMatch.toUpperCase(); toMatch = toMatch.toUpperCase();
} }
return includeNonPatterns.containsKey(toMatch) return includeNonPatterns.containsKey(toMatch)
|| Stream.of(includePatterns)
.anyMatch(p -> p.matchPath(path, isCaseSensitive()));
|| Stream.of(includePatterns).anyMatch(p -> p.matchPath(path, isCaseSensitive()));
} }


/** /**
@@ -1425,11 +1411,9 @@ public class DirectoryScanner
* least one include pattern, or <code>false</code> otherwise. * least one include pattern, or <code>false</code> otherwise.
*/ */
private boolean couldHoldIncluded(final TokenizedPath tokenizedName) { private boolean couldHoldIncluded(final TokenizedPath tokenizedName) {
return Stream
.concat(Stream.of(includePatterns),
includeNonPatterns.values().stream()
.map(TokenizedPath::toPattern))
.anyMatch(pat -> couldHoldIncluded(tokenizedName, pat));
return Stream.concat(Stream.of(includePatterns),
includeNonPatterns.values().stream().map(TokenizedPath::toPattern))
.anyMatch(pat -> couldHoldIncluded(tokenizedName, pat));
} }


/** /**
@@ -1477,8 +1461,7 @@ public class DirectoryScanner
* @since Ant 1.6 * @since Ant 1.6
*/ */
private boolean isMorePowerfulThanExcludes(final String name) { private boolean isMorePowerfulThanExcludes(final String name) {
final String soughtexclude =
name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH;
final String soughtexclude = name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH;
return Stream.of(excludePatterns).map(Object::toString) return Stream.of(excludePatterns).map(Object::toString)
.noneMatch(Predicate.isEqual(soughtexclude)); .noneMatch(Predicate.isEqual(soughtexclude));
} }
@@ -1523,8 +1506,7 @@ public class DirectoryScanner
toMatch = toMatch.toUpperCase(); toMatch = toMatch.toUpperCase();
} }
return excludeNonPatterns.containsKey(toMatch) return excludeNonPatterns.containsKey(toMatch)
|| Stream.of(excludePatterns)
.anyMatch(p -> p.matchPath(name, isCaseSensitive()));
|| Stream.of(excludePatterns).anyMatch(p -> p.matchPath(name, isCaseSensitive()));
} }


/** /**
@@ -1536,8 +1518,8 @@ public class DirectoryScanner
* should not be selected, <code>true</code> otherwise. * should not be selected, <code>true</code> otherwise.
*/ */
protected boolean isSelected(final String name, final File file) { protected boolean isSelected(final String name, final File file) {
return selectors == null || Stream.of(selectors)
.allMatch(sel -> sel.isSelected(basedir, name, file));
return selectors == null
|| Stream.of(selectors).allMatch(sel -> sel.isSelected(basedir, name, file));
} }


/** /**
@@ -1718,8 +1700,7 @@ public class DirectoryScanner
public synchronized String[] getNotFollowedSymlinks() { public synchronized String[] getNotFollowedSymlinks() {
String[] links; String[] links;
synchronized (this) { synchronized (this) {
links = notFollowedSymlinks
.toArray(new String[notFollowedSymlinks.size()]);
links = notFollowedSymlinks.toArray(new String[notFollowedSymlinks.size()]);
} }
Arrays.sort(links); Arrays.sort(links);
return links; return links;
@@ -1730,9 +1711,8 @@ public class DirectoryScanner
*/ */
@Override @Override
public synchronized void addDefaultExcludes() { public synchronized void addDefaultExcludes() {
Stream<String> s = Stream.of(getDefaultExcludes())
.map(p -> p.replace('/', File.separatorChar).replace('\\',
File.separatorChar));
Stream<String> s = Stream.of(getDefaultExcludes()).map(p -> p.replace('/',
File.separatorChar).replace('\\', File.separatorChar));
if (excludes != null) { if (excludes != null) {
s = Stream.concat(Stream.of(excludes), s); s = Stream.concat(Stream.of(excludes), s);
} }
@@ -1807,14 +1787,14 @@ public class DirectoryScanner
* @param patterns String[] of patterns. * @param patterns String[] of patterns.
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
private TokenizedPattern[] fillNonPatternSet(final Map<String, TokenizedPath> map, final String[] patterns) {
private TokenizedPattern[] fillNonPatternSet(final Map<String, TokenizedPath> map,
final String[] patterns) {
final List<TokenizedPattern> al = new ArrayList<>(patterns.length); final List<TokenizedPattern> al = new ArrayList<>(patterns.length);
for (String pattern : patterns) { for (String pattern : patterns) {
if (SelectorUtils.hasWildcards(pattern)) { if (SelectorUtils.hasWildcards(pattern)) {
al.add(new TokenizedPattern(pattern)); al.add(new TokenizedPattern(pattern));
} else { } else {
final String s = isCaseSensitive()
? pattern : pattern.toUpperCase();
final String s = isCaseSensitive() ? pattern : pattern.toUpperCase();
map.put(s, new TokenizedPath(s)); map.put(s, new TokenizedPath(s));
} }
} }
@@ -1836,8 +1816,7 @@ public class DirectoryScanner
final Deque<String> directoryNamesFollowed) { final Deque<String> directoryNamesFollowed) {
try { try {
if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks
&& Collections.frequency(directoryNamesFollowed, dirName)
>= maxLevelsOfSymlinks
&& Collections.frequency(directoryNamesFollowed, dirName) >= maxLevelsOfSymlinks
&& SYMLINK_UTILS.isSymbolicLink(parent, dirName)) { && SYMLINK_UTILS.isSymbolicLink(parent, dirName)) {


final List<String> files = new ArrayList<>(); final List<String> files = new ArrayList<>();
@@ -1852,8 +1831,7 @@ public class DirectoryScanner
f = FILE_UTILS.resolveFile(parent, relPath + dir); f = FILE_UTILS.resolveFile(parent, relPath + dir);
files.add(f.getCanonicalPath()); files.add(f.getCanonicalPath());
if (files.size() > maxLevelsOfSymlinks if (files.size() > maxLevelsOfSymlinks
&& Collections.frequency(files, target)
> maxLevelsOfSymlinks) {
&& Collections.frequency(files, target) > maxLevelsOfSymlinks) {
return true; return true;
} }
} }


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

@@ -1135,7 +1135,7 @@ public final class IntrospectionHelper {
void set(final Project p, final Object parent, final String value) throws InvocationTargetException, void set(final Project p, final Object parent, final String value) throws InvocationTargetException,
IllegalAccessException, BuildException { IllegalAccessException, BuildException {
m.invoke(parent, new Object[] {new FileResource(p, p.resolveFile(value))}); m.invoke(parent, new Object[] {new FileResource(p, p.resolveFile(value))});
};
}
}; };
} }
// EnumeratedAttributes have their own helper class // EnumeratedAttributes have their own helper class


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

@@ -192,12 +192,12 @@ public class Project implements ResourceFactory {
private ClassLoader coreLoader = null; private ClassLoader coreLoader = null;


/** Records the latest task to be executed on a thread. */ /** Records the latest task to be executed on a thread. */
private final Map<Thread,Task> threadTasks =
Collections.synchronizedMap(new WeakHashMap<>());
private final Map<Thread, Task> threadTasks
= Collections.synchronizedMap(new WeakHashMap<>());


/** Records the latest task to be executed on a thread group. */ /** Records the latest task to be executed on a thread group. */
private final Map<ThreadGroup,Task> threadGroupTasks
= Collections.synchronizedMap(new WeakHashMap<>());
private final Map<ThreadGroup, Task> threadGroupTasks
= Collections.synchronizedMap(new WeakHashMap<>());


/** /**
* Called to handle any input requests. * Called to handle any input requests.


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

@@ -592,8 +592,7 @@ public class RuntimeConfigurable implements Serializable {


// Children (this is a shadow of UnknownElement#children) // Children (this is a shadow of UnknownElement#children)
if (r.children != null) { if (r.children != null) {
List<RuntimeConfigurable> newChildren = new ArrayList<>();
newChildren.addAll(r.children);
List<RuntimeConfigurable> newChildren = new ArrayList<>(r.children);
if (children != null) { if (children != null) {
newChildren.addAll(children); newChildren.addAll(children);
} }


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

@@ -398,8 +398,7 @@ public class UnknownElement extends Task {
// Do the runtime // Do the runtime
getWrapper().applyPreSet(u.getWrapper()); getWrapper().applyPreSet(u.getWrapper());
if (u.children != null) { if (u.children != null) {
List<UnknownElement> newChildren = new ArrayList<>();
newChildren.addAll(u.children);
List<UnknownElement> newChildren = new ArrayList<>(u.children);
if (children != null) { if (children != null) {
newChildren.addAll(children); newChildren.addAll(children);
} }


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

@@ -466,7 +466,7 @@ public class XmlLogger implements BuildLogger {
} }


private void synchronizedAppend(Node parent, Node child) { private void synchronizedAppend(Node parent, Node child) {
synchronized(parent) {
synchronized (parent) {
parent.appendChild(child); parent.appendChild(child);
} }
} }


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

@@ -176,7 +176,7 @@ public abstract class BaseFilterReader extends FilterReader {
StringBuffer line = new StringBuffer(); StringBuffer line = new StringBuffer();


while (ch != -1) { while (ch != -1) {
line.append ((char) ch);
line.append((char) ch);
if (ch == '\n') { if (ch == '\n') {
break; break;
} }


+ 5
- 4
src/main/org/apache/tools/ant/filters/ReplaceTokens.java View File

@@ -87,7 +87,8 @@ public final class ReplaceTokens
* *
* @see BaseFilterReader#BaseFilterReader() * @see BaseFilterReader#BaseFilterReader()
*/ */
public ReplaceTokens() {}
public ReplaceTokens() {
}


/** /**
* Creates a new filtered reader. * Creates a new filtered reader.
@@ -138,12 +139,12 @@ public final class ReplaceTokens
if (next == -1) { if (next == -1) {
return next; // end of stream. all buffers empty. return next; // end of stream. all buffers empty.
} }
readBuffer += (char)next;
readBuffer += (char) next;
} }


for (;;) { for (;;) {
// get the closest tokens // get the closest tokens
SortedMap<String,String> possibleTokens = resolvedTokens.tailMap(readBuffer);
SortedMap<String, String> possibleTokens = resolvedTokens.tailMap(readBuffer);
if (possibleTokens.isEmpty() || !possibleTokens.firstKey().startsWith(readBuffer)) { // if there is none, then deliver the first char from the buffer. if (possibleTokens.isEmpty() || !possibleTokens.firstKey().startsWith(readBuffer)) { // if there is none, then deliver the first char from the buffer.
return getFirstCharacterFromReadBuffer(); return getFirstCharacterFromReadBuffer();
} else if (readBuffer.equals(possibleTokens.firstKey())) { // there exists a nearest token - is it an exact match? } else if (readBuffer.equals(possibleTokens.firstKey())) { // there exists a nearest token - is it an exact match?
@@ -156,7 +157,7 @@ public final class ReplaceTokens
} else { // nearest token is not matching exactly - read one character more. } else { // nearest token is not matching exactly - read one character more.
int next = in.read(); int next = in.read();
if (next != -1) { if (next != -1) {
readBuffer += (char)next;
readBuffer += (char) next;
} else { } else {
return getFirstCharacterFromReadBuffer(); // end of stream. deliver remaining characters from buffer. return getFirstCharacterFromReadBuffer(); // end of stream. deliver remaining characters from buffer.
} }


+ 10
- 10
src/main/org/apache/tools/ant/launch/Launcher.java View File

@@ -109,7 +109,7 @@ public class Launcher {
} }
if (exitCode != 0) { if (exitCode != 0) {
if (launchDiag) { if (launchDiag) {
System.out.println("Exit code: "+exitCode);
System.out.println("Exit code: " + exitCode);
} }
System.exit(exitCode); System.exit(exitCode);
} }
@@ -234,7 +234,7 @@ public class Launcher {
} }
} }


logPath("Launcher JAR",sourceJar);
logPath("Launcher JAR", sourceJar);
logPath("Launcher JAR directory", sourceJar.getParentFile()); logPath("Launcher JAR directory", sourceJar.getParentFile());
logPath("java.home", new File(System.getProperty("java.home"))); logPath("java.home", new File(System.getProperty("java.home")));


@@ -253,7 +253,7 @@ public class Launcher {
final URL[] userURLs = noUserLib ? new URL[0] : getUserURLs(); final URL[] userURLs = noUserLib ? new URL[0] : getUserURLs();


final File toolsJAR = Locator.getToolsJar(); final File toolsJAR = Locator.getToolsJar();
logPath("tools.jar",toolsJAR);
logPath("tools.jar", toolsJAR);
final URL[] jars = getJarArray( final URL[] jars = getJarArray(
libURLs, userURLs, systemURLs, toolsJAR); libURLs, userURLs, systemURLs, toolsJAR);


@@ -276,7 +276,7 @@ public class Launcher {
Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setContextClassLoader(loader);
Class<? extends AntMain> mainClass = null; Class<? extends AntMain> mainClass = null;
int exitCode = 0; int exitCode = 0;
Throwable thrown=null;
Throwable thrown = null;
try { try {
mainClass = loader.loadClass(mainClassname).asSubclass(AntMain.class); mainClass = loader.loadClass(mainClassname).asSubclass(AntMain.class);
final AntMain main = mainClass.newInstance(); final AntMain main = mainClass.newInstance();
@@ -294,10 +294,10 @@ public class Launcher {
thrown = cnfe; thrown = cnfe;
} catch (final Throwable t) { } catch (final Throwable t) {
t.printStackTrace(System.err); //NOSONAR t.printStackTrace(System.err); //NOSONAR
thrown=t;
thrown = t;
} }
if(thrown!=null) {
System.err.println(ANTHOME_PROPERTY+": "+antHome.getAbsolutePath());
if (thrown != null) {
System.err.println(ANTHOME_PROPERTY + ": " + antHome.getAbsolutePath());
System.err.println("Classpath: " + baseClassPath.toString()); System.err.println("Classpath: " + baseClassPath.toString());
System.err.println("Launcher JAR: " + sourceJar.getAbsolutePath()); System.err.println("Launcher JAR: " + sourceJar.getAbsolutePath());
System.err.println("Launcher Directory: " + jarDir.getAbsolutePath()); System.err.println("Launcher Directory: " + jarDir.getAbsolutePath());
@@ -371,8 +371,8 @@ public class Launcher {
* @return a combined array * @return a combined array
* @throws MalformedURLException if there is a problem. * @throws MalformedURLException if there is a problem.
*/ */
private URL[] getJarArray (
final URL[] libJars, final URL[] userJars, final URL[] systemJars, final File toolsJar)
private URL[] getJarArray(final URL[] libJars, final URL[] userJars,
final URL[] systemJars, final File toolsJar)
throws MalformedURLException { throws MalformedURLException {
int numJars = libJars.length + userJars.length + systemJars.length; int numJars = libJars.length + userJars.length + systemJars.length;
if (toolsJar != null) { if (toolsJar != null) {
@@ -402,7 +402,7 @@ public class Launcher {
System.setProperty(name, value); System.setProperty(name, value);
} }


private void logPath(final String name,final File path) {
private void logPath(final String name, final File path) {
if (launchDiag) { if (launchDiag) {
System.out.println(name + "= \"" + path + "\""); System.out.println(name + "= \"" + path + "\"");
} }


+ 1
- 2
src/main/org/apache/tools/ant/launch/Locator.java View File

@@ -388,8 +388,7 @@ public final class Locator {
* @deprecated since 1.9, use <code>FileUtils.getFileURL(File)</code> * @deprecated since 1.9, use <code>FileUtils.getFileURL(File)</code>
*/ */
@Deprecated @Deprecated
public static URL fileToURL(File file)
throws MalformedURLException {
public static URL fileToURL(File file) throws MalformedURLException {
return new URL(file.toURI().toASCIIString()); return new URL(file.toURI().toASCIIString());
} }




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

@@ -104,8 +104,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public void buildStarted(final BuildEvent event) { public void buildStarted(final BuildEvent event) {
final String categoryString = PROJECT_LOG;
final Log log = getLog(categoryString, null);
final Log log = getLog(PROJECT_LOG, null);


if (initialized) { if (initialized) {
realLog(log, "Build started.", Project.MSG_INFO, null); realLog(log, "Build started.", Project.MSG_INFO, null);
@@ -116,8 +115,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger {
@Override @Override
public void buildFinished(final BuildEvent event) { public void buildFinished(final BuildEvent event) {
if (initialized) { if (initialized) {
final String categoryString = PROJECT_LOG;
final Log log = getLog(categoryString, event.getProject().getName());
final Log log = getLog(PROJECT_LOG, event.getProject().getName());


if (event.getException() == null) { if (event.getException() == null) {
realLog(log, "Build finished.", Project.MSG_INFO, null); realLog(log, "Build finished.", Project.MSG_INFO, null);
@@ -251,7 +249,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger {
final Log log = getLog(categoryString, categoryDetail); final Log log = getLog(categoryString, categoryDetail);
final int priority = event.getPriority(); final int priority = event.getPriority();
final String message = event.getMessage(); final String message = event.getMessage();
realLog(log, message, priority , null);
realLog(log, message, priority, null);
} }
} }




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

@@ -378,7 +378,7 @@ public class Ant extends Task {
log("calling target(s) " log("calling target(s) "
+ (!locals.isEmpty() ? locals.toString() : "[default]") + (!locals.isEmpty() ? locals.toString() : "[default]")
+ " in build file " + antFile, Project.MSG_VERBOSE); + " in build file " + antFile, Project.MSG_VERBOSE);
newProject.setUserProperty(MagicNames.ANT_FILE , antFile);
newProject.setUserProperty(MagicNames.ANT_FILE, antFile);


String thisAntFile = getProject().getProperty(MagicNames.ANT_FILE); String thisAntFile = getProject().getProperty(MagicNames.ANT_FILE);
// Are we trying to call the target in which we are defined (or // Are we trying to call the target in which we are defined (or


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

@@ -494,7 +494,7 @@ public class Available extends Task implements Condition {
*/ */
public static class FileDir extends EnumeratedAttribute { public static class FileDir extends EnumeratedAttribute {


private static final String[] VALUES = { "file", "dir" };
private static final String[] VALUES = {"file", "dir"};


/** /**
* @see EnumeratedAttribute#getValues * @see EnumeratedAttribute#getValues


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

@@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs;


import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;


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

@@ -77,8 +77,8 @@ public class BindTargets extends Task {
ProjectHelper.PROJECTHELPER_REFERENCE); ProjectHelper.PROJECTHELPER_REFERENCE);


for (String target : targets) { for (String target : targets) {
helper.getExtensionStack().add(new String[] { extensionPoint,
target, onMissingExtensionPoint.name() });
helper.getExtensionStack().add(new String[] {extensionPoint,
target, onMissingExtensionPoint.name()});
} }
} }
} }

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

@@ -115,7 +115,7 @@ public class CVSPass extends Task {
String pwdfile = buf.toString() + cvsRoot + " A" String pwdfile = buf.toString() + cvsRoot + " A"
+ mangle(password); + mangle(password);


log("Writing -> " + pwdfile , Project.MSG_DEBUG);
log("Writing -> " + pwdfile, Project.MSG_DEBUG);


writer = new BufferedWriter(new FileWriter(passFile)); writer = new BufferedWriter(new FileWriter(passFile));




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

@@ -492,7 +492,7 @@ public class Checksum extends MatchingTask implements Condition {
dis.close(); dis.close();
fis.close(); fis.close();
fis = null; fis = null;
byte[] fileDigest = messageDigest.digest ();
byte[] fileDigest = messageDigest.digest();
if (totalproperty != null) { if (totalproperty != null) {
allDigests.put(src, fileDigest); allDigests.put(src, fileDigest);
} }
@@ -693,7 +693,7 @@ public class Checksum extends MatchingTask implements Condition {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { CHECKSUM, MD5SUM, SVF };
return new String[] {CHECKSUM, MD5SUM, SVF};
} }
} }
} }

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

@@ -225,7 +225,7 @@ public class Classloader extends Task {
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
File f = new File(list[i]); File f = new File(list[i]);
if (f.exists()) { if (f.exists()) {
log("Adding to class loader " + acl + " " + f.getAbsolutePath(),
log("Adding to class loader " + acl + " " + f.getAbsolutePath(),
Project.MSG_DEBUG); Project.MSG_DEBUG);
acl.addPathElement(f.getAbsolutePath()); acl.addPathElement(f.getAbsolutePath());
} }


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

@@ -123,8 +123,8 @@ public abstract class Definer extends DefBase {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { POLICY_FAIL, POLICY_REPORT, POLICY_IGNORE,
POLICY_FAILALL };
return new String[] {POLICY_FAIL, POLICY_REPORT, POLICY_IGNORE,
POLICY_FAILALL};
} }
} }


@@ -143,7 +143,7 @@ public abstract class Definer extends DefBase {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "properties", "xml" };
return new String[] {"properties", "xml"};
} }
} }




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

@@ -596,8 +596,7 @@ public class Delete extends MatchingTask {


if (quiet && failonerror) { if (quiet && failonerror) {
throw new BuildException( throw new BuildException(
"quiet and failonerror cannot both be set to true",
getLocation());
"quiet and failonerror cannot both be set to true", getLocation());
} }


// delete the single file // delete the single file
@@ -646,8 +645,7 @@ public class Delete extends MatchingTask {
+ " which looks like a broken symlink.", + " which looks like a broken symlink.",
quiet ? Project.MSG_VERBOSE : verbosity); quiet ? Project.MSG_VERBOSE : verbosity);
if (!delete(dir)) { if (!delete(dir)) {
handle("Unable to delete directory "
+ dir.getAbsolutePath());
handle("Unable to delete directory " + dir.getAbsolutePath());
} }
} }
} }
@@ -675,13 +673,11 @@ public class Delete extends MatchingTask {
fs.setProject(getProject()); fs.setProject(getProject());
} }
final File fsDir = fs.getDir(); final File fsDir = fs.getDir();
if (!fs.getErrorOnMissingDir() &&
(fsDir == null || !fsDir.exists())) {
if (!fs.getErrorOnMissingDir() && (fsDir == null || !fsDir.exists())) {
continue; continue;
} }
if (fsDir == null) { if (fsDir == null) {
throw new BuildException(
"File or Resource without directory or file specified");
throw new BuildException("File or Resource without directory or file specified");
} else if (!fsDir.isDirectory()) { } else if (!fsDir.isDirectory()) {
handle("Directory does not exist: " + fsDir); handle("Directory does not exist: " + fsDir);
} else { } else {
@@ -691,24 +687,25 @@ public class Delete extends MatchingTask {
// iterating, capture the results now and store them // iterating, capture the results now and store them
final String[] files = ds.getIncludedFiles(); final String[] files = ds.getIncludedFiles();
resourcesToDelete.add(new ResourceCollection() { resourcesToDelete.add(new ResourceCollection() {
@Override
public boolean isFilesystemOnly() {
return true;
}
@Override
public int size() {
return files.length;
}
@Override
public Iterator<Resource> iterator() {
return new FileResourceIterator(getProject(),
fsDir, files);
}
});
@Override
public boolean isFilesystemOnly() {
return true;
}

@Override
public int size() {
return files.length;
}

@Override
public Iterator<Resource> iterator() {
return new FileResourceIterator(getProject(),
fsDir, files);
}
});
if (includeEmpty) { if (includeEmpty) {
filesetDirs.add(new ReverseDirs(getProject(), fsDir, filesetDirs.add(new ReverseDirs(getProject(), fsDir,
ds
.getIncludedDirectories()));
ds.getIncludedDirectories()));
} }


if (removeNotFollowedSymlinks) { if (removeNotFollowedSymlinks) {
@@ -746,8 +743,7 @@ public class Delete extends MatchingTask {
for (Resource r : resourcesToDelete) { for (Resource r : resourcesToDelete) {
// nonexistent resources could only occur if we already // nonexistent resources could only occur if we already
// deleted something from a fileset: // deleted something from a fileset:
File f = r.as(FileProvider.class)
.getFile();
File f = r.as(FileProvider.class).getFile();
if (!f.exists()) { if (!f.exists()) {
continue; continue;
} }
@@ -781,8 +777,7 @@ public class Delete extends MatchingTask {


private void handle(Exception e) { private void handle(Exception e) {
if (failonerror) { if (failonerror) {
throw (e instanceof BuildException)
? (BuildException) e : new BuildException(e);
throw (e instanceof BuildException) ? (BuildException) e : new BuildException(e);
} }
log(e, quiet ? Project.MSG_VERBOSE : verbosity); log(e, quiet ? Project.MSG_VERBOSE : verbosity);
} }
@@ -865,8 +860,7 @@ public class Delete extends MatchingTask {
log("Deleting " + currDir.getAbsolutePath(), log("Deleting " + currDir.getAbsolutePath(),
quiet ? Project.MSG_VERBOSE : verbosity); quiet ? Project.MSG_VERBOSE : verbosity);
if (!delete(currDir)) { if (!delete(currDir)) {
handle("Unable to delete directory "
+ currDir.getAbsolutePath());
handle("Unable to delete directory " + currDir.getAbsolutePath());
} else { } else {
dirCount++; dirCount++;
} }
@@ -874,8 +868,7 @@ public class Delete extends MatchingTask {
} }


if (dirCount > 0) { if (dirCount > 0) {
log("Deleted "
+ dirCount
log("Deleted " + dirCount
+ " director" + (dirCount == 1 ? "y" : "ies") + " director" + (dirCount == 1 ? "y" : "ies")
+ " form " + d.getAbsolutePath(), + " form " + d.getAbsolutePath(),
quiet ? Project.MSG_VERBOSE : verbosity); quiet ? Project.MSG_VERBOSE : verbosity);


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

@@ -107,7 +107,8 @@ public class EchoXML extends XMLFragment {
public static final NamespacePolicy DEFAULT public static final NamespacePolicy DEFAULT
= new NamespacePolicy(IGNORE); = new NamespacePolicy(IGNORE);


public NamespacePolicy() {}
public NamespacePolicy() {
}


public NamespacePolicy(String s) { public NamespacePolicy(String s) {
setValue(s); setValue(s);
@@ -116,7 +117,7 @@ public class EchoXML extends XMLFragment {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { IGNORE, ELEMENTS, ALL };
return new String[] {IGNORE, ELEMENTS, ALL};
} }


public DOMElementWriter.XmlNamespacePolicy getPolicy() { public DOMElementWriter.XmlNamespacePolicy getPolicy() {


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

@@ -194,16 +194,16 @@ public class Execute {
private static String[] getProcEnvCommand() { private static String[] getProcEnvCommand() {
if (Os.isFamily("os/2")) { if (Os.isFamily("os/2")) {
// OS/2 - use same mechanism as Windows 2000 // OS/2 - use same mechanism as Windows 2000
return new String[] { "cmd", "/c", "set" };
return new String[] {"cmd", "/c", "set"};
} }
if (Os.isFamily("windows")) { if (Os.isFamily("windows")) {
// Determine if we're running under XP/2000/NT or 98/95 // Determine if we're running under XP/2000/NT or 98/95
if (Os.isFamily("win9x")) { if (Os.isFamily("win9x")) {
// Windows 98/95 // Windows 98/95
return new String[] { "command.com", "/c", "set" };
return new String[] {"command.com", "/c", "set"};
} }
// Windows XP/2000/NT/2003 // Windows XP/2000/NT/2003
return new String[] { "cmd", "/c", "set" };
return new String[] {"cmd", "/c", "set"};
} }
if (Os.isFamily("z/os") || Os.isFamily("unix")) { if (Os.isFamily("z/os") || Os.isFamily("unix")) {
// On most systems one could use: /bin/sh -c env // On most systems one could use: /bin/sh -c env
@@ -222,10 +222,10 @@ public class Execute {
} }
if (Os.isFamily("netware") || Os.isFamily("os/400")) { if (Os.isFamily("netware") || Os.isFamily("os/400")) {
// rely on PATH // rely on PATH
return new String[] { "env" };
return new String[] {"env"};
} }
if (Os.isFamily("openvms")) { if (Os.isFamily("openvms")) {
return new String[] { "show", "logical" };
return new String[] {"show", "logical"};
} }
// MAC OS 9 and previous // MAC OS 9 and previous
// TODO: I have no idea how to get it, someone must fix it // TODO: I have no idea how to get it, someone must fix it


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

@@ -329,7 +329,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
//after execution finished, which is much better for long-lived runtimes //after execution finished, which is much better for long-lived runtimes
//though spawning complicates things... //though spawning complicates things...
vmsJavaOptionFile.deleteOnExit(); vmsJavaOptionFile.deleteOnExit();
String[] vmsCmd = { command[0], "-V", vmsJavaOptionFile.getPath() };
String[] vmsCmd = {command[0], "-V", vmsJavaOptionFile.getPath()};
exe.setCommandline(vmsCmd); exe.setCommandline(vmsCmd);
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Failed to create a temporary file for \"-V\" switch"); throw new BuildException("Failed to create a temporary file for \"-V\" switch");


+ 14
- 26
src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -334,8 +334,7 @@ public class ExecuteOn extends ExecTask {
@Override @Override
protected ExecuteStreamHandler createHandler() throws BuildException { protected ExecuteStreamHandler createHandler() throws BuildException {
//if we have a RedirectorElement, return a decoy //if we have a RedirectorElement, return a decoy
return (redirectorElement == null)
? super.createHandler() : new PumpStreamHandler();
return (redirectorElement == null) ? super.createHandler() : new PumpStreamHandler();
} }


/** /**
@@ -397,8 +396,7 @@ public class ExecuteOn extends ExecTask {
if (!parallel) { if (!parallel) {
for (String srcFile : fileNames) { for (String srcFile : fileNames) {
String[] command = getCommandline(srcFile, base); String[] command = getCommandline(srcFile, base);
log(Commandline.describeCommand(command),
Project.MSG_VERBOSE);
log(Commandline.describeCommand(command), Project.MSG_VERBOSE);
exe.setCommandline(command); exe.setCommandline(command);


if (redirectorElement != null) { if (redirectorElement != null) {
@@ -441,11 +439,9 @@ public class ExecuteOn extends ExecTask {
continue; continue;
} }


if ((!res.isDirectory() || !res.isExists())
&& !FileDirBoth.DIR.equals(type)) {
if ((!res.isDirectory() || !res.isExists()) && !FileDirBoth.DIR.equals(type)) {
totalFiles++; totalFiles++;
} else if (res.isDirectory()
&& !FileDirBoth.FILE.equals(type)) {
} else if (res.isDirectory() && !FileDirBoth.FILE.equals(type)) {
totalDirs++; totalDirs++;
} else { } else {
continue; continue;
@@ -456,8 +452,7 @@ public class ExecuteOn extends ExecTask {


if (!parallel) { if (!parallel) {
String[] command = getCommandline(name, base); String[] command = getCommandline(name, base);
log(Commandline.describeCommand(command),
Project.MSG_VERBOSE);
log(Commandline.describeCommand(command), Project.MSG_VERBOSE);
exe.setCommandline(command); exe.setCommandline(command);


if (redirectorElement != null) { if (redirectorElement != null) {
@@ -482,10 +477,8 @@ public class ExecuteOn extends ExecTask {
haveExecuted = true; haveExecuted = true;
} }
if (haveExecuted) { if (haveExecuted) {
log("Applied " + cmdl.getExecutable() + " to "
+ totalFiles + " file"
+ (totalFiles != 1 ? "s" : "") + " and "
+ totalDirs + " director"
log("Applied " + cmdl.getExecutable() + " to " + totalFiles + " file"
+ (totalFiles != 1 ? "s" : "") + " and " + totalDirs + " director"
+ (totalDirs != 1 ? "ies" : "y") + ".", + (totalDirs != 1 ? "ies" : "y") + ".",
verbose ? Project.MSG_INFO : Project.MSG_VERBOSE); verbose ? Project.MSG_INFO : Project.MSG_VERBOSE);
} }
@@ -507,11 +500,8 @@ public class ExecuteOn extends ExecTask {
*/ */
private void logSkippingFileset( private void logSkippingFileset(
String currentType, DirectoryScanner ds, File base) { String currentType, DirectoryScanner ds, File base) {
int includedCount
= ((!FileDirBoth.DIR.equals(currentType))
? ds.getIncludedFilesCount() : 0)
+ ((!FileDirBoth.FILE.equals(currentType))
? ds.getIncludedDirsCount() : 0);
int includedCount = (!FileDirBoth.DIR.equals(currentType) ? ds.getIncludedFilesCount() : 0)
+ (!FileDirBoth.FILE.equals(currentType) ? ds.getIncludedDirsCount() : 0);


log("Skipping fileset for directory " + base + ". It is " log("Skipping fileset for directory " + base + ". It is "
+ ((includedCount > 0) ? "up to date." : "empty."), + ((includedCount > 0) ? "up to date." : "empty."),
@@ -627,9 +617,8 @@ public class ExecuteOn extends ExecTask {
if (forwardSlash && fileSeparator != '/') { if (forwardSlash && fileSeparator != '/') {
src = src.replace(fileSeparator, '/'); src = src.replace(fileSeparator, '/');
} }
if (srcFilePos != null &&
(srcFilePos.getPrefix().length() > 0
|| srcFilePos.getSuffix().length() > 0)) {
if (srcFilePos != null && (srcFilePos.getPrefix().length() > 0
|| srcFilePos.getSuffix().length() > 0)) {
src = srcFilePos.getPrefix() + src + srcFilePos.getSuffix(); src = srcFilePos.getPrefix() + src + srcFilePos.getSuffix();
} }
result[srcIndex + i] = src; result[srcIndex + i] = src;
@@ -645,7 +634,7 @@ public class ExecuteOn extends ExecTask {
* @return the command line in the form of a String[]. * @return the command line in the form of a String[].
*/ */
protected String[] getCommandline(String srcFile, File baseDir) { protected String[] getCommandline(String srcFile, File baseDir) {
return getCommandline(new String[] { srcFile }, new File[] { baseDir });
return getCommandline(new String[] {srcFile}, new File[] {baseDir});
} }


/** /**
@@ -703,8 +692,7 @@ public class ExecuteOn extends ExecTask {
String[] s = fileNames.toArray(new String[fileNames.size()]); String[] s = fileNames.toArray(new String[fileNames.size()]);
File[] b = baseDirs.toArray(new File[baseDirs.size()]); File[] b = baseDirs.toArray(new File[baseDirs.size()]);


if (maxParallel <= 0
|| s.length == 0 /* this is skipEmpty == false */) {
if (maxParallel <= 0 || s.length == 0 /* this is skipEmpty == false */) {
String[] command = getCommandline(s, b); String[] command = getCommandline(s, b);
log(Commandline.describeCommand(command), Project.MSG_VERBOSE); log(Commandline.describeCommand(command), Project.MSG_VERBOSE);
exe.setCommandline(command); exe.setCommandline(command);
@@ -780,7 +768,7 @@ public class ExecuteOn extends ExecTask {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { FILE, DIR, "both" };
return new String[] {FILE, DIR, "both"};
} }
} }




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

@@ -680,7 +680,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "add", "asis", "remove" };
return new String[] {"add", "asis", "remove"};
} }
} }


@@ -694,8 +694,8 @@ public class FixCRLF extends MatchingTask implements ChainableReader {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "asis", "cr", "lf", "crlf", "mac", "unix",
"dos" };
return new String[] {"asis", "cr", "lf", "crlf", "mac", "unix",
"dos"};
} }
} }




+ 31
- 39
src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -19,7 +19,6 @@
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@@ -358,7 +357,7 @@ public class Get extends Task {
* @param v if "true" then be quiet * @param v if "true" then be quiet
* @since Ant 1.9.4 * @since Ant 1.9.4
*/ */
public void setQuiet(final boolean v){
public void setQuiet(final boolean v) {
this.quiet = v; this.quiet = v;
} }


@@ -655,8 +654,8 @@ public class Get extends Task {
private int redirections = 0; private int redirections = 0;
private String userAgent = null; private String userAgent = null;


GetThread(final URL source, final File dest,
final boolean h, final long t, final DownloadProgress p, final int l, final String userAgent) {
GetThread(final URL source, final File dest, final boolean h,
final long t, final DownloadProgress p, final int l, final String userAgent) {
this.source = source; this.source = source;
this.dest = dest; this.dest = dest;
hasTimestamp = h; hasTimestamp = h;
@@ -699,30 +698,29 @@ public class Get extends Task {




private boolean redirectionAllowed(final URL aSource, final URL aDest) { private boolean redirectionAllowed(final URL aSource, final URL aDest) {
if (!(aSource.getProtocol().equals(aDest.getProtocol()) || (HTTP
.equals(aSource.getProtocol()) && HTTPS.equals(aDest
.getProtocol())))) {
final String message = "Redirection detected from "
+ aSource.getProtocol() + " to " + aDest.getProtocol()
+ ". Protocol switch unsafe, not allowed.";
if (ignoreErrors) {
log(message, logLevel);
return false;
if (aSource.getProtocol().equals(aDest.getProtocol())
&& (HTTP.equals(aSource.getProtocol()) || HTTPS.equals(aDest.getProtocol()))) {
redirections++;
if (redirections > REDIRECT_LIMIT) {
final String message = "More than " + REDIRECT_LIMIT
+ " times redirected, giving up";
if (ignoreErrors) {
log(message, logLevel);
return false;
}
throw new BuildException(message);
} }
throw new BuildException(message);
return true;
} }


redirections++;
if (redirections > REDIRECT_LIMIT) {
final String message = "More than " + REDIRECT_LIMIT
+ " times redirected, giving up";
if (ignoreErrors) {
log(message, logLevel);
return false;
}
throw new BuildException(message);
final String message = "Redirection detected from "
+ aSource.getProtocol() + " to " + aDest.getProtocol()
+ ". Protocol switch unsafe, not allowed.";
if (ignoreErrors) {
log(message, logLevel);
return false;
} }
return true;
throw new BuildException(message);
} }


private URLConnection openConnection(final URL aSource) throws IOException { private URLConnection openConnection(final URL aSource) throws IOException {
@@ -746,8 +744,7 @@ public class Get extends Task {
// testing // testing
final Base64Converter encoder = new Base64Converter(); final Base64Converter encoder = new Base64Converter();
encoding = encoder.encode(up.getBytes()); encoding = encoder.encode(up.getBytes());
connection.setRequestProperty("Authorization", "Basic "
+ encoding);
connection.setRequestProperty("Authorization", "Basic " + encoding);
} }


if (tryGzipEncoding) { if (tryGzipEncoding) {
@@ -761,10 +758,8 @@ public class Get extends Task {
} }


if (connection instanceof HttpURLConnection) { if (connection instanceof HttpURLConnection) {
((HttpURLConnection) connection)
.setInstanceFollowRedirects(false);
((HttpURLConnection) connection)
.setUseCaches(httpUseCaches);
((HttpURLConnection) connection).setInstanceFollowRedirects(false);
connection.setUseCaches(httpUseCaches);
} }
// connect to the remote site (may take some time) // connect to the remote site (may take some time)
try { try {
@@ -821,14 +816,13 @@ public class Get extends Task {
} }


private boolean isMoved(final int responseCode) { private boolean isMoved(final int responseCode) {
return responseCode == HttpURLConnection.HTTP_MOVED_PERM ||
responseCode == HttpURLConnection.HTTP_MOVED_TEMP ||
responseCode == HttpURLConnection.HTTP_SEE_OTHER ||
responseCode == HTTP_MOVED_TEMP;
return responseCode == HttpURLConnection.HTTP_MOVED_PERM
|| responseCode == HttpURLConnection.HTTP_MOVED_TEMP
|| responseCode == HttpURLConnection.HTTP_SEE_OTHER
|| responseCode == HTTP_MOVED_TEMP;
} }


private boolean downloadFile()
throws FileNotFoundException, IOException {
private boolean downloadFile() throws IOException {
for (int i = 0; i < numberRetries; i++) { for (int i = 0; i < numberRetries; i++) {
// this three attempt trick is to get round quirks in different // this three attempt trick is to get round quirks in different
// Java implementations. Some of them take a few goes to bind // Java implementations. Some of them take a few goes to bind
@@ -885,9 +879,7 @@ public class Get extends Task {
if (verbose) { if (verbose) {
final Date t = new Date(remoteTimestamp); final Date t = new Date(remoteTimestamp);
log("last modified = " + t.toString() log("last modified = " + t.toString()
+ ((remoteTimestamp == 0)
? " - using current time instead"
: ""), logLevel);
+ ((remoteTimestamp == 0) ? " - using current time instead" : ""), logLevel);
} }
if (remoteTimestamp != 0) { if (remoteTimestamp != 0) {
FILE_UTILS.setFileLastModified(dest, remoteTimestamp); FILE_UTILS.setFileLastModified(dest, remoteTimestamp);


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

@@ -241,7 +241,7 @@ public class HostInfo extends Task {
int idx = fqdn.indexOf('.'); int idx = fqdn.indexOf('.');
if (idx > 0) { if (idx > 0) {
setProperty(NAME, fqdn.substring(0, idx)); setProperty(NAME, fqdn.substring(0, idx));
setProperty(DOMAIN, fqdn.substring(idx+1));
setProperty(DOMAIN, fqdn.substring(idx + 1));
} else { } else {
setProperty(NAME, fqdn); setProperty(NAME, fqdn);
setProperty(DOMAIN, DEF_DOMAIN); setProperty(DOMAIN, DEF_DOMAIN);


+ 8
- 10
src/main/org/apache/tools/ant/taskdefs/Input.java View File

@@ -125,14 +125,12 @@ public class Input extends Task {
* "default", "propertyfile", "greedy", "secure" (since Ant 1.8). * "default", "propertyfile", "greedy", "secure" (since Ant 1.8).
*/ */
public static class HandlerType extends EnumeratedAttribute { public static class HandlerType extends EnumeratedAttribute {
private static final String[] VALUES =
{ "default", "propertyfile", "greedy", "secure" };
private static final String[] VALUES = {"default", "propertyfile", "greedy", "secure"};


private static final InputHandler[] HANDLERS
= { new DefaultInputHandler(),
private static final InputHandler[] HANDLERS = {new DefaultInputHandler(),
new PropertyFileInputHandler(), new PropertyFileInputHandler(),
new GreedyInputHandler(), new GreedyInputHandler(),
new SecureInputHandler() };
new SecureInputHandler()};


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
@@ -160,7 +158,7 @@ public class Input extends Task {
* *
* @param validargs A comma separated String defining valid input args. * @param validargs A comma separated String defining valid input args.
*/ */
public void setValidargs (final String validargs) {
public void setValidargs(final String validargs) {
this.validargs = validargs; this.validargs = validargs;
} }


@@ -171,7 +169,7 @@ public class Input extends Task {
* *
* @param addproperty Name for the property to be created from input * @param addproperty Name for the property to be created from input
*/ */
public void setAddproperty (final String addproperty) {
public void setAddproperty(final String addproperty) {
this.addproperty = addproperty; this.addproperty = addproperty;
} }


@@ -179,7 +177,7 @@ public class Input extends Task {
* Sets the Message which gets displayed to the user during the build run. * Sets the Message which gets displayed to the user during the build run.
* @param message The message to be displayed. * @param message The message to be displayed.
*/ */
public void setMessage (final String message) {
public void setMessage(final String message) {
this.message = message; this.message = message;
messageAttribute = true; messageAttribute = true;
} }
@@ -191,7 +189,7 @@ public class Input extends Task {
* @param defaultvalue Default value for the property if no input * @param defaultvalue Default value for the property if no input
* is received * is received
*/ */
public void setDefaultvalue (final String defaultvalue) {
public void setDefaultvalue(final String defaultvalue) {
this.defaultvalue = defaultvalue; this.defaultvalue = defaultvalue;
} }


@@ -211,7 +209,7 @@ public class Input extends Task {
* @throws BuildException on error * @throws BuildException on error
*/ */
@Override @Override
public void execute () throws BuildException {
public void execute() throws BuildException {
if (addproperty != null if (addproperty != null
&& getProject().getProperty(addproperty) != null) { && getProject().getProperty(addproperty) != null) {
log("skipping " + getTaskName() + " as property " + addproperty log("skipping " + getTaskName() + " as property " + addproperty


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

@@ -969,7 +969,7 @@ public class Jar extends Zip {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "skip", "merge", "mergewithoutmain" };
return new String[] {"skip", "merge", "mergewithoutmain"};
} }
} }


@@ -1104,10 +1104,10 @@ public class Jar extends Zip {
for (int i = 0; i < rcs.length; i++) { for (int i = 0; i < rcs.length; i++) {
Resource[][] resources; Resource[][] resources;
if (rcs[i] instanceof FileSet) { if (rcs[i] instanceof FileSet) {
resources = grabResources(new FileSet[] { (FileSet) rcs[i] });
resources = grabResources(new FileSet[] {(FileSet) rcs[i]});
} else { } else {
resources = grabNonFileSetResources( resources = grabNonFileSetResources(
new ResourceCollection[] { rcs[i] });
new ResourceCollection[] {rcs[i]});
} }
for (int j = 0; j < resources[0].length; j++) { for (int j = 0; j < resources[0].length; j++) {
String name = resources[0][j].getName().replace('\\', '/'); String name = resources[0][j].getName().replace('\\', '/');
@@ -1169,7 +1169,7 @@ public class Jar extends Zip {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "fail", "warn", "ignore" };
return new String[] {"fail", "warn", "ignore"};
} }


/** /**


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

@@ -1231,7 +1231,7 @@ public class Javac extends MatchingTask {
} }


if (extensions == null) { if (extensions == null) {
extensions = new String[] { "java" };
extensions = new String[] {"java"};
} }


// now process the extensions to ensure that they are the // now process the extensions to ensure that they are the
@@ -1669,9 +1669,8 @@ public class Javac extends MatchingTask {
throw new BuildException("The modulesourcepath entry must contain at most one module mark"); throw new BuildException("The modulesourcepath entry must contain at most one module mark");
} }
final String pathToModule = pattern.substring(0, startIndex); final String pathToModule = pattern.substring(0, startIndex);
final String pathInModule = endIndex == pattern.length() ?
null :
pattern.substring(endIndex + 1); //+1 the separator
final String pathInModule = endIndex == pattern.length()
? null : pattern.substring(endIndex + 1); //+1 the separator
findModules(root, pathToModule, pathInModule, collector); findModules(root, pathToModule, pathInModule, collector);
} }




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

@@ -368,7 +368,7 @@ public class Javadoc extends Task {
public String[] getValues() { public String[] getValues() {
// Protected first so if any GUI tool offers a default // Protected first so if any GUI tool offers a default
// based on enum #0, it will be right. // based on enum #0, it will be right.
return new String[] { "protected", "public", "package", "private" };
return new String[] {"protected", "public", "package", "private"};
} }
} }


@@ -1339,7 +1339,7 @@ public class Javadoc extends Task {
private String scope = "a"; private String scope = "a";


/** Sole constructor. */ /** Sole constructor. */
public TagArgument () {
public TagArgument() {
//empty //empty
} }


@@ -1349,7 +1349,7 @@ public class Javadoc extends Task {
* @param name The name of the tag. * @param name The name of the tag.
* Must not be <code>null</code> or empty. * Must not be <code>null</code> or empty.
*/ */
public void setName (final String name) {
public void setName(final String name) {
this.name = name; this.name = name;
} }


@@ -1369,7 +1369,7 @@ public class Javadoc extends Task {
* elements are specified, or if any unrecognised elements are * elements are specified, or if any unrecognised elements are
* specified. * specified.
*/ */
public void setScope (String verboseScope) throws BuildException {
public void setScope(String verboseScope) throws BuildException {
verboseScope = verboseScope.toLowerCase(Locale.ENGLISH); verboseScope = verboseScope.toLowerCase(Locale.ENGLISH);


final boolean[] elements = new boolean[SCOPE_ELEMENTS.length]; final boolean[] elements = new boolean[SCOPE_ELEMENTS.length];
@@ -1379,7 +1379,7 @@ public class Javadoc extends Task {


// Go through the tokens one at a time, updating the // Go through the tokens one at a time, updating the
// elements array and issuing warnings where appropriate. // elements array and issuing warnings where appropriate.
final StringTokenizer tok = new StringTokenizer (verboseScope, ",");
final StringTokenizer tok = new StringTokenizer(verboseScope, ",");
while (tok.hasMoreTokens()) { while (tok.hasMoreTokens()) {
final String next = tok.nextToken().trim(); final String next = tok.nextToken().trim();
if ("all".equals(next)) { if ("all".equals(next)) {
@@ -1434,7 +1434,7 @@ public class Javadoc extends Task {
* *
* @param enabled Whether or not this tag is enabled. * @param enabled Whether or not this tag is enabled.
*/ */
public void setEnabled (final boolean enabled) {
public void setEnabled(final boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
} }




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

@@ -176,18 +176,18 @@ public class KeySubst extends Task {
while ((index = origString.indexOf("${", i)) > -1) { while ((index = origString.indexOf("${", i)) > -1) {
key = origString.substring(index + 2, origString.indexOf("}", key = origString.substring(index + 2, origString.indexOf("}",
index + 3)); index + 3));
finalString.append (origString.substring(i, index));
finalString.append(origString.substring(i, index));
if (keys.containsKey(key)) { if (keys.containsKey(key)) {
finalString.append (keys.get(key));
finalString.append(keys.get(key));
} else { } else {
finalString.append ("${");
finalString.append (key);
finalString.append ("}");
finalString.append("${");
finalString.append(key);
finalString.append("}");
} }
i = index + 3 + key.length(); i = index + 3 + key.length();
} }
// CheckStyle:MagicNumber ON // CheckStyle:MagicNumber ON
finalString.append (origString.substring(i));
finalString.append(origString.substring(i));
return finalString.toString(); return finalString.toString();
} }
} }

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

@@ -255,7 +255,7 @@ public class Length extends Task implements Condition {


/** EnumeratedAttribute operation mode */ /** EnumeratedAttribute operation mode */
public static class FileMode extends EnumeratedAttribute { public static class FileMode extends EnumeratedAttribute {
static final String[] MODES = new String[] { EACH, ALL }; //NOSONAR
static final String[] MODES = new String[] {EACH, ALL}; //NOSONAR


/** /**
* Return the possible values for FileMode. * Return the possible values for FileMode.


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

@@ -92,7 +92,7 @@ public class ManifestTask extends Task {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "update", "replace" };
return new String[] {"update", "replace"};
} }
} }




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

@@ -170,7 +170,7 @@ public class Move extends Copy {
int createCount = 0; int createCount = 0;
for (Map.Entry<String, String[]> entry : dirCopyMap.entrySet()) { for (Map.Entry<String, String[]> entry : dirCopyMap.entrySet()) {
String fromDirName = entry.getKey(); String fromDirName = entry.getKey();
String[] toDirNames = entry.getValue();;
String[] toDirNames = entry.getValue();
boolean selfMove = false; boolean selfMove = false;
for (int i = 0; i < toDirNames.length; i++) { for (int i = 0; i < toDirNames.length; i++) {
if (fromDirName.equals(toDirNames[i])) { if (fromDirName.equals(toDirNames[i])) {


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

@@ -163,8 +163,7 @@ public class PathConvert extends Task {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "windows", "unix", "netware", "os/2",
"tandem" };
return new String[] {"windows", "unix", "netware", "os/2", "tandem"};
} }
} }




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

@@ -516,7 +516,7 @@ public class Replace extends MatchingTask {
Properties props = getProperties(replaceFilterResource); Properties props = getProperties(replaceFilterResource);
Iterator<Object> e = getOrderedIterator(props); Iterator<Object> e = getOrderedIterator(props);
while (e.hasNext()) { while (e.hasNext()) {
String tok = e.next().toString();
String tok = e.next().toString();
Replacefilter replaceFilter = createReplacefilter(); Replacefilter replaceFilter = createReplacefilter();
replaceFilter.setToken(tok); replaceFilter.setToken(tok);
replaceFilter.setValue(props.getProperty(tok)); replaceFilter.setValue(props.getProperty(tok));


+ 8
- 10
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -91,7 +91,7 @@ public class SQLExec extends JDBCTask {
/** @return the enumerated strings */ /** @return the enumerated strings */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { NORMAL, ROW };
return new String[] {NORMAL, ROW};
} }
} }


@@ -987,7 +987,7 @@ public class SQLExec extends JDBCTask {
/** @return the enumerated values */ /** @return the enumerated values */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "continue", "stop", "abort" };
return new String[] {"continue", "stop", "abort"};
} }
} }


@@ -1071,9 +1071,9 @@ public class SQLExec extends JDBCTask {
public int lastDelimiterPosition(StringBuffer buf, String currentLine) { public int lastDelimiterPosition(StringBuffer buf, String currentLine) {
if (strictDelimiterMatching) { if (strictDelimiterMatching) {
if ((delimiterType.equals(DelimiterType.NORMAL) if ((delimiterType.equals(DelimiterType.NORMAL)
&& StringUtils.endsWith(buf, delimiter)) ||
(delimiterType.equals(DelimiterType.ROW)
&& currentLine.equals(delimiter))) {
&& StringUtils.endsWith(buf, delimiter))
|| (delimiterType.equals(DelimiterType.ROW)
&& currentLine.equals(delimiter))) {
return buf.length() - delimiter.length(); return buf.length() - delimiter.length();
} }
// no match // no match
@@ -1085,17 +1085,15 @@ public class SQLExec extends JDBCTask {
// StringUtils.endsWith // StringUtils.endsWith
int endIndex = delimiter.length() - 1; int endIndex = delimiter.length() - 1;
int bufferIndex = buf.length() - 1; int bufferIndex = buf.length() - 1;
while (bufferIndex >= 0
&& Character.isWhitespace(buf.charAt(bufferIndex))) {
while (bufferIndex >= 0 && Character.isWhitespace(buf.charAt(bufferIndex))) {
--bufferIndex; --bufferIndex;
} }
if (bufferIndex < endIndex) { if (bufferIndex < endIndex) {
return -1; return -1;
} }
while (endIndex >= 0) { while (endIndex >= 0) {
if (buf.substring(bufferIndex, bufferIndex + 1)
.toLowerCase(Locale.ENGLISH).charAt(0)
!= d.charAt(endIndex)) {
if (buf.substring(bufferIndex, bufferIndex + 1).toLowerCase(Locale.ENGLISH)
.charAt(0) != d.charAt(endIndex)) {
return -1; return -1;
} }
bufferIndex--; bufferIndex--;


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

@@ -76,7 +76,7 @@ public class SetPermissions extends Task {
* Try DosFilePermissions - setting the read-only flag - and * Try DosFilePermissions - setting the read-only flag - and
* log an error and go on if that fails as well. * log an error and go on if that fails as well.
*/ */
tryDosOrPass;
tryDosOrPass
} }


/** /**
@@ -153,11 +153,11 @@ public class SetPermissions extends Task {
} }
} }
} catch (ClassCastException cce) { } catch (ClassCastException cce) {
maybeThrowException(null,
"some specified permissions are not of type PosixFilePermission: %s",
maybeThrowException(null,
"some specified permissions are not of type PosixFilePermission: %s",
StringUtils.join(permissions, ", ")); StringUtils.join(permissions, ", "));
} catch (SecurityException se) { } catch (SecurityException se) {
maybeThrowException(null,
maybeThrowException(null,
"the SecurityManager denies role accessUserInformation or write access for SecurityManager.checkWrite for resource '%s'", "the SecurityManager denies role accessUserInformation or write access for SecurityManager.checkWrite for resource '%s'",
currentResource); currentResource);
} catch (BuildException be) { } catch (BuildException be) {


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

@@ -143,7 +143,7 @@ public class StreamPumper implements Runnable {
} }
// On completion, drain any available data (which might be the first data available for quick executions) // On completion, drain any available data (which might be the first data available for quick executions)
if (finish) { if (finish) {
while((length = is.available()) > 0) {
while ((length = is.available()) > 0) {
if (Thread.interrupted()) { if (Thread.interrupted()) {
break; break;
} }


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

@@ -188,7 +188,7 @@ public class Sync extends Task {
*/ */
private int[] removeOrphanFiles(Set<String> nonOrphans, File toDir, private int[] removeOrphanFiles(Set<String> nonOrphans, File toDir,
Set<File> preservedDirectories) { Set<File> preservedDirectories) {
int[] removedCount = new int[] { 0, 0 };
int[] removedCount = new int[] {0, 0};
String[] excls = String[] excls =
nonOrphans.toArray(new String[nonOrphans.size() + 1]); nonOrphans.toArray(new String[nonOrphans.size() + 1]);
// want to keep toDir itself // want to keep toDir itself


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

@@ -980,7 +980,7 @@ public class Tar extends MatchingTask {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { NONE, GZIP, BZIP2, XZ };
return new String[] {NONE, GZIP, BZIP2, XZ};
} }


/** /**


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

@@ -24,7 +24,6 @@ import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Vector; import java.util.Vector;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;


+ 10
- 21
src/main/org/apache/tools/ant/taskdefs/Tstamp.java View File

@@ -78,14 +78,14 @@ public class Tstamp extends Task {


customFormats.forEach(cts -> cts.execute(getProject(), d, getLocation())); customFormats.forEach(cts -> cts.execute(getProject(), d, getLocation()));


SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd");
SimpleDateFormat dstamp = new SimpleDateFormat("yyyyMMdd");
setProperty("DSTAMP", dstamp.format(d)); setProperty("DSTAMP", dstamp.format(d));


SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm");
SimpleDateFormat tstamp = new SimpleDateFormat("HHmm");
setProperty("TSTAMP", tstamp.format(d)); setProperty("TSTAMP", tstamp.format(d));


SimpleDateFormat today SimpleDateFormat today
= new SimpleDateFormat ("MMMM d yyyy", Locale.US);
= new SimpleDateFormat("MMMM d yyyy", Locale.US);
setProperty("TODAY", today.format(d)); setProperty("TODAY", today.format(d));


} catch (Exception e) { } catch (Exception e) {
@@ -131,11 +131,7 @@ public class Tstamp extends Task {
s -> new Date(1000 * Long.parseLong(s)), s -> new Date(1000 * Long.parseLong(s)),
(k, v) -> "magic property " + k + " ignored as " + v + " is not a valid number" (k, v) -> "magic property " + k + " ignored as " + v + " is not a valid number"
); );
if (now.isPresent()) {
return now.get();
}

return new Date();
return now.orElseGet(Date::new);
} }


/** /**
@@ -213,16 +209,14 @@ public class Tstamp extends Task {
if (st.hasMoreElements()) { if (st.hasMoreElements()) {
variant = st.nextToken(); variant = st.nextToken();
if (st.hasMoreElements()) { if (st.hasMoreElements()) {
throw new BuildException("bad locale format",
getLocation());
throw new BuildException("bad locale format", getLocation());
} }
} }
} else { } else {
country = ""; country = "";
} }
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
throw new BuildException("bad locale format", e,
getLocation());
throw new BuildException("bad locale format", e, getLocation());
} }
} }


@@ -290,25 +284,20 @@ public class Tstamp extends Task {
*/ */
public void execute(Project project, Date date, Location location) { public void execute(Project project, Date date, Location location) {
if (propertyName == null) { if (propertyName == null) {
throw new BuildException("property attribute must be provided",
location);
throw new BuildException("property attribute must be provided", location);
} }


if (pattern == null) { if (pattern == null) {
throw new BuildException("pattern attribute must be provided",
location);
throw new BuildException("pattern attribute must be provided", location);
} }


SimpleDateFormat sdf; SimpleDateFormat sdf;
if (language == null) { if (language == null) {
sdf = new SimpleDateFormat(pattern); sdf = new SimpleDateFormat(pattern);
} else if (variant == null) { } else if (variant == null) {
sdf = new SimpleDateFormat(pattern,
new Locale(language, country));
sdf = new SimpleDateFormat(pattern, new Locale(language, country));
} else { } else {
sdf = new SimpleDateFormat(pattern,
new Locale(language, country,
variant));
sdf = new SimpleDateFormat(pattern, new Locale(language, country, variant));
} }
if (offset != 0) { if (offset != 0) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();


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

@@ -204,7 +204,7 @@ public class Untar extends Expand {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { NONE, GZIP, BZIP2, XZ };
return new String[] {NONE, GZIP, BZIP2, XZ};
} }


/** /**


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

@@ -1290,7 +1290,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
((XSLTLiaison4) liaison).addParam(p.getName(), ((XSLTLiaison4) liaison).addParam(p.getName(),
evaluatedParam); evaluatedParam);
} else if (evaluatedParam == null || evaluatedParam instanceof String) { } else if (evaluatedParam == null || evaluatedParam instanceof String) {
liaison.addParam(p.getName(), (String)evaluatedParam);
liaison.addParam(p.getName(), (String) evaluatedParam);
} else { } else {
log("XSLTLiaison '" + liaison.getClass().getName() log("XSLTLiaison '" + liaison.getClass().getName()
+ "' supports only String parameters. Converting parameter '" + p.getName() + "' supports only String parameters. Converting parameter '" + p.getName()
@@ -1373,7 +1373,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
final String fileName = FileUtils.getRelativePath(baseDir, inFile); final String fileName = FileUtils.getRelativePath(baseDir, inFile);
final File file = new File(fileName); final File file = new File(fileName);
// Give always a slash as file separator, so the stylesheet could be sure about that // Give always a slash as file separator, so the stylesheet could be sure about that
// Use '.' so a dir+"/"+name would not result in an absolute path
// Use '.' so a dir + "/" + name would not result in an absolute path
liaison.addParam(fileDirParameter, file.getParent() != null ? file.getParent().replace( liaison.addParam(fileDirParameter, file.getParent() != null ? file.getParent().replace(
'\\', '/') : "."); '\\', '/') : ".");
} }


+ 12
- 12
src/main/org/apache/tools/ant/taskdefs/XmlProperty.java View File

@@ -330,7 +330,7 @@ public class XmlProperty extends org.apache.tools.ant.Task {
* either a String if this node resulted in setting an attribute, * either a String if this node resulted in setting an attribute,
* or a Path. * or a Path.
*/ */
public Object processNode (Node node, String prefix, Object container) {
public Object processNode(Node node, String prefix, Object container) {


// Parse the attribute(s) and text of this node, adding // Parse the attribute(s) and text of this node, adding
// properties for each. // properties for each.
@@ -460,7 +460,7 @@ public class XmlProperty extends org.apache.tools.ant.Task {
* Actually add the given property/value to the project * Actually add the given property/value to the project
* after writing a log message. * after writing a log message.
*/ */
private void addProperty (String name, String value, String id) {
private void addProperty(String name, String value, String id) {
String msg = name + ":" + value; String msg = name + ":" + value;
if (id != null) { if (id != null) {
msg += ("(id=" + id + ")"); msg += ("(id=" + id + ")");
@@ -497,7 +497,7 @@ public class XmlProperty extends org.apache.tools.ant.Task {
* Otherwise, we return "(nodename)". This is long-standing * Otherwise, we return "(nodename)". This is long-standing
* (and default) &lt;xmlproperty&gt; behavior. * (and default) &lt;xmlproperty&gt; behavior.
*/ */
private String getAttributeName (Node attributeNode) {
private String getAttributeName(Node attributeNode) {
String attributeName = attributeNode.getNodeName(); String attributeName = attributeNode.getNodeName();


if (semanticAttributes) { if (semanticAttributes) {
@@ -518,7 +518,7 @@ public class XmlProperty extends org.apache.tools.ant.Task {
/** /**
* Return whether the provided attribute name is recognized or not. * Return whether the provided attribute name is recognized or not.
*/ */
private static boolean isSemanticAttribute (String attributeName) {
private static boolean isSemanticAttribute(String attributeName) {
return Arrays.asList(ATTRIBUTES).contains(attributeName); return Arrays.asList(ATTRIBUTES).contains(attributeName);
} }


@@ -534,7 +534,7 @@ public class XmlProperty extends org.apache.tools.ant.Task {
* resolved to absolute file names. Also for refid values, look * resolved to absolute file names. Also for refid values, look
* up the referenced object from the project.</p> * up the referenced object from the project.</p>
*/ */
private String getAttributeValue (Node attributeNode) {
private String getAttributeValue(Node attributeNode) {
String nodeValue = attributeNode.getNodeValue().trim(); String nodeValue = attributeNode.getNodeValue().trim();
if (semanticAttributes) { if (semanticAttributes) {
String attributeName = attributeNode.getNodeName(); String attributeName = attributeNode.getNodeName();
@@ -663,7 +663,7 @@ public class XmlProperty extends org.apache.tools.ant.Task {
/** /**
* @return the file attribute. * @return the file attribute.
*/ */
protected File getFile () {
protected File getFile() {
FileProvider fp = src.as(FileProvider.class); FileProvider fp = src.as(FileProvider.class);
return fp != null ? fp.getFile() : null; return fp != null ? fp.getFile() : null;
} }
@@ -683,42 +683,42 @@ public class XmlProperty extends org.apache.tools.ant.Task {
/** /**
* @return the prefix attribute. * @return the prefix attribute.
*/ */
protected String getPrefix () {
protected String getPrefix() {
return this.prefix; return this.prefix;
} }


/** /**
* @return the keeproot attribute. * @return the keeproot attribute.
*/ */
protected boolean getKeeproot () {
protected boolean getKeeproot() {
return this.keepRoot; return this.keepRoot;
} }


/** /**
* @return the validate attribute. * @return the validate attribute.
*/ */
protected boolean getValidate () {
protected boolean getValidate() {
return this.validate; return this.validate;
} }


/** /**
* @return the collapse attributes attribute. * @return the collapse attributes attribute.
*/ */
protected boolean getCollapseAttributes () {
protected boolean getCollapseAttributes() {
return this.collapseAttributes; return this.collapseAttributes;
} }


/** /**
* @return the semantic attributes attribute. * @return the semantic attributes attribute.
*/ */
protected boolean getSemanticAttributes () {
protected boolean getSemanticAttributes() {
return this.semanticAttributes; return this.semanticAttributes;
} }


/** /**
* @return the root directory attribute. * @return the root directory attribute.
*/ */
protected File getRootDirectory () {
protected File getRootDirectory() {
return this.rootDirectory; return this.rootDirectory;
} }




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

@@ -89,7 +89,7 @@ public class Zip extends MatchingTask {
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();


// For directories: // For directories:
private static final long EMPTY_CRC = new CRC32 ().getValue ();
private static final long EMPTY_CRC = new CRC32().getValue();


private static final ResourceSelector MISSING_SELECTOR = private static final ResourceSelector MISSING_SELECTOR =
target -> !target.isExists(); target -> !target.isExists();
@@ -387,7 +387,7 @@ public class Zip extends MatchingTask {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "fail", "skip", "create" };
return new String[] {"fail", "skip", "create"};
} }
} }


@@ -765,7 +765,7 @@ public class Zip extends MatchingTask {
// temporary file // temporary file
if (doUpdate) { if (doUpdate) {
if (!renamedFile.delete()) { if (!renamedFile.delete()) {
log ("Warning: unable to delete temporary file "
log("Warning: unable to delete temporary file "
+ renamedFile.getName(), Project.MSG_WARN); + renamedFile.getName(), Project.MSG_WARN);
} }
} }
@@ -1708,7 +1708,7 @@ public class Zip extends MatchingTask {
addedDirs.put(vPath, vPath); addedDirs.put(vPath, vPath);


if (!skipWriting) { if (!skipWriting) {
final ZipEntry ze = new ZipEntry (vPath);
final ZipEntry ze = new ZipEntry(vPath);


// ZIPs store time with a granularity of 2 seconds, round up // ZIPs store time with a granularity of 2 seconds, round up
final int millisToAdd = roundUp ? ROUNDUP_MILLIS : 0; final int millisToAdd = roundUp ? ROUNDUP_MILLIS : 0;
@@ -1720,10 +1720,10 @@ public class Zip extends MatchingTask {
} else { } else {
ze.setTime(System.currentTimeMillis() + millisToAdd); ze.setTime(System.currentTimeMillis() + millisToAdd);
} }
ze.setSize (0);
ze.setMethod (ZipEntry.STORED);
ze.setSize(0);
ze.setMethod(ZipEntry.STORED);
// This is faintly ridiculous: // This is faintly ridiculous:
ze.setCrc (EMPTY_CRC);
ze.setCrc(EMPTY_CRC);
ze.setUnixMode(mode); ze.setUnixMode(mode);


if (extra != null) { if (extra != null) {
@@ -1983,7 +1983,7 @@ public class Zip extends MatchingTask {
entries.clear(); entries.clear();
addingNewFiles = false; addingNewFiles = false;
doUpdate = savedDoUpdate; doUpdate = savedDoUpdate;
filesetsFromGroupfilesets.forEach(resources::remove);
resources.removeAll(filesetsFromGroupfilesets);
filesetsFromGroupfilesets.clear(); filesetsFromGroupfilesets.clear();
HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.FALSE); HAVE_NON_FILE_SET_RESOURCES_TO_ADD.set(Boolean.FALSE);
} }
@@ -2101,7 +2101,7 @@ public class Zip extends MatchingTask {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "add", "preserve", "fail" };
return new String[] {"add", "preserve", "fail"};
} }
} }


@@ -2234,7 +2234,7 @@ public class Zip extends MatchingTask {


@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { NEVER_KEY, ALWAYS_KEY, A_N_KEY };
return new String[] {NEVER_KEY, ALWAYS_KEY, A_N_KEY};
} }


public static final Zip64ModeAttribute NEVER = public static final Zip64ModeAttribute NEVER =


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

@@ -150,7 +150,7 @@ public abstract class DefaultCompilerAdapter
*/ */
@Override @Override
public String[] getSupportedFileExtensions() { public String[] getSupportedFileExtensions() {
return new String[] { "java" };
return new String[] {"java"};
} }


/** /**
@@ -432,8 +432,8 @@ public abstract class DefaultCompilerAdapter
cmd.createArgument().setPath(ump); cmd.createArgument().setPath(ump);
} }
if (attributes.getNativeHeaderDir() != null) { if (attributes.getNativeHeaderDir() != null) {
if (assumeJava13() || assumeJava14() || assumeJava15()
|| assumeJava16() || assumeJava17()) {
if (assumeJava13() || assumeJava14() || assumeJava15() || assumeJava16()
|| assumeJava17()) {
attributes.log( attributes.log(
"Support for javac -h has been added in Java8, ignoring it"); "Support for javac -h has been added in Java8, ignoring it");
} else { } else {
@@ -484,20 +484,15 @@ public abstract class DefaultCompilerAdapter
* @param cmd the command line * @param cmd the command line
*/ */
protected void logAndAddFilesToCompile(final Commandline cmd) { protected void logAndAddFilesToCompile(final Commandline cmd) {
attributes.log("Compilation " + cmd.describeArguments(),
Project.MSG_VERBOSE);
attributes.log("Compilation " + cmd.describeArguments(), Project.MSG_VERBOSE);


attributes.log(
String.format("%s to be compiled:",
compileList.length == 1 ? "File" : "Files"),
Project.MSG_VERBOSE);
attributes.log(String.format("%s to be compiled:",
compileList.length == 1 ? "File" : "Files"), Project.MSG_VERBOSE);


attributes.log(
Stream.of(compileList).map(File::getAbsolutePath)
.peek(arg -> cmd.createArgument().setValue(arg))
.map(arg -> " " + arg)
.collect(Collectors.joining(StringUtils.LINE_SEP)),
Project.MSG_VERBOSE);
attributes.log(Stream.of(compileList).map(File::getAbsolutePath)
.peek(arg -> cmd.createArgument().setValue(arg))
.map(arg -> " " + arg)
.collect(Collectors.joining(StringUtils.LINE_SEP)), Project.MSG_VERBOSE);
} }


/** /**
@@ -723,10 +718,10 @@ public abstract class DefaultCompilerAdapter
return "javac1.9".equals(attributes.getCompilerVersion()) return "javac1.9".equals(attributes.getCompilerVersion())
|| "javac9".equals(attributes.getCompilerVersion()) || "javac9".equals(attributes.getCompilerVersion())
|| "javac10+".equals(attributes.getCompilerVersion()) || "javac10+".equals(attributes.getCompilerVersion())
|| (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9) &&
("classic".equals(attributes.getCompilerVersion())
|| "modern".equals(attributes.getCompilerVersion())
|| "extJavac".equals(attributes.getCompilerVersion())));
|| (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)
&& ("classic".equals(attributes.getCompilerVersion())
|| "modern".equals(attributes.getCompilerVersion())
|| "extJavac".equals(attributes.getCompilerVersion())));
} }


/** /**
@@ -735,8 +730,8 @@ public abstract class DefaultCompilerAdapter
*/ */
private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) { private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) {
return javacXY.equals(attributes.getCompilerVersion()) return javacXY.equals(attributes.getCompilerVersion())
|| (JavaEnvUtils.isJavaVersion(javaEnvVersionXY) &&
("classic".equals(attributes.getCompilerVersion())
|| (JavaEnvUtils.isJavaVersion(javaEnvVersionXY)
&& ("classic".equals(attributes.getCompilerVersion())
|| "modern".equals(attributes.getCompilerVersion()) || "modern".equals(attributes.getCompilerVersion())
|| "extJavac".equals(attributes.getCompilerVersion()))); || "extJavac".equals(attributes.getCompilerVersion())));
} }
@@ -825,11 +820,10 @@ public abstract class DefaultCompilerAdapter
t = t.substring(2); t = t.substring(2);
} }
return "1".equals(t) || "2".equals(t) || "3".equals(t) || "4".equals(t) return "1".equals(t) || "2".equals(t) || "3".equals(t) || "4".equals(t)
|| (("5".equals(t) || "6".equals(t))
&& !assumeJava15() && !assumeJava16())
|| ("7".equals(t) && !assumeJava17())
|| ("8".equals(t) && !assumeJava18())
|| ("9".equals(t) && !assumeJava9Plus());
|| (("5".equals(t) || "6".equals(t)) && !assumeJava15() && !assumeJava16())
|| ("7".equals(t) && !assumeJava17())
|| ("8".equals(t) && !assumeJava18())
|| ("9".equals(t) && !assumeJava9Plus());
} }


/** /**


+ 4
- 7
src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java View File

@@ -31,9 +31,7 @@ import org.apache.tools.ant.types.Path;
* @since Ant 1.4 * @since Ant 1.4
*/ */
public class Gcj extends DefaultCompilerAdapter { public class Gcj extends DefaultCompilerAdapter {
private static final String [] CONFLICT_WITH_DASH_C = {
"-o" , "--main=", "-D", "-fjni", "-L"
};
private static final String[] CONFLICT_WITH_DASH_C = {"-o", "--main=", "-D", "-fjni", "-L"};


/** /**
* Performs a compile using the gcj compiler. * Performs a compile using the gcj compiler.
@@ -145,10 +143,9 @@ public class Gcj extends DefaultCompilerAdapter {
int argsLength = 0; int argsLength = 0;
while (!nativeBuild && argsLength < additionalArguments.length) { while (!nativeBuild && argsLength < additionalArguments.length) {
int conflictLength = 0; int conflictLength = 0;
while (!nativeBuild
&& conflictLength < CONFLICT_WITH_DASH_C.length) {
nativeBuild = (additionalArguments[argsLength].startsWith
(CONFLICT_WITH_DASH_C[conflictLength]));
while (!nativeBuild && conflictLength < CONFLICT_WITH_DASH_C.length) {
nativeBuild = additionalArguments[argsLength]
.startsWith(CONFLICT_WITH_DASH_C[conflictLength]);
conflictLength++; conflictLength++;
} }
argsLength++; argsLength++;


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

@@ -68,7 +68,7 @@ public class Javac12 extends DefaultCompilerAdapter {
new Object[] {cmd.getArguments()}); new Object[] {cmd.getArguments()});
return ok.booleanValue(); return ok.booleanValue();
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new BuildException("Cannot use classic compiler , as it is "
throw new BuildException("Cannot use classic compiler, as it is "
+ "not available. \n" + "not available. \n"
+ " A common solution is " + " A common solution is "
+ "to set the environment variable" + "to set the environment variable"


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

@@ -51,7 +51,7 @@ public class Javac13 extends DefaultCompilerAdapter {


// Use reflection to be able to build on all JDKs >= 1.1: // Use reflection to be able to build on all JDKs >= 1.1:
try { try {
Class<?> c = Class.forName ("com.sun.tools.javac.Main");
Class<?> c = Class.forName("com.sun.tools.javac.Main");
Object compiler = c.newInstance(); Object compiler = c.newInstance();
Method compile = c.getMethod("compile", String[].class); Method compile = c.getMethod("compile", String[].class);
int result = ((Integer) compile.invoke(compiler, int result = ((Integer) compile.invoke(compiler,


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

@@ -21,6 +21,7 @@ package org.apache.tools.ant.taskdefs.condition;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Locale; import java.util.Locale;
@@ -117,7 +118,7 @@ public class Http extends ProjectComponent implements Condition {
} }
return false; return false;
} }
} catch (java.net.ProtocolException pe) {
} catch (ProtocolException pe) {
throw new BuildException("Invalid HTTP protocol: " throw new BuildException("Invalid HTTP protocol: "
+ requestMethod, pe); + requestMethod, pe);
} catch (IOException e) { } catch (IOException e) {


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

@@ -160,7 +160,7 @@ public class IsLastModified extends ProjectComponent implements Condition {
long expected = getMillis(); long expected = getMillis();
long actual = resource.getLastModified(); long actual = resource.getLastModified();
log("expected timestamp: " + expected + " (" + new Date(expected) + ")" log("expected timestamp: " + expected + " (" + new Date(expected) + ")"
+ ", actual timestamp: " + actual + " (" + new Date(actual) + ")" ,
+ ", actual timestamp: " + actual + " (" + new Date(actual) + ")",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
if (CompareMode.EQUALS_TEXT.equals(mode.getValue())) { if (CompareMode.EQUALS_TEXT.equals(mode.getValue())) {
return expected == actual; return expected == actual;


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

@@ -61,7 +61,7 @@ public class EmailTask extends Task {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { AUTO, MIME, UU, PLAIN };
return new String[] {AUTO, MIME, UU, PLAIN};
} }
} }




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

@@ -154,7 +154,7 @@ public class Message extends ProjectComponent {
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setCharset(String charset) { public void setCharset(String charset) {
this.charset = charset;
this.charset = charset;
} }


/** /**
@@ -164,7 +164,7 @@ public class Message extends ProjectComponent {
* @since Ant 1.6 * @since Ant 1.6
*/ */
public String getCharset() { public String getCharset() {
return charset;
return charset;
} }


/** /**


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

@@ -56,9 +56,9 @@ public class Java13CommandLauncher extends CommandLauncher {
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
return Runtime.getRuntime().exec(cmd, env, workingDir); return Runtime.getRuntime().exec(cmd, env, workingDir);
} catch(IOException ioex) {
} catch (IOException ioex) {
throw ioex; throw ioex;
} catch(Exception exc) {
} catch (Exception exc) {
// IllegalAccess, IllegalArgument, ClassCast // IllegalAccess, IllegalArgument, ClassCast
throw new BuildException("Unable to execute command", exc); throw new BuildException("Unable to execute command", exc);
} }


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

@@ -50,7 +50,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher {
throws IOException { throws IOException {
File cmdFile = createCommandFile(cmd, env); File cmdFile = createCommandFile(cmd, env);
Process p = Process p =
super.exec(project, new String[] { cmdFile.getPath() }, env);
super.exec(project, new String[] {cmdFile.getPath()}, env);
deleteAfter(cmdFile, p); deleteAfter(cmdFile, p);
return p; return p;
} }
@@ -77,7 +77,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher {
public Process exec(Project project, String[] cmd, String[] env, public Process exec(Project project, String[] cmd, String[] env,
File workingDir) throws IOException { File workingDir) throws IOException {
File cmdFile = createCommandFile(cmd, env); File cmdFile = createCommandFile(cmd, env);
Process p = super.exec(project, new String[] { cmdFile.getPath() }, env,
Process p = super.exec(project, new String[] {cmdFile.getPath()}, env,
workingDir); workingDir);
deleteAfter(cmdFile, p); deleteAfter(cmdFile, p);
return p; return p;


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

@@ -244,7 +244,7 @@ public class Cab extends MatchingTask {


try { try {
Process p = Execute.launch(getProject(), Process p = Execute.launch(getProject(),
new String[] { "listcab" }, null,
new String[] {"listcab"}, null,
baseDir != null ? baseDir : getProject().getBaseDir(), baseDir != null ? baseDir : getProject().getBaseDir(),
true); true);
OutputStream out = p.getOutputStream(); OutputStream out = p.getOutputStream();


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

@@ -240,7 +240,7 @@ public class EchoProperties extends Task {
* The values are "xml" and "text". * The values are "xml" and "text".
*/ */
public static class FormatAttribute extends EnumeratedAttribute { public static class FormatAttribute extends EnumeratedAttribute {
private String[] formats = new String[] { "xml", "text" };
private String[] formats = new String[] {"xml", "text"};


/** /**
* @see EnumeratedAttribute#getValues() * @see EnumeratedAttribute#getValues()
@@ -357,7 +357,7 @@ public class EchoProperties extends Task {
} }


@Override @Override
public Set<Map.Entry<Object,Object>> entrySet() {
public Set<Map.Entry<Object, Object>> entrySet() {
Set<Map.Entry<Object, Object>> result = super.entrySet(); Set<Map.Entry<Object, Object>> result = super.entrySet();
if (JavaEnvUtils.isKaffe()) { if (JavaEnvUtils.isKaffe()) {
Set<Map.Entry<Object, Object>> t = Set<Map.Entry<Object, Object>> t =


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

@@ -455,11 +455,9 @@ public class Javah extends Task {
classpath = classpath.concatSystemClasspath("ignore"); classpath = classpath.concatSystemClasspath("ignore");
} }


JavahAdapter ad =
nestedAdapter != null ? nestedAdapter :
JavahAdapterFactory.getAdapter(facade.getImplementation(),
this,
createImplementationClasspath());
JavahAdapter ad = nestedAdapter != null ? nestedAdapter
: JavahAdapterFactory.getAdapter(facade.getImplementation(), this,
createImplementationClasspath());
if (!ad.compile(this)) { if (!ad.compile(this)) {
throw new BuildException("compilation failed"); throw new BuildException("compilation failed");
} }


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

@@ -294,11 +294,9 @@ public class Native2Ascii extends MatchingTask {
} }


log("converting " + srcName, Project.MSG_VERBOSE); log("converting " + srcName, Project.MSG_VERBOSE);
Native2AsciiAdapter ad =
nestedAdapter != null ? nestedAdapter :
Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(),
this,
createImplementationClasspath());
Native2AsciiAdapter ad = nestedAdapter != null ? nestedAdapter
: Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(), this,
createImplementationClasspath());
if (!ad.convert(this, srcFile, destFile)) { if (!ad.convert(this, srcFile, destFile)) {
throw new BuildException("conversion failed"); throw new BuildException("conversion failed");
} }
@@ -328,10 +326,9 @@ public class Native2Ascii extends MatchingTask {
public String[] mapFileName(String fileName) { public String[] mapFileName(String fileName) {
int lastDot = fileName.lastIndexOf('.'); int lastDot = fileName.lastIndexOf('.');
if (lastDot >= 0) { if (lastDot >= 0) {
return new String[] {
fileName.substring(0, lastDot) + extension };
return new String[] {fileName.substring(0, lastDot) + extension};
} }
return new String[] { fileName + extension };
return new String[] {fileName + extension};
} }
} }
} }

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

@@ -946,7 +946,7 @@ public class NetRexxC extends MatchingTask {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "trace", "trace1", "trace2", "notrace" };
return new String[] {"trace", "trace1", "trace2", "notrace"};
} }
} }


@@ -957,8 +957,8 @@ public class NetRexxC extends MatchingTask {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "verbose", "verbose0", "verbose1", "verbose2",
"verbose3", "verbose4", "verbose5", "noverbose" };
return new String[] {"verbose", "verbose0", "verbose1", "verbose2",
"verbose3", "verbose4", "verbose5", "noverbose"};
} }
} }
} }

+ 20
- 21
src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java View File

@@ -283,14 +283,14 @@ public class PropertyFile extends Task {
private static final String DEFAULT_DATE_VALUE = "now"; private static final String DEFAULT_DATE_VALUE = "now";
private static final String DEFAULT_STRING_VALUE = ""; private static final String DEFAULT_STRING_VALUE = "";


private String key = null;
private int type = Type.STRING_TYPE;
private int operation = Operation.EQUALS_OPER;
private String value = null;
private String defaultValue = null;
private String newValue = null;
private String pattern = null;
private int field = Calendar.DATE;
private String key = null;
private int type = Type.STRING_TYPE;
private int operation = Operation.EQUALS_OPER;
private String value = null;
private String defaultValue = null;
private String newValue = null;
private String pattern = null;
private int field = Calendar.DATE;


/** /**
* Name of the property name/value pair * Name of the property name/value pair
@@ -389,8 +389,7 @@ public class PropertyFile extends Task {
} else if (type == Type.STRING_TYPE) { } else if (type == Type.STRING_TYPE) {
executeString(oldValue); executeString(oldValue);
} else { } else {
throw new BuildException("Unknown operation type: %d",
type);
throw new BuildException("Unknown operation type: %d", type);
} }
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
// Default to string type // Default to string type
@@ -600,18 +599,18 @@ public class PropertyFile extends Task {


// Property type operations // Property type operations
/** + */ /** + */
public static final int INCREMENT_OPER = 0;
public static final int INCREMENT_OPER = 0;
/** - */ /** - */
public static final int DECREMENT_OPER = 1;
public static final int DECREMENT_OPER = 1;
/** = */ /** = */
public static final int EQUALS_OPER = 2;
public static final int EQUALS_OPER = 2;
/** del */ /** del */
public static final int DELETE_OPER = 3;
public static final int DELETE_OPER = 3;


/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "+", "-", "=", "del" };
return new String[] {"+", "-", "=", "del"};
} }


/** /**
@@ -640,16 +639,16 @@ public class PropertyFile extends Task {


// Property types // Property types
/** int */ /** int */
public static final int INTEGER_TYPE = 0;
public static final int INTEGER_TYPE = 0;
/** date */ /** date */
public static final int DATE_TYPE = 1;
public static final int DATE_TYPE = 1;
/** string */ /** string */
public static final int STRING_TYPE = 2;
public static final int STRING_TYPE = 2;


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "int", "date", "string" };
return new String[] {"int", "date", "string"};
} }


/** /**
@@ -685,8 +684,8 @@ public class PropertyFile extends Task {
private static final String MONTH = "month"; private static final String MONTH = "month";
private static final String YEAR = "year"; private static final String YEAR = "year";


private static final String[] UNITS =
{ MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR };
private static final String[] UNITS = {MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH,
YEAR};


private Map<String, Integer> calendarFields = new HashMap<>(); private Map<String, Integer> calendarFields = new HashMap<>();




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

@@ -115,9 +115,8 @@ public class Rpm extends Task {


Commandline toExecute = new Commandline(); Commandline toExecute = new Commandline();


toExecute.setExecutable(rpmBuildCommand == null
? guessRpmBuildCommand()
: rpmBuildCommand);
toExecute.setExecutable(rpmBuildCommand == null ? guessRpmBuildCommand()
: rpmBuildCommand);
if (topDir != null) { if (topDir != null) {
toExecute.createArgument().setValue("--define"); toExecute.createArgument().setValue("--define");
toExecute.createArgument().setValue("_topdir " + topDir); toExecute.createArgument().setValue("_topdir " + topDir);
@@ -170,7 +169,7 @@ public class Rpm extends Task {
fos = Files.newOutputStream(error.toPath()); fos = Files.newOutputStream(error.toPath());
BufferedOutputStream bos = new BufferedOutputStream(fos); BufferedOutputStream bos = new BufferedOutputStream(fos);
errorstream = new PrintStream(bos); errorstream = new PrintStream(bos);
} catch (IOException e) {
} catch (IOException e) {
FileUtils.close(fos); FileUtils.close(fos);
throw new BuildException(e, getLocation()); throw new BuildException(e, getLocation());
} }


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

@@ -251,12 +251,11 @@ public class BorlandDeploymentTool extends GenericDeploymentTool
File borlandDD = new File(getConfig().descriptorDir, ddPrefix + dd); File borlandDD = new File(getConfig().descriptorDir, ddPrefix + dd);
if (borlandDD.exists()) { if (borlandDD.exists()) {
log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE); log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE);
ejbFiles.put(META_DIR + dd , borlandDD);
ejbFiles.put(META_DIR + dd, borlandDD);
} else { } else {
log("Unable to locate borland deployment descriptor. " log("Unable to locate borland deployment descriptor. "
+ "It was expected to be in " + "It was expected to be in "
+ borlandDD.getPath(), Project.MSG_WARN); + borlandDD.getPath(), Project.MSG_WARN);
return;
} }
} }




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

@@ -29,6 +29,7 @@ import java.util.Map;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.xml.sax.AttributeList; import org.xml.sax.AttributeList;
import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;


@@ -40,7 +41,7 @@ import org.xml.sax.SAXException;
* inserted into an EJB jar as to a File representing the file on disk. This * inserted into an EJB jar as to a File representing the file on disk. This
* list can then be accessed through the getFiles() method. * list can then be accessed through the getFiles() method.
*/ */
public class DescriptorHandler extends org.xml.sax.HandlerBase {
public class DescriptorHandler extends HandlerBase {
private static final int DEFAULT_HASH_TABLE_SIZE = 10; private static final int DEFAULT_HASH_TABLE_SIZE = 10;
private static final int STATE_LOOKING_EJBJAR = 1; private static final int STATE_LOOKING_EJBJAR = 1;
private static final int STATE_IN_EJBJAR = 2; private static final int STATE_IN_EJBJAR = 2;
@@ -221,7 +222,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
} }
} }


owningTask.log("Could not resolve ( publicId: " + publicId
owningTask.log("Could not resolve (publicId: " + publicId
+ ", systemId: " + systemId + ") to a local entity", Project.MSG_INFO); + ", systemId: " + systemId + ") to a local entity", Project.MSG_INFO);


return null; return null;


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

@@ -163,8 +163,7 @@ public class EjbJar extends MatchingTask {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { EJB_NAME, DIRECTORY, DESCRIPTOR,
BASEJARNAME };
return new String[] {EJB_NAME, DIRECTORY, DESCRIPTOR, BASEJARNAME};
} }
} }




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

@@ -749,7 +749,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
} }
manifest = new Manifest(in); manifest = new Manifest(in);
} catch (IOException e) { } catch (IOException e) {
throw new BuildException ("Unable to read manifest", e, getLocation());
throw new BuildException("Unable to read manifest", e, getLocation());
} finally { } finally {
if (in != null) { if (in != null) {
in.close(); in.close();


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

@@ -706,7 +706,7 @@ public class IPlanetEjbc {
inputStream = Files.newInputStream(Paths.get(location)); //NOSONAR inputStream = Files.newInputStream(Paths.get(location)); //NOSONAR
} }
} }
} catch (IOException e) {
} catch (IOException ignored) {
} }
if (inputStream == null) { if (inputStream == null) {
return super.resolveEntity(publicId, systemId); return super.resolveEntity(publicId, systemId);


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

@@ -114,7 +114,7 @@ public class IPlanetEjbcTask extends Task {
* @param iasdescriptor The name and location of the iAS-specific EJB * @param iasdescriptor The name and location of the iAS-specific EJB
* descriptor. * descriptor.
*/ */
public void setIasdescriptor (File iasdescriptor) {
public void setIasdescriptor(File iasdescriptor) {
this.iasdescriptor = iasdescriptor; this.iasdescriptor = iasdescriptor;
} }




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

@@ -590,7 +590,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
log("Cannot find GenIC class in classpath.", Project.MSG_ERR); log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
throw new BuildException("GenIC class not found, please check the classpath."); throw new BuildException("GenIC class not found, please check the classpath.");
} }
log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);
log("Using '" + genicClass + "' GenIC class.", Project.MSG_VERBOSE);
genicTask.setClassname(genicClass); genicTask.setClassname(genicClass);


// keepgenerated // keepgenerated


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

@@ -46,7 +46,7 @@ public class OrionDeploymentTool extends GenericDeploymentTool {
* @param baseName String * @param baseName String
*/ */
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { protected void addVendorFiles(Hashtable ejbFiles, String baseName) {
String ddPrefix = (usingBaseJarName() ? "" : baseName );
String ddPrefix = usingBaseJarName() ? "" : baseName;
File orionDD = new File(getConfig().descriptorDir, ddPrefix + ORION_DD); File orionDD = new File(getConfig().descriptorDir, ddPrefix + ORION_DD);


if (orionDD.exists()) { if (orionDD.exists()) {


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

@@ -173,7 +173,7 @@ public class ExtensionAdapter extends DataType {
} }


/** /**
* Convert this adpater object into an extension object.
* Convert this adapter object into an extension object.
* *
* @return the extension object * @return the extension object
*/ */


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

@@ -236,7 +236,7 @@ public class Image extends MatchingTask {
for (String dstName : dstNames) { for (String dstName : dstNames) {
final File dstFile = new File(dstDir, dstName).getAbsoluteFile(); final File dstFile = new File(dstDir, dstName).getAbsoluteFile();


if (dstFile.exists()){
if (dstFile.exists()) {
// avoid overwriting unless necessary // avoid overwriting unless necessary
if(!overwrite if(!overwrite
&& srcFile.lastModified() <= dstFile.lastModified()) { && srcFile.lastModified() <= dstFile.lastModified()) {
@@ -249,7 +249,7 @@ public class Image extends MatchingTask {
} }


// avoid extra work while overwriting // avoid extra work while overwriting
if (!srcFile.equals(dstFile)){
if (!srcFile.equals(dstFile)) {
dstFile.delete(); dstFile.delete();
} }
} }
@@ -309,7 +309,7 @@ public class Image extends MatchingTask {
dstParent); dstParent);
} }


if ((overwrite && newFile.exists()) && (!newFile.equals(file))) {
if (overwrite && newFile.exists() && !newFile.equals(file)) {
newFile.delete(); newFile.delete();
} }


@@ -319,7 +319,7 @@ public class Image extends MatchingTask {
stream.flush(); stream.flush();
} }
} catch (IOException | RuntimeException err) { } catch (IOException | RuntimeException err) {
if (!file.equals(newFile)){
if (!file.equals(newFile)) {
newFile.delete(); newFile.delete();
} }
if (!failonerror) { if (!failonerror) {
@@ -340,7 +340,7 @@ public class Image extends MatchingTask {
validateAttributes(); validateAttributes();


try { try {
File dest = destDir != null ? destDir : srcDir;
File dest = (destDir != null) ? destDir : srcDir;


int writeCount = 0; int writeCount = 0;


@@ -361,9 +361,8 @@ public class Image extends MatchingTask {
dest, mapper); dest, mapper);
} }


if (writeCount>0){
log("Processed " + writeCount +
(writeCount == 1 ? " image." : " images."));
if (writeCount > 0) {
log("Processed " + writeCount + (writeCount == 1 ? " image." : " images."));
} }


} catch (Exception err) { } catch (Exception err) {


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

@@ -53,8 +53,8 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
/** /**
* All the valid actions that weblogic.deploy permits * * All the valid actions that weblogic.deploy permits *
*/ */
private static final String[] VALID_ACTIONS = { ACTION_DELETE,
ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE };
private static final String[] VALID_ACTIONS = {ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST,
ACTION_UNDEPLOY, ACTION_UPDATE};


/** /**
* Description of the Field * Description of the Field


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

@@ -326,7 +326,7 @@ public class JDependTask extends Task {
* @see EnumeratedAttribute * @see EnumeratedAttribute
*/ */
public static class FormatAttribute extends EnumeratedAttribute { public static class FormatAttribute extends EnumeratedAttribute {
private String[] formats = new String[] { "xml", "text" };
private String[] formats = new String[] {"xml", "text"};


/** /**
* @return the enumerated values * @return the enumerated values
@@ -633,9 +633,7 @@ public class JDependTask extends Task {
return result; return result;
} }
result = Optional.ofNullable(getSourcespath()); result = Optional.ofNullable(getSourcespath());
if (result.isPresent()) {
log("nested sourcespath is deprecated; please use classespath");
}
result.ifPresent(resources -> log("nested sourcespath is deprecated; please use classespath"));
return result; return result;
} }




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

@@ -456,7 +456,7 @@ public class JspC extends MatchingTask {
throw new BuildException("srcdir attribute must be set!", throw new BuildException("srcdir attribute must be set!",
getLocation()); getLocation());
} }
String [] list = src.list();
String[] list = src.list();
if (list.length == 0) { if (list.length == 0) {
throw new BuildException("srcdir attribute must be set!", throw new BuildException("srcdir attribute must be set!",
getLocation()); getLocation());


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

@@ -68,7 +68,7 @@ public class JspNameMangler implements JspMangler {
* map from a jsp file to a base name; does not deal with extensions * map from a jsp file to a base name; does not deal with extensions
* *
* @param jspFile jspFile file * @param jspFile jspFile file
* @return exensionless potentially remapped name
* @return extensionless potentially remapped name
*/ */
private String mapJspToBaseName(File jspFile) { private String mapJspToBaseName(File jspFile) {
String className = stripExtension(jspFile); String className = stripExtension(jspFile);


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

@@ -225,7 +225,7 @@ public class WLJspc extends MatchingTask {
* Set the directory containing the source jsp's * Set the directory containing the source jsp's
* *
* *
* @param dirName the directory containg the source jsp's
* @param dirName the directory containing the source jsp's
*/ */
public void setSrc(File dirName) { public void setSrc(File dirName) {
sourceDirectory = dirName; sourceDirectory = dirName;
@@ -235,7 +235,7 @@ public class WLJspc extends MatchingTask {
* Set the directory containing the source jsp's * Set the directory containing the source jsp's
* *
* *
* @param dirName the directory containg the source jsp's
* @param dirName the directory containing the source jsp's
*/ */
public void setDest(File dirName) { public void setDest(File dirName) {
destinationDirectory = dirName; destinationDirectory = dirName;


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

@@ -126,7 +126,7 @@ public class AggregateTransformer {
/** /**
* Used to ensure the uniqueness of a property * Used to ensure the uniqueness of a property
*/ */
private volatile static int counter = 0;
private static volatile int counter = 0;


/** the format to use for the report. Must be <tt>FRAMES</tt> or <tt>NOFRAMES</tt> */ /** the format to use for the report. Must be <tt>FRAMES</tt> or <tt>NOFRAMES</tt> */
protected String format = FRAMES; protected String format = FRAMES;


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

@@ -41,7 +41,8 @@ public abstract class BaseTest {
protected String errorProperty; protected String errorProperty;
// CheckStyle:VisibilityModifier ON // CheckStyle:VisibilityModifier ON


private Object ifCond, unlessCond;
private Object ifCond;
private Object unlessCond;
private boolean skipNonTests; private boolean skipNonTests;


/** /**


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

@@ -39,8 +39,8 @@ public class Constants {
static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents="; static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents=";
static final String TESTSFILE = "testsfile="; static final String TESTSFILE = "testsfile=";
static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; static final String TERMINATED_SUCCESSFULLY = "terminated successfully";
static final String LOG_FAILED_TESTS="logfailedtests=";
static final String LOG_FAILED_TESTS = "logfailedtests=";
static final String SKIP_NON_TESTS = "skipNonTests="; static final String SKIP_NON_TESTS = "skipNonTests=";
/** @since Ant 1.9.4 */ /** @since Ant 1.9.4 */
static final String THREADID="threadid=";
static final String THREADID = "threadid=";
} }

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

@@ -137,7 +137,7 @@ public final class DOMUtil {
* the parent is <tt>null</tt> or if a child does not match the * the parent is <tt>null</tt> or if a child does not match the
* given name. * given name.
*/ */
public static Element getChildByTagName (Node parent, String tagname) {
public static Element getChildByTagName(Node parent, String tagname) {
if (parent == null) { if (parent == null) {
return null; return null;
} }


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

@@ -53,8 +53,8 @@ import org.apache.tools.ant.util.StringUtils;
* } * }
* public static Test suite() { * public static Test suite() {
* TestSuite suite = new TestSuite(); * TestSuite suite = new TestSuite();
* suite.addTest( new B("test04") );
* suite.addTest( new org.D("test10") );
* suite.addTest(new B("test04"));
* suite.addTest(new org.D("test10"));
* return suite; * return suite;
* } * }
* } * }


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

@@ -359,7 +359,7 @@ public class FormatterElement {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "plain", "xml", "brief", "failure" };
return new String[] {"plain", "xml", "brief", "failure"};
} }
} }




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

@@ -44,7 +44,7 @@ public class IgnoredTestResult extends TestResult {
@Override @Override
public synchronized void addListener(TestListener listener) { public synchronized void addListener(TestListener listener) {
if (listener instanceof IgnoredTestListener) { if (listener instanceof IgnoredTestListener) {
listeners.add((IgnoredTestListener)listener);
listeners.add((IgnoredTestListener) listener);
} }
super.addListener(listener); super.addListener(listener);
} }


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

@@ -371,8 +371,7 @@ public class JUnitTask extends Task {
*/ */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { "true", "yes", "false", "no", "on", "off",
"withOutAndErr" };
return new String[] {"true", "yes", "false", "no", "on", "off", "withOutAndErr"};
} }


/** /**
@@ -820,16 +819,13 @@ public class JUnitTask extends Task {
mirrorLoader = AccessController.doPrivileged( mirrorLoader = AccessController.doPrivileged(
(PrivilegedAction<ClassLoader>) () -> new SplitClassLoader( (PrivilegedAction<ClassLoader>) () -> new SplitClassLoader(
myLoader, path, getProject(), myLoader, path, getProject(),
new String[] { "BriefJUnitResultFormatter",
"JUnit4TestMethodAdapter", "JUnitResultFormatter",
"JUnitTaskMirrorImpl", "JUnitTestRunner",
"JUnitVersionHelper",
"OutErrSummaryJUnitResultFormatter",
"PlainJUnitResultFormatter",
"SummaryJUnitResultFormatter", "TearDownOnVmCrash",
"XMLJUnitResultFormatter", "IgnoredTestListener",
"IgnoredTestResult", "CustomJUnit4TestAdapterCache",
"TestListenerWrapper" }));
new String[] {"BriefJUnitResultFormatter", "JUnit4TestMethodAdapter",
"JUnitResultFormatter", "JUnitTaskMirrorImpl", "JUnitTestRunner",
"JUnitVersionHelper", "OutErrSummaryJUnitResultFormatter",
"PlainJUnitResultFormatter", "SummaryJUnitResultFormatter",
"TearDownOnVmCrash", "XMLJUnitResultFormatter", "IgnoredTestListener",
"IgnoredTestResult", "CustomJUnit4TestAdapterCache",
"TestListenerWrapper"}));
} else { } else {
mirrorLoader = myLoader; mirrorLoader = myLoader;
} }
@@ -850,9 +846,7 @@ public class JUnitTask extends Task {


final List<List<JUnitTest>> testLists = new ArrayList<>(); final List<List<JUnitTest>> testLists = new ArrayList<>();
/* parallel test execution is only supported for multi-process execution */ /* parallel test execution is only supported for multi-process execution */
final int threads = ((!fork) || (forkMode.getValue().equals(ForkMode.ONCE))
? 1
: this.threads);
final int threads = !fork || forkMode.getValue().equals(ForkMode.ONCE) ? 1 : this.threads;


final boolean forkPerTest = ForkMode.PER_TEST.equals(forkMode.getValue()); final boolean forkPerTest = ForkMode.PER_TEST.equals(forkMode.getValue());
if (forkPerTest || ForkMode.ONCE.equals(forkMode.getValue())) { if (forkPerTest || ForkMode.ONCE.equals(forkMode.getValue())) {
@@ -991,7 +985,7 @@ public class JUnitTask extends Task {


/* create 1 thread using the passthrough class, and let each thread start */ /* create 1 thread using the passthrough class, and let each thread start */
for (i = 0; i < numThreads; i++) { for (i = 0; i < numThreads; i++) {
threads[i] = new Thread(new JunitTestThread(this, iter, i+1));
threads[i] = new Thread(new JunitTestThread(this, iter, i + 1));
threads[i].start(); threads[i].start();
} }


@@ -2166,7 +2160,7 @@ public class JUnitTask extends Task {
/** {@inheritDoc}. */ /** {@inheritDoc}. */
@Override @Override
public String[] getValues() { public String[] getValues() {
return new String[] { ONCE, PER_TEST, PER_BATCH };
return new String[] {ONCE, PER_TEST, PER_BATCH};
} }
} }




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

@@ -77,7 +77,7 @@ public interface JUnitTaskMirror {




/** The interface that JUnitResultFormatter extends. */ /** The interface that JUnitResultFormatter extends. */
public interface JUnitResultFormatterMirror {
interface JUnitResultFormatterMirror {
/** /**
* Set the output stream. * Set the output stream.
* @param outputStream the stream to use. * @param outputStream the stream to use.
@@ -86,7 +86,7 @@ public interface JUnitTaskMirror {
} }


/** The interface that SummaryJUnitResultFormatter extends. */ /** The interface that SummaryJUnitResultFormatter extends. */
public interface SummaryJUnitResultFormatterMirror
interface SummaryJUnitResultFormatterMirror
extends JUnitResultFormatterMirror { extends JUnitResultFormatterMirror {


/** /**
@@ -97,7 +97,7 @@ public interface JUnitTaskMirror {
} }


/** Interface that test runners implement. */ /** Interface that test runners implement. */
public interface JUnitTestRunnerMirror {
interface JUnitTestRunnerMirror {


/** /**
* Used in formatter arguments as a placeholder for the basename * Used in formatter arguments as a placeholder for the basename


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

@@ -481,7 +481,7 @@ public class JUnitTest extends BaseTest implements Cloneable {
* @param p the properties. * @param p the properties.
* This is a copy of the projects ant properties. * This is a copy of the projects ant properties.
*/ */
public void setProperties(Hashtable<?,?> p) {
public void setProperties(Hashtable<?, ?> p) {
props = new Properties(); props = new Properties();
p.forEach(props::put); p.forEach(props::put);
} }


+ 49
- 69
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -73,11 +74,9 @@ import org.apache.tools.ant.util.TeeOutputStream;
*/ */


public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestRunnerMirror { public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestRunnerMirror {
private static final String JUNIT_4_TEST_ADAPTER
= "junit.framework.JUnit4TestAdapter";
private static final String JUNIT_4_TEST_ADAPTER = "junit.framework.JUnit4TestAdapter";


private static final String[] DEFAULT_TRACE_FILTERS = new String[] {
"junit.framework.TestCase",
private static final String[] DEFAULT_TRACE_FILTERS = new String[] {"junit.framework.TestCase",
"junit.framework.TestResult", "junit.framework.TestResult",
"junit.framework.TestSuite", "junit.framework.TestSuite",
"junit.framework.Assert.", // don't filter AssertionFailure "junit.framework.Assert.", // don't filter AssertionFailure
@@ -90,8 +89,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
// JUnit 4 support: // JUnit 4 support:
"org.junit.", "org.junit.",
"junit.framework.JUnit4TestAdapter", "junit.framework.JUnit4TestAdapter",
" more",
};
" more"};


/** /**
* Do we filter junit.*.* stack frames out of failure and error exceptions. * Do we filter junit.*.* stack frames out of failure and error exceptions.
@@ -446,8 +444,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
junit4TestAdapterCacheClass = Class.forName( junit4TestAdapterCacheClass = Class.forName(
"org.apache.tools.ant.taskdefs.optional.junit.CustomJUnit4TestAdapterCache"); "org.apache.tools.ant.taskdefs.optional.junit.CustomJUnit4TestAdapterCache");
if (loader == null) { if (loader == null) {
junit4TestAdapterClass =
Class.forName(JUNIT_4_TEST_ADAPTER);
junit4TestAdapterClass = Class.forName(JUNIT_4_TEST_ADAPTER);
if (testMethodsSpecified) { if (testMethodsSpecified) {
/* /*
* We cannot try to load the JUnit4TestAdapter * We cannot try to load the JUnit4TestAdapter
@@ -465,8 +462,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
Class.forName(JUNIT_4_TEST_ADAPTER, Class.forName(JUNIT_4_TEST_ADAPTER,
true, loader); true, loader);
if (testMethodsSpecified) { if (testMethodsSpecified) {
junit4TestAdapterClass =
Class.forName(
junit4TestAdapterClass = Class.forName(
"org.apache.tools.ant.taskdefs.optional.junit.JUnit4TestMethodAdapter", "org.apache.tools.ant.taskdefs.optional.junit.JUnit4TestMethodAdapter",
true, loader); true, loader);
useSingleMethodAdapter = true; useSingleMethodAdapter = true;
@@ -488,22 +484,16 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
Class<?>[] formalParams; Class<?>[] formalParams;
Object[] actualParams; Object[] actualParams;
if (useSingleMethodAdapter) { if (useSingleMethodAdapter) {
formalParams =
new Class[] { Class.class, String[].class };
actualParams = new Object[] { testClass, methods };
formalParams = new Class[] {Class.class, String[].class};
actualParams = new Object[] {testClass, methods};
} else { } else {
formalParams =
new Class[] { Class.class, Class.forName(
"junit.framework.JUnit4TestAdapterCache") };
actualParams =
new Object[] { testClass,
junit4TestAdapterCacheClass
.getMethod("getInstance")
.invoke(null) };
formalParams = new Class[] {Class.class, Class.forName(
"junit.framework.JUnit4TestAdapterCache")};
actualParams = new Object[] {testClass, junit4TestAdapterCacheClass
.getMethod("getInstance").invoke(null)};
} }
suite = junit4TestAdapterClass.asSubclass(Test.class) suite = junit4TestAdapterClass.asSubclass(Test.class)
.getConstructor(formalParams)
.newInstance(actualParams);
.getConstructor(formalParams).newInstance(actualParams);
} else { } else {
// Use JUnit 3. // Use JUnit 3.


@@ -536,8 +526,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
if (exception != null) { // had an exception constructing suite if (exception != null) { // had an exception constructing suite
final int formatterSize = formatters.size(); final int formatterSize = formatters.size();
for (int i = 0; i < formatterSize; i++) { for (int i = 0; i < formatterSize; i++) {
((TestListener) formatters.elementAt(i))
.addError(null, exception);
((TestListener) formatters.elementAt(i)).addError(null, exception);
} }
junitTest.setCounts(1, 0, 1, 0); junitTest.setCounts(1, 0, 1, 0);
junitTest.setRunTime(0); junitTest.setRunTime(0);
@@ -546,10 +535,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
logTestListenerEvent("tests to run: " + suite.countTestCases()); logTestListenerEvent("tests to run: " + suite.countTestCases());
suite.run(res); suite.run(res);
} finally { } finally {
if (junit4 ||
suite.getClass().getName().equals(JUNIT_4_TEST_ADAPTER)) {
if (junit4 || suite.getClass().getName().equals(JUNIT_4_TEST_ADAPTER)) {
final int[] cnts = findJUnit4FailureErrorCount(res); final int[] cnts = findJUnit4FailureErrorCount(res);
junitTest.setCounts(res.runCount() + res.ignoredCount(), cnts[0], cnts[1], res.ignoredCount() + res.skippedCount());
junitTest.setCounts(res.runCount() + res.ignoredCount(), cnts[0], cnts[1],
res.ignoredCount() + res.skippedCount());
} else { } else {
junitTest.setCounts(res.runCount() + res.ignoredCount(), res.failureCount(), junitTest.setCounts(res.runCount() + res.ignoredCount(), res.failureCount(),
res.errorCount(), res.ignoredCount() + res.skippedCount()); res.errorCount(), res.ignoredCount() + res.skippedCount());
@@ -616,13 +605,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
try { try {
suiteAnnotation = Class.forName("org.junit.Suite.SuiteClasses") suiteAnnotation = Class.forName("org.junit.Suite.SuiteClasses")
.asSubclass(Annotation.class); .asSubclass(Annotation.class);
} catch(final ClassNotFoundException ex) {
} catch (final ClassNotFoundException ex) {
// ignore - we don't have this annotation so make sure we don't check for it // ignore - we don't have this annotation so make sure we don't check for it
} }
try { try {
runWithAnnotation = Class.forName("org.junit.runner.RunWith") runWithAnnotation = Class.forName("org.junit.runner.RunWith")
.asSubclass(Annotation.class); .asSubclass(Annotation.class);
} catch(final ClassNotFoundException ex) {
} catch (final ClassNotFoundException ex) {
// also ignore as this annotation doesn't exist so tests can't use it // also ignore as this annotation doesn't exist so tests can't use it
} }


@@ -633,32 +622,30 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR


// check if we have any inner classes that contain suitable test methods // check if we have any inner classes that contain suitable test methods
for (final Class<?> innerClass : testClass.getDeclaredClasses()) { for (final Class<?> innerClass : testClass.getDeclaredClasses()) {
if (containsTests(innerClass, isJUnit4)
|| containsTests(innerClass, !isJUnit4)) {
if (containsTests(innerClass, isJUnit4) || containsTests(innerClass, !isJUnit4)) {
return true; return true;
} }
} }


if (Modifier.isAbstract(testClass.getModifiers()) if (Modifier.isAbstract(testClass.getModifiers())
|| Modifier.isInterface(testClass.getModifiers())) {
|| Modifier.isInterface(testClass.getModifiers())) {
// can't instantiate class and no inner classes are tests either // can't instantiate class and no inner classes are tests either
return false; return false;
} }


if (isJUnit4) { if (isJUnit4) {
if (suiteAnnotation != null
&& testClass.getAnnotation(suiteAnnotation) != null) {
if (suiteAnnotation != null && testClass.getAnnotation(suiteAnnotation) != null) {
// class is marked as a suite. Let JUnit try and work its magic on it. // class is marked as a suite. Let JUnit try and work its magic on it.
return true; return true;
} }
if (runWithAnnotation != null
&& testClass.getAnnotation(runWithAnnotation) != null) {
/* Class is marked with @RunWith. If this class is badly written (no test methods, multiple
* constructors, private constructor etc) then the class is automatically run and fails in the
* IDEs I've tried... so I'm happy handing the class to JUnit to try and run, and let JUnit
* report a failure if a bad test case is provided. Trying to do anything else is likely to
* result in us filtering out cases that could be valid for future versions of JUnit so would
* just increase future maintenance work.
if (runWithAnnotation != null && testClass.getAnnotation(runWithAnnotation) != null) {
/* Class is marked with @RunWith. If this class is badly written (no test methods,
* multiple constructors, private constructor etc) then the class is automatically
* run and fails in the IDEs I've tried... so I'm happy handing the class to JUnit
* to try and run, and let JUnit report a failure if a bad test case is provided.
* Trying to do anything else is likely to result in us filtering out cases that
* could be valid for future versions of JUnit so would just increase future
* maintenance work.
*/ */
return true; return true;
} }
@@ -671,7 +658,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
return true; return true;
} }
} else { } else {
// check if JUnit3 class have public or protected no-args methods starting with names starting with test
// check if JUnit3 class have public or protected no-args methods starting with
// names starting with test
if (m.getName().startsWith("test") if (m.getName().startsWith("test")
&& m.getParameterTypes().length == 0 && m.getParameterTypes().length == 0
&& (Modifier.isProtected(m.getModifiers()) && (Modifier.isProtected(m.getModifiers())
@@ -729,13 +717,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR


private void logTestListenerEvent(String msg) { private void logTestListenerEvent(String msg) {
if (logTestListenerEvents) { if (logTestListenerEvents) {
@SuppressWarnings("resource")
final PrintStream out = savedOut != null ? savedOut : System.out; final PrintStream out = savedOut != null ? savedOut : System.out;
out.flush(); out.flush();
final StringTokenizer msgLines = final StringTokenizer msgLines =
new StringTokenizer(String.valueOf(msg), "\r\n", false); new StringTokenizer(String.valueOf(msg), "\r\n", false);
while (msgLines.hasMoreTokens()) { while (msgLines.hasMoreTokens()) {
out.println(JUnitTask.TESTLISTENER_PREFIX
+ msgLines.nextToken());
out.println(JUnitTask.TESTLISTENER_PREFIX + msgLines.nextToken());
} }
out.flush(); out.flush();
} }
@@ -862,16 +850,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
private void fireStartTestSuite() { private void fireStartTestSuite() {
final int size = formatters.size(); final int size = formatters.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
((JUnitResultFormatter) formatters.elementAt(i))
.startTestSuite(junitTest);
((JUnitResultFormatter) formatters.elementAt(i)).startTestSuite(junitTest);
} }
} }


private void fireEndTestSuite() { private void fireEndTestSuite() {
final int size = formatters.size(); final int size = formatters.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
((JUnitResultFormatter) formatters.elementAt(i))
.endTestSuite(junitTest);
((JUnitResultFormatter) formatters.elementAt(i)).endTestSuite(junitTest);
} }
} }


@@ -938,7 +924,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
boolean logFailedTests = true; boolean logFailedTests = true;
boolean logTestListenerEvents = false; boolean logTestListenerEvents = false;
boolean skipNonTests = false; boolean skipNonTests = false;
int antThreadID = 0; /* Ant id of thread running this unit test, 0 in single-threaded mode */
/* Ant id of thread running this unit test, 0 in single-threaded mode */
int antThreadID = 0;


if (args.length == 0) { if (args.length == 0) {
System.err.println("required argument TestClassName missing"); System.err.println("required argument TestClassName missing");
@@ -977,7 +964,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
} }
} else if (args[i].startsWith(Constants.PROPSFILE)) { } else if (args[i].startsWith(Constants.PROPSFILE)) {
final InputStream in = Files.newInputStream(Paths.get(args[i] final InputStream in = Files.newInputStream(Paths.get(args[i]
.substring(Constants.PROPSFILE.length())));
.substring(Constants.PROPSFILE.length())));
props.load(in); props.load(in);
in.close(); in.close();
} else if (args[i].startsWith(Constants.SHOWOUTPUT)) { } else if (args[i].startsWith(Constants.SHOWOUTPUT)) {
@@ -1004,9 +991,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR


int returnCode = SUCCESS; int returnCode = SUCCESS;
if (multipleTests) { if (multipleTests) {
try (
final BufferedReader reader =
new BufferedReader(new java.io.FileReader(args[0]))){
try (final BufferedReader reader = new BufferedReader(new FileReader(args[0]))) {
int code = 0; int code = 0;
boolean errorOccurred = false; boolean errorOccurred = false;
boolean failureOccurred = false; boolean failureOccurred = false;
@@ -1039,8 +1024,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
errorOccurred = (code == ERRORS); errorOccurred = (code == ERRORS);
failureOccurred = (code != SUCCESS); failureOccurred = (code != SUCCESS);
if (errorOccurred || failureOccurred) { if (errorOccurred || failureOccurred) {
if ((errorOccurred && haltError)
|| (failureOccurred && haltFail)) {
if ((errorOccurred && haltError) || (failureOccurred && haltFail)) {
registerNonCrash(); registerNonCrash();
System.exit(code); System.exit(code);
} else { } else {
@@ -1048,8 +1032,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
returnCode = code; returnCode = code;
} }
if (logFailedTests) { if (logFailedTests) {
System.out.println("TEST " + t.getName()
+ " FAILED");
System.out.println("TEST " + t.getName() + " FAILED");
} }
} }
} }
@@ -1062,9 +1045,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
t.setThread(antThreadID); t.setThread(antThreadID);
t.setProperties(props); t.setProperties(props);
t.setSkipNonTests(skipNonTests); t.setSkipNonTests(skipNonTests);
returnCode = launch(
t, methods, haltError, stackfilter, haltFail,
showOut, outputToFormat, logTestListenerEvents);
returnCode = launch(t, methods, haltError, stackfilter, haltFail, showOut,
outputToFormat, logTestListenerEvents);
} }


registerNonCrash(); registerNonCrash();
@@ -1118,9 +1100,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
final FormatterElement fe = fromCmdLine.elementAt(i); final FormatterElement fe = fromCmdLine.elementAt(i);
if (multipleTests && fe.getUseFile()) { if (multipleTests && fe.getUseFile()) {
final File destFile =
new File(test.getTodir(),
test.getOutfile() + fe.getExtension());
final File destFile = new File(test.getTodir(),
test.getOutfile() + fe.getExtension());
fe.setOutfile(destFile); fe.setOutfile(destFile);
} }
runner.addFormatter((JUnitResultFormatter) fe.createFormatter()); runner.addFormatter((JUnitResultFormatter) fe.createFormatter());
@@ -1147,9 +1128,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
} else { } else {
final int fName = line.indexOf(IGNORED_FILE_NAME); final int fName = line.indexOf(IGNORED_FILE_NAME);
if (fName > -1) { if (fName > -1) {
fe.setExtension(line
.substring(fName
+ IGNORED_FILE_NAME.length()));
fe.setExtension(line.substring(fName
+ IGNORED_FILE_NAME.length()));
} }
} }
} }
@@ -1340,7 +1320,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
errors++; errors++;
} }
} }
return new int[] { failures, errors };
return new int[] {failures, errors};
} }


} }

+ 19
- 14
src/main/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrash.java View File

@@ -45,8 +45,7 @@ public class TearDownOnVmCrash implements JUnitResultFormatter {
@Override @Override
public void startTestSuite(final JUnitTest suite) { public void startTestSuite(final JUnitTest suite) {
suiteName = suite.getName(); suiteName = suite.getName();
if (suiteName != null &&
suiteName.endsWith(JUnitTask.NAME_OF_DUMMY_TEST)) {
if (suiteName != null && suiteName.endsWith(JUnitTask.NAME_OF_DUMMY_TEST)) {
// no way to know which class caused the timeout // no way to know which class caused the timeout
suiteName = null; suiteName = null;
} }
@@ -59,35 +58,42 @@ public class TearDownOnVmCrash implements JUnitResultFormatter {
*/ */
@Override @Override
public void addError(final Test fakeTest, final Throwable t) { public void addError(final Test fakeTest, final Throwable t) {
if (suiteName != null
&& fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) {
if (suiteName != null && fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) {
tearDown(); tearDown();
} }
} }


// no need to implement the rest // no need to implement the rest
public void addFailure(Test test, Throwable t) {}
public void addFailure(Test test, Throwable t) {
}


@Override @Override
public void addFailure(Test test, AssertionFailedError t) {}
public void addFailure(Test test, AssertionFailedError t) {
}


@Override @Override
public void startTest(Test test) {}
public void startTest(Test test) {
}


@Override @Override
public void endTest(Test test) {}
public void endTest(Test test) {
}


@Override @Override
public void endTestSuite(JUnitTest suite) {}
public void endTestSuite(JUnitTest suite) {
}


@Override @Override
public void setOutput(OutputStream out) {}
public void setOutput(OutputStream out) {
}


@Override @Override
public void setSystemOutput(String out) {}
public void setSystemOutput(String out) {
}


@Override @Override
public void setSystemError(String err) {}
public void setSystemError(String err) {
}


private void tearDown() { private void tearDown() {
try { try {
@@ -104,8 +110,7 @@ public class TearDownOnVmCrash implements JUnitResultFormatter {
} }
if (testClass == null && getClass().getClassLoader() != null) { if (testClass == null && getClass().getClassLoader() != null) {
try { try {
testClass =
getClass().getClassLoader().loadClass(suiteName);
testClass = getClass().getClassLoader().loadClass(suiteName);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
// ignore // ignore
} }


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

@@ -27,8 +27,8 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.Writer; import java.io.Writer;
import java.util.function.UnaryOperator;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.function.UnaryOperator;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.optional.Native2Ascii; import org.apache.tools.ant.taskdefs.optional.Native2Ascii;


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

@@ -424,7 +424,7 @@ public class FTP extends Task implements FTPTaskConfig {
} else { } else {
// only scan directories that can include matched files or // only scan directories that can include matched files or
// directories // directories
newroots.forEach((k,v) -> scanRoots(baseFTPFile, k, v));
newroots.forEach((k, v) -> scanRoots(baseFTPFile, k, v));
} }
} }


@@ -448,7 +448,7 @@ public class FTP extends Task implements FTPTaskConfig {
try { try {
path = myfile.getRelativePath(); path = myfile.getRelativePath();
traversesSymlinks = myfile.isTraverseSymlinks(); traversesSymlinks = myfile.isTraverseSymlinks();
} catch (IOException be) {
} catch (IOException be) {
throw new BuildException(be, getLocation()); throw new BuildException(be, getLocation());
} catch (BuildException be) { } catch (BuildException be) {
isOK = false; isOK = false;
@@ -1827,25 +1827,25 @@ public class FTP extends Task implements FTPTaskConfig {
final String dsfile = dsfiles[i]; final String dsfile = dsfiles[i];
executeRetryable(h, () -> { executeRetryable(h, () -> {
switch (action) { switch (action) {
case SEND_FILES:
sendFile(ftp, fdir, dsfile);
break;
case GET_FILES:
getFile(ftp, fdir, dsfile);
break;
case DEL_FILES:
delFile(ftp, dsfile);
break;
case LIST_FILES:
listFile(ftp, fbw, dsfile);
break;
case CHMOD:
doSiteCommand(ftp, "chmod " + chmod
+ " " + resolveFile(dsfile));
transferred++;
break;
default:
throw new BuildException("unknown ftp action " + action);
case SEND_FILES:
sendFile(ftp, fdir, dsfile);
break;
case GET_FILES:
getFile(ftp, fdir, dsfile);
break;
case DEL_FILES:
delFile(ftp, dsfile);
break;
case LIST_FILES:
listFile(ftp, fbw, dsfile);
break;
case CHMOD:
doSiteCommand(ftp, "chmod " + chmod
+ " " + resolveFile(dsfile));
transferred++;
break;
default:
throw new BuildException("unknown ftp action " + action);
} }
}, dsfile); }, dsfile);
} }


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

@@ -339,7 +339,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
try { try {
path = myfile.getRelativePath(); path = myfile.getRelativePath();
traversesSymlinks = myfile.isTraverseSymlinks(); traversesSymlinks = myfile.isTraverseSymlinks();
} catch (IOException be) {
} catch (IOException be) {
throw new BuildException(be, task.getLocation()); throw new BuildException(be, task.getLocation());
} catch (BuildException be) { } catch (BuildException be) {
isOK = false; isOK = false;
@@ -1200,26 +1200,26 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
final String dsfile = dsfiles[i]; final String dsfile = dsfiles[i];
executeRetryable(h, () -> { executeRetryable(h, () -> {
switch (task.getAction()) { switch (task.getAction()) {
case FTPTask.SEND_FILES:
sendFile(ftp, fdir, dsfile);
break;
case FTPTask.GET_FILES:
getFile(ftp, fdir, dsfile);
break;
case FTPTask.DEL_FILES:
delFile(ftp, dsfile);
break;
case FTPTask.LIST_FILES:
listFile(ftp, fbw, dsfile);
break;
case FTPTask.CHMOD:
doSiteCommand(ftp, "chmod " + task.getChmod() + " "
+ resolveFile(dsfile));
transferred++;
break;
default:
throw new BuildException("unknown ftp action %s",
task.getAction());
case FTPTask.SEND_FILES:
sendFile(ftp, fdir, dsfile);
break;
case FTPTask.GET_FILES:
getFile(ftp, fdir, dsfile);
break;
case FTPTask.DEL_FILES:
delFile(ftp, dsfile);
break;
case FTPTask.LIST_FILES:
listFile(ftp, fbw, dsfile);
break;
case FTPTask.CHMOD:
doSiteCommand(ftp, "chmod " + task.getChmod() + " "
+ resolveFile(dsfile));
transferred++;
break;
default:
throw new BuildException("unknown ftp action %s",
task.getAction());
} }
}, dsfile); }, dsfile);
} }
@@ -1461,20 +1461,20 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
+ task.getGranularityMillis(); + task.getGranularityMillis();


StringBuilder msg; StringBuilder msg;
synchronized(TIMESTAMP_LOGGING_SDF) {
synchronized (TIMESTAMP_LOGGING_SDF) {
msg = new StringBuilder(" [") msg = new StringBuilder(" [")
.append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp))) .append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp)))
.append("] local"); .append("] local");
} }
task.log(msg.toString(), Project.MSG_VERBOSE); task.log(msg.toString(), Project.MSG_VERBOSE);


synchronized(TIMESTAMP_LOGGING_SDF) {
synchronized (TIMESTAMP_LOGGING_SDF) {
msg = new StringBuilder(" [") msg = new StringBuilder(" [")
.append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp))) .append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp)))
.append("] remote"); .append("] remote");
} }
if (remoteTimestamp != adjustedRemoteTimestamp) { if (remoteTimestamp != adjustedRemoteTimestamp) {
synchronized(TIMESTAMP_LOGGING_SDF) {
synchronized (TIMESTAMP_LOGGING_SDF) {
msg.append(" - (raw: ") msg.append(" - (raw: ")
.append(TIMESTAMP_LOGGING_SDF.format(new Date(remoteTimestamp))) .append(TIMESTAMP_LOGGING_SDF.format(new Date(remoteTimestamp)))
.append(")"); .append(")");


+ 10
- 15
src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java View File

@@ -200,8 +200,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
for (PvcsProject pvcsProject : getPvcsprojects()) { for (PvcsProject pvcsProject : getPvcsprojects()) {
String projectName = pvcsProject.getName(); String projectName = pvcsProject.getName();
if (projectName == null || projectName.trim().isEmpty()) { if (projectName == null || projectName.trim().isEmpty()) {
throw new BuildException(
"name is a required attribute of pvcsproject");
throw new BuildException("name is a required attribute of pvcsproject");
} }
commandLine.createArgument().setValue(projectName); commandLine.createArgument().setValue(projectName);
} }
@@ -216,10 +215,8 @@ public class Pvcs extends org.apache.tools.ant.Task {
tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log");
log(commandLine.describeCommand(), Project.MSG_VERBOSE); log(commandLine.describeCommand(), Project.MSG_VERBOSE);
try { try {
result = runCmd(commandLine,
new PumpStreamHandler(fos,
new LogOutputStream(this,
Project.MSG_WARN)));
result = runCmd(commandLine, new PumpStreamHandler(fos,
new LogOutputStream(this, Project.MSG_WARN)));
} finally { } finally {
FileUtils.close(fos); FileUtils.close(fos);
} }
@@ -264,8 +261,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
commandLine.createArgument().setValue("-v" + getLabel()); commandLine.createArgument().setValue("-v" + getLabel());
} else { } else {
if (getRevision() != null) { if (getRevision() != null) {
commandLine.createArgument().setValue("-r"
+ getRevision());
commandLine.createArgument().setValue("-r" + getRevision());
} }
} }
} }
@@ -316,10 +312,10 @@ public class Pvcs extends org.apache.tools.ant.Task {
String line = in.readLine(); String line = in.readLine();
while (line != null) { while (line != null) {
log("Considering \"" + line + "\"", Project.MSG_VERBOSE); log("Considering \"" + line + "\"", Project.MSG_VERBOSE);
if (line.startsWith("\"\\") // Checking for "\
|| line.startsWith("\"/") // or "/
// or "X:\...
|| (line.length() > POS_3 && line.startsWith("\"")
if (line.startsWith("\"\\") // Checking for "\
|| line.startsWith("\"/") // or "/
// or "X:\...
|| (line.length() > POS_3 && line.startsWith("\"")
&& Character.isLetter(line.charAt(POS_1)) && Character.isLetter(line.charAt(POS_1))
&& String.valueOf(line.charAt(POS_2)).equals(":") && String.valueOf(line.charAt(POS_2)).equals(":")
&& String.valueOf(line.charAt(POS_3)).equals("\\"))) { && String.valueOf(line.charAt(POS_3)).equals("\\"))) {
@@ -365,10 +361,9 @@ public class Pvcs extends org.apache.tools.ant.Task {
private void massagePCLI(File in, File out) private void massagePCLI(File in, File out)
throws IOException { throws IOException {
try (BufferedReader inReader = new BufferedReader(new FileReader(in)); try (BufferedReader inReader = new BufferedReader(new FileReader(in));
BufferedWriter outWriter =
new BufferedWriter(new FileWriter(out))) {
BufferedWriter outWriter = new BufferedWriter(new FileWriter(out))) {
for (String line : (Iterable<String>) () -> inReader.lines() for (String line : (Iterable<String>) () -> inReader.lines()
.map(s -> s.replace('\\', '/')).iterator()) {
.map(s -> s.replace('\\', '/')).iterator()) {
outWriter.write(line); outWriter.write(line);
outWriter.newLine(); outWriter.newLine();
} }


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

@@ -49,7 +49,7 @@ public class Directory {
* @param directory a directory * @param directory a directory
* @param parent a parent Directory * @param parent a parent Directory
*/ */
public Directory(File directory , Directory parent) {
public Directory(File directory, Directory parent) {
this.parent = parent; this.parent = parent;
this.childDirectories = new LinkedHashSet<>(); this.childDirectories = new LinkedHashSet<>();
this.files = new ArrayList<>(); this.files = new ArrayList<>();


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

@@ -423,8 +423,7 @@ public class Scp extends SSHBase {
// password. (so if the path contains an @ and a : it will not work) // password. (so if the path contains an @ and a : it will not work)
int indexOfCurrentAt = indexOfAt; int indexOfCurrentAt = indexOfAt;
final int indexOfLastColon = uri.lastIndexOf(':'); final int indexOfLastColon = uri.lastIndexOf(':');
while (indexOfCurrentAt > -1 && indexOfCurrentAt < indexOfLastColon)
{
while (indexOfCurrentAt > -1 && indexOfCurrentAt < indexOfLastColon) {
indexOfAt = indexOfCurrentAt; indexOfAt = indexOfCurrentAt;
indexOfCurrentAt = uri.indexOf('@', indexOfCurrentAt + 1); indexOfCurrentAt = uri.indexOf('@', indexOfCurrentAt + 1);
} }


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

Loading…
Cancel
Save