Browse Source

Simplify and tidy up

master
Gintas Grigelionis 7 years ago
parent
commit
28e51503e3
41 changed files with 89 additions and 147 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/AntClassLoader.java
  2. +16
    -23
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  3. +1
    -0
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  4. +4
    -6
      src/main/org/apache/tools/ant/dispatch/DispatchUtils.java
  5. +1
    -1
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  6. +2
    -1
      src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
  7. +2
    -6
      src/main/org/apache/tools/ant/taskdefs/Available.java
  8. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  9. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  10. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  11. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  12. +7
    -18
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  13. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Redirector.java
  14. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  15. +4
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  16. +2
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  17. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  18. +9
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  19. +0
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java
  20. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java
  21. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
  22. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
  23. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/SingleTestClass.java
  24. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestDefinition.java
  25. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/BuiltinNative2Ascii.java
  26. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  27. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  28. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
  29. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
  30. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java
  31. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  32. +1
    -0
      src/main/org/apache/tools/ant/types/DataType.java
  33. +1
    -2
      src/main/org/apache/tools/ant/types/Mapper.java
  34. +1
    -0
      src/main/org/apache/tools/ant/types/resources/TarResource.java
  35. +2
    -4
      src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
  36. +2
    -10
      src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
  37. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java
  38. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java
  39. +2
    -10
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java
  40. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
  41. +0
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java

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

@@ -974,7 +974,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
} else { } else {
// ClassLoader.this.parent is already delegated to for example from // ClassLoader.this.parent is already delegated to for example from
// ClassLoader.getResources, no need: // ClassLoader.getResources, no need:
base = new CollectionUtils.EmptyEnumeration<URL>();
base = Collections.emptyEnumeration();
} }
if (isParentFirst(name)) { if (isParentFirst(name)) {
// Normal case. // Normal case.


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

@@ -700,10 +700,8 @@ public final class IntrospectionHelper {
* @return true if the given nested element is supported * @return true if the given nested element is supported
*/ */
public boolean supportsNestedElement(final String parentUri, final String elementName) { public boolean supportsNestedElement(final String parentUri, final String elementName) {
if (isDynamic() || !addTypeMethods.isEmpty()) {
return true;
}
return supportsReflectElement(parentUri, elementName);
return isDynamic() || !addTypeMethods.isEmpty()
|| supportsReflectElement(parentUri, elementName);
} }


/** /**
@@ -725,11 +723,9 @@ public final class IntrospectionHelper {
*/ */
public boolean supportsNestedElement(final String parentUri, final String elementName, public boolean supportsNestedElement(final String parentUri, final String elementName,
final Project project, final Object parent) { final Project project, final Object parent) {
if (!addTypeMethods.isEmpty()
&& createAddTypeCreator(project, parent, elementName) != null) {
return true;
}
return isDynamic() || supportsReflectElement(parentUri, elementName);
return !addTypeMethods.isEmpty()
&& createAddTypeCreator(project, parent, elementName) != null
|| isDynamic() || supportsReflectElement(parentUri, elementName);
} }


/** /**
@@ -1116,7 +1112,8 @@ public final class IntrospectionHelper {
if (java.nio.file.Path.class.equals(reflectedArg)) { if (java.nio.file.Path.class.equals(reflectedArg)) {
return new AttributeSetter(m, arg) { return new AttributeSetter(m, arg) {
@Override @Override
public void set(final Project p, final Object parent, final String value) throws InvocationTargetException, IllegalAccessException {
public void set(final Project p, final Object parent, final String value)
throws InvocationTargetException, IllegalAccessException {
m.invoke(parent, p.resolveFile(value).toPath()); m.invoke(parent, p.resolveFile(value).toPath());
} }
}; };
@@ -1126,8 +1123,8 @@ public final class IntrospectionHelper {
if (Resource.class.equals(reflectedArg) || FileProvider.class.equals(reflectedArg)) { if (Resource.class.equals(reflectedArg) || FileProvider.class.equals(reflectedArg)) {
return new AttributeSetter(m, arg) { return new AttributeSetter(m, arg) {
@Override @Override
void set(final Project p, final Object parent, final String value) throws InvocationTargetException,
IllegalAccessException, BuildException {
void set(final Project p, final Object parent, final String value)
throws InvocationTargetException, IllegalAccessException, BuildException {
m.invoke(parent, new FileResource(p, p.resolveFile(value))); m.invoke(parent, new FileResource(p, p.resolveFile(value)));
} }
}; };
@@ -1244,7 +1241,7 @@ public final class IntrospectionHelper {
value); value);
setValue = enumValue; setValue = enumValue;
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
//there is specific logic here for the value
// there is a specific logic here for the value
// being out of the allowed set of enumerations. // being out of the allowed set of enumerations.
throw new BuildException("'" + value + "' is not a permitted value for " throw new BuildException("'" + value + "' is not a permitted value for "
+ reflectedArg.getName()); + reflectedArg.getName());
@@ -1478,7 +1475,7 @@ public final class IntrospectionHelper {
} }


private void istore(final Object parent, final Object child) private void istore(final Object parent, final Object child)
throws InvocationTargetException, IllegalAccessException, InstantiationException {
throws InvocationTargetException, IllegalAccessException {
getMethod().invoke(parent, child); getMethod().invoke(parent, child);
} }
} }
@@ -1541,10 +1538,8 @@ public final class IntrospectionHelper {
} }
final ComponentHelper helper = ComponentHelper.getComponentHelper(project); final ComponentHelper helper = ComponentHelper.getComponentHelper(project);


final MethodAndObject restricted = createRestricted(
helper, elementName, addTypeMethods);
final MethodAndObject topLevel = createTopLevel(
helper, elementName, addTypeMethods);
final MethodAndObject restricted = createRestricted(helper, elementName, addTypeMethods);
final MethodAndObject topLevel = createTopLevel(helper, elementName, addTypeMethods);


if (restricted == null && topLevel == null) { if (restricted == null && topLevel == null) {
return null; return null;
@@ -1556,8 +1551,7 @@ public final class IntrospectionHelper {
+ elementName); + elementName);
} }


final MethodAndObject methodAndObject
= restricted != null ? restricted : topLevel;
final MethodAndObject methodAndObject = restricted == null ? topLevel : restricted;


Object rObject = methodAndObject.object; Object rObject = methodAndObject.object;
if (methodAndObject.object instanceof PreSetDef.PreSetDefinition) { if (methodAndObject.object instanceof PreSetDef.PreSetDefinition) {
@@ -1716,9 +1710,8 @@ public final class IntrospectionHelper {
final Method addMethod = findMatchingMethod( final Method addMethod = findMatchingMethod(
restrictedDefinition.getExposedClass(project), addTypeMethods); restrictedDefinition.getExposedClass(project), addTypeMethods);
if (addMethod == null) { if (addMethod == null) {
throw new BuildException(
"Ant Internal Error - contract mismatch for "
+ elementName);
throw new BuildException("Ant Internal Error - contract mismatch for "
+ elementName);
} }
final Object addedObject = restrictedDefinition.create(project); final Object addedObject = restrictedDefinition.create(project);
if (addedObject == null) { if (addedObject == null) {


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

@@ -176,6 +176,7 @@ public class RuntimeConfigurable implements Serializable {
* false. * false.
* @since 1.9.1 * @since 1.9.1
*/ */
@SuppressWarnings("deprecated")
public boolean isEnabled(UnknownElement owner) { public boolean isEnabled(UnknownElement owner) {
if (!namespacedAttribute) { if (!namespacedAttribute) {
return true; return true;


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

@@ -62,12 +62,10 @@ public class DispatchUtils {
if (actionM != null) { if (actionM != null) {
final Object o = actionM.invoke(dispatchable, (Object[]) null); final Object o = actionM.invoke(dispatchable, (Object[]) null);
if (o != null) { if (o != null) {
final String s = o.toString();
if (s.trim().length() > 0) {
methodName = s.trim();
Method executeM = null;
executeM = dispatchable.getClass().getMethod(
methodName);
final String s = o.toString().trim();
if (s.length() > 0) {
methodName = s;
Method executeM = dispatchable.getClass().getMethod(methodName);
if (executeM == null) { if (executeM == null) {
throw new BuildException( throw new BuildException(
"No public " + methodName + "() in " "No public " + methodName + "() in "


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

@@ -395,7 +395,7 @@ public class TokenFilter extends BaseFilterReader


// write the remaining characters // write the remaining characters
if (line.length() > start) { if (line.length() > start) {
ret.append(line.substring(start, line.length()));
ret.append(line, start, line.length());
} }


return ret.toString(); return ret.toString();


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

@@ -43,6 +43,7 @@ import org.xml.sax.DocumentHandler;
import org.xml.sax.HandlerBase; import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.Parser;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.XMLReaderAdapter; import org.xml.sax.helpers.XMLReaderAdapter;
@@ -62,7 +63,7 @@ public class ProjectHelperImpl extends ProjectHelper {
* SAX 1 style parser used to parse the given file. This may * SAX 1 style parser used to parse the given file. This may
* in fact be a SAX 2 XMLReader wrapped in an XMLReaderAdapter. * in fact be a SAX 2 XMLReader wrapped in an XMLReaderAdapter.
*/ */
private org.xml.sax.Parser parser;
private Parser parser;


/** The project to configure. */ /** The project to configure. */
private Project project; private Project project;


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

@@ -31,7 +31,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.StringUtils;


/** /**
* Will set the given property if the requested resource is available at * Will set the given property if the requested resource is available at
@@ -240,11 +239,8 @@ public class Available extends Task implements Condition {
PropertyHelper ph = PropertyHelper.getPropertyHelper(getProject()); PropertyHelper ph = PropertyHelper.getPropertyHelper(getProject());
Object oldvalue = ph.getProperty(property); Object oldvalue = ph.getProperty(property);
if (null != oldvalue && !oldvalue.equals(value)) { if (null != oldvalue && !oldvalue.equals(value)) {
log("DEPRECATED - <available> used to override an existing"
+ " property."
+ StringUtils.LINE_SEP
+ " Build file should not reuse the same property"
+ " name for different values.",
log(String.format("DEPRECATED - <available> used to override an existing property.%n"
+ " Build file should not reuse the same property name for different values."),
Project.MSG_WARN); Project.MSG_WARN);
} }
// NB: this makes use of Project#setProperty rather than Project#setNewProperty // NB: this makes use of Project#setProperty rather than Project#setNewProperty


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

@@ -21,6 +21,7 @@ package org.apache.tools.ant.taskdefs;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Hashtable; import java.util.Hashtable;
@@ -1019,7 +1020,7 @@ public class Copy extends Task {
l = new ArrayList<>(names.length); l = new ArrayList<>(names.length);
m.put(baseDir, l); m.put(baseDir, l);
} }
l.addAll(java.util.Arrays.asList(names));
l.addAll(Arrays.asList(names));
} }
} }




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

@@ -662,7 +662,6 @@ public class Delete extends MatchingTask {
filesets.add(implicit); filesets.add(implicit);
} }


final int size = filesets.size();
for (FileSet fs : filesets) { for (FileSet fs : filesets) {
if (fs.getProject() == null) { if (fs.getProject() == null) {
log("Deleting fileset with no project specified; assuming executing project", log("Deleting fileset with no project specified; assuming executing project",


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

@@ -187,9 +187,7 @@ public class Expand extends Task {
+ " as the file does not exist", + " as the file does not exist",
getLocation()); getLocation());
} }
try (
ZipFile
zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)){
try (ZipFile zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)) {
boolean empty = true; boolean empty = true;
Enumeration<ZipEntry> e = zf.getEntries(); Enumeration<ZipEntry> e = zf.getEntries();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {


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

@@ -1546,7 +1546,7 @@ public class Javac extends MatchingTask {
element, element,
i)); i));
} }
final Collection<? extends CharSequence> parts = resolveGroup(element.subSequence(i+1, end));
final Collection<? extends CharSequence> parts = resolveGroup(element.subSequence(i + 1, end));
switch (parts.size()) { switch (parts.size()) {
case 0: case 0:
break; break;


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

@@ -263,7 +263,6 @@ public class MacroDef extends AntlibDefinition {
"the name \"%s\" has already been used by the text element", "the name \"%s\" has already been used by the text element",
attribute.getName()); attribute.getName());
} }
final int size = attributes.size();
for (Attribute att : attributes) { for (Attribute att : attributes) {
if (att.getName().equals(attribute.getName())) { if (att.getName().equals(attribute.getName())) {
throw new BuildException( throw new BuildException(
@@ -700,12 +699,10 @@ public class MacroDef extends AntlibDefinition {
return true; return true;
} }


if (obj == null) {
return false;
}
if (!obj.getClass().equals(getClass())) {
if (obj == null || !obj.getClass().equals(getClass())) {
return false; return false;
} }

MacroDef other = (MacroDef) obj; MacroDef other = (MacroDef) obj;
if (name == null) { if (name == null) {
return other.name == null; return other.name == null;
@@ -716,8 +713,8 @@ public class MacroDef extends AntlibDefinition {
// Allow two macro definitions with the same location // Allow two macro definitions with the same location
// to be treated as similar - bugzilla 31215 // to be treated as similar - bugzilla 31215
if (other.getLocation() != null if (other.getLocation() != null
&& other.getLocation().equals(getLocation())
&& !same) {
&& other.getLocation().equals(getLocation())
&& !same) {
return true; return true;
} }
if (text == null) { if (text == null) {
@@ -728,7 +725,7 @@ public class MacroDef extends AntlibDefinition {
return false; return false;
} }
if (getURI() == null || "".equals(getURI()) if (getURI() == null || "".equals(getURI())
|| getURI().equals(ProjectHelper.ANT_CORE_URI)) {
|| getURI().equals(ProjectHelper.ANT_CORE_URI)) {
if (other.getURI() != null && !"".equals(other.getURI()) if (other.getURI() != null && !"".equals(other.getURI())
&& !other.getURI().equals(ProjectHelper.ANT_CORE_URI)) { && !other.getURI().equals(ProjectHelper.ANT_CORE_URI)) {
return false; return false;
@@ -737,16 +734,8 @@ public class MacroDef extends AntlibDefinition {
return false; return false;
} }


if (!nestedSequential.similar(other.nestedSequential)) {
return false;
}
if (!attributes.equals(other.attributes)) {
return false;
}
if (!elements.equals(other.elements)) {
return false;
}
return true;
return nestedSequential.similar(other.nestedSequential)
&& attributes.equals(other.attributes) && elements.equals(other.elements);
} }


/** /**


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

@@ -674,8 +674,7 @@ public class Redirector {
} catch (final IOException eyeOhEx) { } catch (final IOException eyeOhEx) {
throw new BuildException(eyeOhEx); throw new BuildException(eyeOhEx);
} }
((ConcatFileInputStream) inputStream)
.setManagingComponent(managingTask);
((ConcatFileInputStream) inputStream).setManagingComponent(managingTask);
} else if (inputString != null) { } else if (inputString != null) {
final StringBuffer buf = new StringBuffer("Using input "); final StringBuffer buf = new StringBuffer("Using input ");
if (logInputString) { if (logInputString) {


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

@@ -626,9 +626,7 @@ public class Replace extends MatchingTask {
throws BuildException { throws BuildException {
Properties props = new Properties(); Properties props = new Properties();


try (
InputStream
in = propertyResource.getInputStream()){
try (InputStream in = propertyResource.getInputStream()) {
props.load(in); props.load(in);
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Property resource (%s) cannot be loaded.", throw new BuildException("Property resource (%s) cannot be loaded.",


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

@@ -150,8 +150,7 @@ public class Javah extends Task {
public String[] getClasses() { public String[] getClasses() {
Stream<String> stream = Stream.concat( Stream<String> stream = Stream.concat(
files.stream() files.stream()
.map(fs -> fs.getDirectoryScanner(getProject())
.getIncludedFiles())
.map(fs -> fs.getDirectoryScanner(getProject()).getIncludedFiles())
.flatMap(Stream::of) .flatMap(Stream::of)
.map(s -> s.replace('\\', '.').replace('/', '.') .map(s -> s.replace('\\', '.').replace('/', '.')
.replaceFirst("\\.class$", "")), .replaceFirst("\\.class$", "")),
@@ -375,8 +374,7 @@ public class Javah extends Task {
* @since Ant 1.6.3 * @since Ant 1.6.3
*/ */
public ImplementationSpecificArgument createArg() { public ImplementationSpecificArgument createArg() {
ImplementationSpecificArgument arg =
new ImplementationSpecificArgument();
ImplementationSpecificArgument arg = new ImplementationSpecificArgument();
facade.addImplementationArgument(arg); facade.addImplementationArgument(arg);
return arg; return arg;
} }
@@ -444,8 +442,8 @@ public class Javah extends Task {
+ "\" does not exist or is not a directory", getLocation()); + "\" does not exist or is not a directory", getLocation());
} }
if (outputFile != null) { if (outputFile != null) {
throw new BuildException("destdir and outputFile are mutually "
+ "exclusive", getLocation());
throw new BuildException("destdir and outputFile are mutually exclusive",
getLocation());
} }
} }




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

@@ -254,13 +254,8 @@ public class PropertyFile extends Task {
throw new BuildException(x, getLocation()); throw new BuildException(x, getLocation());
} }
try { try {
OutputStream os = Files.newOutputStream(propertyfile.toPath()); //NOSONAR
try {
try {
os.write(baos.toByteArray());
} finally {
os.close();
}
try (OutputStream os = Files.newOutputStream(propertyfile.toPath())) {
os.write(baos.toByteArray());
} catch (IOException x) { // possibly corrupt } catch (IOException x) { // possibly corrupt
FileUtils.getFileUtils().tryHardToDelete(propertyfile); FileUtils.getFileUtils().tryHardToDelete(propertyfile);
throw x; throw x;


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

@@ -327,7 +327,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
if (uriResolver != null) { if (uriResolver != null) {
transformer.setURIResolver(uriResolver); transformer.setURIResolver(uriResolver);
} }
for (String[] pair : outputProperties) {
for (final String[] pair : outputProperties) {
transformer.setOutputProperty(pair[0], pair[1]); transformer.setOutputProperty(pair[0], pair[1]);
} }


@@ -422,7 +422,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
tfactory.setErrorListener(this); tfactory.setErrorListener(this);


// specific attributes for the transformer // specific attributes for the transformer
final int size = attributes.size();
for (final Object[] pair : attributes) { for (final Object[] pair : attributes) {
tfactory.setAttribute((String) pair[0], pair[1]); tfactory.setAttribute((String) pair[0], pair[1]);
} }


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

@@ -288,7 +288,7 @@ public class XMLValidateTask extends Task {
public void execute() throws BuildException { public void execute() throws BuildException {
try { try {
int fileProcessed = 0; int fileProcessed = 0;
if (file == null && (filesets.isEmpty())) {
if (file == null && filesets.isEmpty()) {
throw new BuildException( throw new BuildException(
"Specify at least one source - " + "a file or a fileset."); "Specify at least one source - " + "a file or a fileset.");
} }
@@ -307,7 +307,7 @@ public class XMLValidateTask extends Task {
} }
} }


for (FileSet fs : filesets) {
for (final FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
for (String fileName : ds.getIncludedFiles()) { for (String fileName : ds.getIncludedFiles()) {
File srcFile = new File(fs.getDir(getProject()), fileName); File srcFile = new File(fs.getDir(getProject()), fileName);
@@ -348,12 +348,12 @@ public class XMLValidateTask extends Task {
setFeature(XmlConstants.FEATURE_VALIDATION, true); setFeature(XmlConstants.FEATURE_VALIDATION, true);
} }
// set the feature from the attribute list // set the feature from the attribute list
for (Attribute feature : attributeList) {
for (final Attribute feature : attributeList) {
setFeature(feature.getName(), feature.getValue()); setFeature(feature.getName(), feature.getValue());


} }
// Sets properties // Sets properties
for (Property prop : propertyList) {
for (final Property prop : propertyList) {
setProperty(prop.getName(), prop.getValue()); setProperty(prop.getName(), prop.getValue());
} }
} }
@@ -375,6 +375,7 @@ public class XMLValidateTask extends Task {
* we have created and wrapped a SAX1 parser. * we have created and wrapped a SAX1 parser.
* @return the new XMLReader. * @return the new XMLReader.
*/ */
@SuppressWarnings("deprecated")
protected XMLReader createXmlReader() { protected XMLReader createXmlReader() {
Object reader = null; Object reader = null;
if (readerClassName == null) { if (readerClassName == null) {
@@ -645,7 +646,7 @@ public class XMLValidateTask extends Task {
} }
int line = e.getLineNumber(); int line = e.getLineNumber();
int col = e.getColumnNumber(); int col = e.getColumnNumber();
return name
return name
+ (line == -1 + (line == -1
? "" ? ""
: (":" + line + (col == -1 ? "" : (":" + col)))) : (":" + line + (col == -1 ? "" : (":" + col))))
@@ -661,11 +662,10 @@ public class XMLValidateTask extends Task {
* @since ant1.6 * @since ant1.6
*/ */
public static class Attribute { public static class Attribute {
/** The name of the attribute to set.
/**
* The name of the attribute to set.
* *
* Valid attributes <a href=
* "http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"
* >include.</a>
* Valid attributes <a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description">include</a>
*/ */
private String attributeName = null; private String attributeName = null;




+ 0
- 5
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java View File

@@ -31,11 +31,6 @@ public class MethodHandleCPInfo extends ConstantPoolEntry {
private ReferenceKind referenceKind; private ReferenceKind referenceKind;
/** Must be a valid index into the constant pool table. */ /** Must be a valid index into the constant pool table. */
private int referenceIndex; private int referenceIndex;
/**
* the index into the constant pool which defined the name and type
* signature of the method
*/
private int nameAndTypeIndex;


public enum ReferenceKind { public enum ReferenceKind {
REF_getField, REF_getField,


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

@@ -105,6 +105,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool {
* we may determine the name of the EJB JAR file using this display-name, * we may determine the name of the EJB JAR file using this display-name,
* but this has not be implemented yet. * but this has not be implemented yet.
*/ */
@SuppressWarnings("unused")
private String displayName; private String displayName;


/* /*


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

@@ -93,6 +93,7 @@ public class IPlanetEjbc {


/* Classpath used when the iAS ejbc is called */ /* Classpath used when the iAS ejbc is called */
private String classpath; private String classpath;
@SuppressWarnings("unused")
private String[] classpathElements; private String[] classpathElements;


/* Options passed to the iAS ejbc */ /* Options passed to the iAS ejbc */
@@ -643,6 +644,7 @@ public class IPlanetEjbc {
* *
* @return String display-name value. * @return String display-name value.
*/ */
@SuppressWarnings("unused")
public String getDisplayName() { public String getDisplayName() {
return displayName; return displayName;
} }
@@ -956,6 +958,7 @@ public class IPlanetEjbc {
this.primaryKey = primaryKey; this.primaryKey = primaryKey;
} }


@SuppressWarnings("unused")
public Classname getPrimaryKey() { public Classname getPrimaryKey() {
return primaryKey; return primaryKey;
} }


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

@@ -312,7 +312,7 @@ public class WLJspc extends MatchingTask {
int numTokens = st.countTokens(); int numTokens = st.countTokens();
for (int i = 0; i < numTokens; i++) { for (int i = 0; i < numTokens; i++) {
String test = st.nextToken(); String test = st.nextToken();
test = (test.equals(escapeChars) ? replaceChars : test);
test = test.equals(escapeChars) ? replaceChars : test;
localString.append(test); localString.append(test);
} }
return localString.toString(); return localString.toString();


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

@@ -80,8 +80,7 @@ public class SingleTestClass extends TestDefinition implements NamedTest {
requestBuilder.selectors(DiscoverySelectors.selectClass(this.testClass)); requestBuilder.selectors(DiscoverySelectors.selectClass(this.testClass));
} else { } else {
// add specific methods // add specific methods
final String[] methods = this.getMethods();
for (final String method : methods) {
for (final String method : this.getMethods()) {
requestBuilder.selectors(DiscoverySelectors.selectMethod(this.testClass, method)); requestBuilder.selectors(DiscoverySelectors.selectMethod(this.testClass, method));
} }
} }


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

@@ -38,7 +38,7 @@ abstract class TestDefinition {
} }


boolean isHaltOnFailure() { boolean isHaltOnFailure() {
return this.haltOnFailure == null ? false : this.haltOnFailure;
return this.haltOnFailure != null && this.haltOnFailure;
} }


Boolean getHaltOnFailure() { Boolean getHaltOnFailure() {


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

@@ -32,7 +32,6 @@ 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;
import org.apache.tools.ant.util.Native2AsciiUtils; import org.apache.tools.ant.util.Native2AsciiUtils;
import org.apache.tools.ant.util.StringUtils;


/** /**
* Encapsulates the built-in Native2Ascii implementation. * Encapsulates the built-in Native2Ascii implementation.
@@ -85,8 +84,7 @@ public class BuiltinNative2Ascii implements Native2AsciiAdapter {
UnaryOperator<String> translation) throws IOException { UnaryOperator<String> translation) throws IOException {
for (String line : (Iterable<String>) () -> input.lines() for (String line : (Iterable<String>) () -> input.lines()
.map(translation).iterator()) { .map(translation).iterator()) {
output.write(line);
output.write(StringUtils.LINE_SEP);
output.write(String.format("%s%n", line));
} }
} }
} }

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

@@ -247,7 +247,7 @@ public class FTP extends Task implements FTPTaskConfig {
@Override @Override
public String getParent() { public String getParent() {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (int i = 0; i < parts.length - 1; i++){
for (int i = 0; i < parts.length - 1; i++) {
result.append(File.separatorChar).append(parts[i]); result.append(File.separatorChar).append(parts[i]);
} }
return result.toString(); return result.toString();
@@ -2702,7 +2702,6 @@ public class FTP extends Task implements FTPTaskConfig {
getValidLanguageCodes(); getValidLanguageCodes();


private static String[] getValidLanguageCodes() { private static String[] getValidLanguageCodes() {
@SuppressWarnings("unchecked")
Collection<String> c = FTPClientConfig.getSupportedLanguageCodes(); Collection<String> c = FTPClientConfig.getSupportedLanguageCodes();
String[] ret = new String[c.size() + 1]; String[] ret = new String[c.size() + 1];
int i = 0; int i = 0;


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

@@ -146,7 +146,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
@Override @Override
public String getParent() { public String getParent() {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (int i = 0; i < parts.length - 1; i++){
for (int i = 0; i < parts.length - 1; i++) {
result.append(File.separatorChar).append(parts[i]); result.append(File.separatorChar).append(parts[i]);
} }
return result.toString(); return result.toString();


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

@@ -236,9 +236,8 @@ public class SplashTask extends Task {


boolean success = false; boolean success = false;
if (in != null) { if (in != null) {
try (
DataInputStream din = new DataInputStream(in);
ByteArrayOutputStream bout = new ByteArrayOutputStream()){
try (DataInputStream din = new DataInputStream(in);
ByteArrayOutputStream bout = new ByteArrayOutputStream()) {
int data; int data;
while ((data = din.read()) != -1) { while ((data = din.read()) != -1) {
bout.write((byte) data); bout.write((byte) data);


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

@@ -39,7 +39,9 @@ public class ScpFromMessageBySftp extends ScpFromMessage {


private String remoteFile; private String remoteFile;
private final File localFile; private final File localFile;
@SuppressWarnings("unused")
private boolean isRecursive = false; private boolean isRecursive = false;
@SuppressWarnings("unused")
private boolean verbose = false; private boolean verbose = false;


/** /**
@@ -161,7 +163,7 @@ public class ScpFromMessageBySftp extends ScpFromMessage {


private void getFile(final ChannelSftp channel, private void getFile(final ChannelSftp channel,
final ChannelSftp.LsEntry le, final ChannelSftp.LsEntry le,
File localFile) throws IOException, SftpException {
File localFile) throws SftpException {
final String remoteFile = le.getFilename(); final String remoteFile = le.getFilename();
if (!localFile.exists()) { if (!localFile.exists()) {
final String path = localFile.getAbsolutePath(); final String path = localFile.getAbsolutePath();


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

@@ -171,7 +171,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
log("done.\n"); log("done.\n");
} }


private void doSingleTransfer() throws IOException, JSchException {
private void doSingleTransfer() throws JSchException {
final ChannelSftp channel = openSftpChannel(); final ChannelSftp channel = openSftpChannel();
try { try {
channel.connect(); channel.connect();
@@ -265,7 +265,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
private void sendFileToRemote(final ChannelSftp channel, private void sendFileToRemote(final ChannelSftp channel,
final File localFile, final File localFile,
String remotePath) String remotePath)
throws IOException, SftpException {
throws SftpException {
final long filesize = localFile.length(); final long filesize = localFile.length();


if (remotePath == null) { if (remotePath == null) {


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

@@ -179,9 +179,8 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
* @throws BuildException if the command cannot execute. * @throws BuildException if the command cannot execute.
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
int result = 0;
Commandline commandLine = buildCmdLine(); Commandline commandLine = buildCmdLine();
result = run(commandLine);
int result = run(commandLine);
if (Execute.isFailure(result) && getFailOnError()) { if (Execute.isFailure(result) && getFailOnError()) {
String msg = "Failed executing: " + formatCommandLine(commandLine) String msg = "Failed executing: " + formatCommandLine(commandLine)
+ " With a return code of " + result; + " With a return code of " + result;


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

@@ -244,6 +244,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable {
* or if <code>project</code> is <code>null</code>. * or if <code>project</code> is <code>null</code>.
* @since Ant 1.7 * @since Ant 1.7
*/ */
@SuppressWarnings("unchecked")
protected <T> T getCheckedRef(final Class<T> requiredClass, protected <T> T getCheckedRef(final Class<T> requiredClass,
final String dataTypeName, final Project project) { final String dataTypeName, final Project project) {
if (project == null) { if (project == null) {


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

@@ -218,8 +218,7 @@ public class Mapper extends DataType {


if (type == null && classname == null && container == null) { if (type == null && classname == null && container == null) {
throw new BuildException( throw new BuildException(
"nested mapper or "
+ "one of the attributes type or classname is required");
"nested mapper or one of the attributes type or classname is required");
} }


if (container != null) { if (container != null) {


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

@@ -180,6 +180,7 @@ public class TarResource extends ArchiveResource {
return (TarResource) super.getCheckedRef(); return (TarResource) super.getCheckedRef();
} }


@SuppressWarnings("deprecated")
private void setEntry(TarEntry e) { private void setEntry(TarEntry e) {
if (e == null) { if (e == null) {
setExists(false); setExists(false);


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

@@ -37,9 +37,6 @@ import org.apache.tools.ant.types.resources.comparators.ResourceComparator;
*/ */
public class Compare extends DataType implements ResourceSelector { public class Compare extends DataType implements ResourceSelector {


private static final String ONE_CONTROL_MESSAGE
= " the <control> element should be specified exactly once.";

private DelegatedResourceComparator comp = new DelegatedResourceComparator(); private DelegatedResourceComparator comp = new DelegatedResourceComparator();
private Quantifier against = Quantifier.ALL; private Quantifier against = Quantifier.ALL;


@@ -144,6 +141,7 @@ public class Compare extends DataType implements ResourceSelector {
} }


private BuildException oneControl() { private BuildException oneControl() {
return new BuildException(super.toString() + ONE_CONTROL_MESSAGE);
return new BuildException("%s the <control> element should be specified exactly once.",
super.toString());
} }
} }

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

@@ -576,16 +576,8 @@ public final class SelectorUtils {
* @return whether the target is out of date * @return whether the target is out of date
*/ */
public static boolean isOutOfDate(File src, File target, int granularity) { public static boolean isOutOfDate(File src, File target, int granularity) {
if (!src.exists()) {
return false;
}
if (!target.exists()) {
return true;
}
if ((src.lastModified() - granularity) > target.lastModified()) {
return true;
}
return false;
return src.exists() && (!target.exists()
|| (src.lastModified() - granularity) > target.lastModified());
} }


/** /**


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

@@ -136,11 +136,11 @@ public class ExecuteWatchdogTest {
watchdog.start(process); watchdog.start(process);


// I assume that starting this takes less than TIME_OUT/2 ms... // I assume that starting this takes less than TIME_OUT/2 ms...
Thread thread = new Thread(){
public void run(){
Thread thread = new Thread() {
public void run() {
try { try {
process.waitFor(); process.waitFor();
} catch(InterruptedException e){
} catch(InterruptedException e) {
// not very nice but will do the job // not very nice but will do the job
throw new AssumptionViolatedException("process interrupted in thread", e); throw new AssumptionViolatedException("process interrupted in thread", e);
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java View File

@@ -89,7 +89,7 @@ public class SQLExecTest {
assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER));
try { try {
sql.execute(); sql.execute();
} catch (BuildException e){
} catch (BuildException e) {
assertTrue(e.getCause().getMessage().contains("No suitable Driver")); assertTrue(e.getCause().getMessage().contains("No suitable Driver"));
} }
assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER));


+ 2
- 10
src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java View File

@@ -69,12 +69,8 @@ public class TranslateTest {
byte[] buffer1 = new byte[BUF_SIZE]; byte[] buffer1 = new byte[BUF_SIZE];
byte[] buffer2 = new byte[BUF_SIZE]; byte[] buffer2 = new byte[BUF_SIZE];


@SuppressWarnings("resource")
FileInputStream fis1 = new FileInputStream(file1);
try {
@SuppressWarnings("resource")
FileInputStream fis2 = new FileInputStream(file2);
try {
try (FileInputStream fis1 = new FileInputStream(file1)) {
try (FileInputStream fis2 = new FileInputStream(file2)) {
int read = 0; int read = 0;
while ((read = fis1.read(buffer1)) != -1) { while ((read = fis1.read(buffer1)) != -1) {
fis2.read(buffer2); fis2.read(buffer2);
@@ -84,11 +80,7 @@ public class TranslateTest {
} }
} }
} }
} finally {
fis2.close();
} }
} finally {
fis1.close();
} }
return true; return true;
} }


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

@@ -64,7 +64,7 @@ public class ImageTest {
} }


@Test @Test
public void testSimpleScale(){
public void testSimpleScale() {
buildRule.executeTarget("testSimpleScale"); buildRule.executeTarget("testSimpleScale");
AntAssert.assertContains("Processing File", buildRule.getLog()); AntAssert.assertContains("Processing File", buildRule.getLog());


@@ -114,7 +114,7 @@ public class ImageTest {
try { try {
buildRule.executeTarget("testFailOnError"); buildRule.executeTarget("testFailOnError");
AntAssert.assertContains("Unable to process image stream", buildRule.getLog()); AntAssert.assertContains("Unable to process image stream", buildRule.getLog());
} catch (RuntimeException re){
} catch (RuntimeException re) {
assertTrue("Run time exception should say 'Unable to process image stream'. :" assertTrue("Run time exception should say 'Unable to process image stream'. :"
+ re.toString(), + re.toString(),
re.toString().contains("Unable to process image stream")); re.toString().contains("Unable to process image stream"));


+ 0
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java View File

@@ -524,7 +524,6 @@ public class FTPTest {
*/ */
private class LogCounter extends DefaultLogger { private class LogCounter extends DefaultLogger {
private Map<String, Integer> searchMap = new HashMap<>(); private Map<String, Integer> searchMap = new HashMap<>();
private int matchCount;


public void addLogMessageToSearch(String message) { public void addLogMessageToSearch(String message) {
searchMap.put(message, 0); searchMap.put(message, 0);


Loading…
Cancel
Save