You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mb...@apache.org on 2017/04/13 15:16:10 UTC
[10/34] ant git commit: java 5-8
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java b/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
index 7e62549..35d873c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
@@ -21,7 +21,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -54,21 +53,22 @@ public class ScriptDef extends DefBase {
private String name;
/** Attributes definitions of this script */
- private List attributes = new ArrayList();
+ private List<Attribute> attributes = new ArrayList<>();
/** Nested Element definitions of this script */
- private List nestedElements = new ArrayList();
+ private List<NestedElement> nestedElements = new ArrayList<>();
/** The attribute names as a set */
- private Set attributeSet;
+ private Set<String> attributeSet;
/** The nested element definitions indexed by their names */
- private Map nestedElementMap;
+ private Map<String, NestedElement> nestedElementMap;
/**
* Set the project.
* @param project the project that this definition belongs to.
*/
+ @Override
public void setProject(Project project) {
super.setProject(project);
helper.setProjectComponent(this);
@@ -181,20 +181,21 @@ public class ScriptDef extends DefBase {
/**
* Defines the script.
*/
+ @Override
public void execute() {
if (name == null) {
- throw new BuildException("scriptdef requires a name attribute to "
- + "name the script");
+ throw new BuildException(
+ "scriptdef requires a name attribute to name the script");
}
if (helper.getLanguage() == null) {
- throw new BuildException("scriptdef requires a language attribute "
- + "to specify the script language");
+ throw new BuildException(
+ "scriptdef requires a language attribute to specify the script language");
}
if (helper.getSrc() == null && helper.getEncoding() != null) {
- throw new BuildException("scriptdef requires a src attribute "
- + "if the encoding is set");
+ throw new BuildException(
+ "scriptdef requires a src attribute if the encoding is set");
}
// Check if need to set the loader
@@ -202,51 +203,47 @@ public class ScriptDef extends DefBase {
helper.setClassLoader(createLoader());
}
- attributeSet = new HashSet();
- for (Iterator i = attributes.iterator(); i.hasNext();) {
- Attribute attribute = (Attribute) i.next();
+ attributeSet = new HashSet<>();
+ for (Attribute attribute : attributes) {
if (attribute.name == null) {
- throw new BuildException("scriptdef <attribute> elements "
- + "must specify an attribute name");
+ throw new BuildException(
+ "scriptdef <attribute> elements must specify an attribute name");
}
-
if (attributeSet.contains(attribute.name)) {
- throw new BuildException("scriptdef <" + name + "> declares "
- + "the " + attribute.name + " attribute more than once");
+ throw new BuildException(
+ "scriptdef <%s> declares the %s attribute more than once",
+ name, attribute.name);
}
attributeSet.add(attribute.name);
}
- nestedElementMap = new HashMap();
- for (Iterator i = nestedElements.iterator(); i.hasNext();) {
- NestedElement nestedElement = (NestedElement) i.next();
+ nestedElementMap = new HashMap<>();
+ for (NestedElement nestedElement : nestedElements) {
if (nestedElement.name == null) {
- throw new BuildException("scriptdef <element> elements "
- + "must specify an element name");
+ throw new BuildException(
+ "scriptdef <element> elements must specify an element name");
}
if (nestedElementMap.containsKey(nestedElement.name)) {
- throw new BuildException("scriptdef <" + name + "> declares "
- + "the " + nestedElement.name + " nested element more "
- + "than once");
+ throw new BuildException(
+ "scriptdef <%s> declares the %s nested element more than once",
+ name, nestedElement.name);
}
if (nestedElement.className == null
&& nestedElement.type == null) {
- throw new BuildException("scriptdef <element> elements "
- + "must specify either a classname or type attribute");
+ throw new BuildException(
+ "scriptdef <element> elements must specify either a classname or type attribute");
}
if (nestedElement.className != null
&& nestedElement.type != null) {
- throw new BuildException("scriptdef <element> elements "
- + "must specify only one of the classname and type "
- + "attributes");
+ throw new BuildException(
+ "scriptdef <element> elements must specify only one of the classname and type attributes");
}
-
nestedElementMap.put(nestedElement.name, nestedElement);
}
// find the script repository - it is stored in the project
- Map scriptRepository = lookupScriptRepository();
+ Map<String, ScriptDef> scriptRepository = lookupScriptRepository();
name = ProjectHelper.genComponentName(getURI(), name);
scriptRepository.put(name, this);
AntTypeDefinition def = new AntTypeDefinition();
@@ -261,14 +258,14 @@ public class ScriptDef extends DefBase {
* This method is synchronized on the project under {@link MagicNames#SCRIPT_REPOSITORY}
* @return the current script repository registered as a reference.
*/
- private Map lookupScriptRepository() {
- Map scriptRepository = null;
+ private Map<String, ScriptDef> lookupScriptRepository() {
+ Map<String, ScriptDef> scriptRepository;
Project p = getProject();
synchronized (p) {
scriptRepository =
- (Map) p.getReference(MagicNames.SCRIPT_REPOSITORY);
+ p.getReference(MagicNames.SCRIPT_REPOSITORY);
if (scriptRepository == null) {
- scriptRepository = new HashMap();
+ scriptRepository = new HashMap<>();
p.addReference(MagicNames.SCRIPT_REPOSITORY,
scriptRepository);
}
@@ -283,14 +280,14 @@ public class ScriptDef extends DefBase {
* @return object representing the element name.
*/
public Object createNestedElement(String elementName) {
- NestedElement definition
- = (NestedElement) nestedElementMap.get(elementName);
+ NestedElement definition = nestedElementMap.get(elementName);
if (definition == null) {
- throw new BuildException("<" + name + "> does not support "
- + "the <" + elementName + "> nested element");
+ throw new BuildException(
+ "<%s> does not support the <%s> nested element", name,
+ elementName);
}
- Object instance = null;
+ Object instance;
String classname = definition.className;
if (classname == null) {
instance = getProject().createTask(definition.type);
@@ -298,11 +295,6 @@ public class ScriptDef extends DefBase {
instance = getProject().createDataType(definition.type);
}
} else {
- /*
- // try the context classloader
- ClassLoader loader
- = Thread.currentThread().getContextClassLoader();
- */
ClassLoader loader = createLoader();
try {
@@ -310,13 +302,13 @@ public class ScriptDef extends DefBase {
} catch (BuildException e) {
instance = ClasspathUtils.newInstance(classname, ScriptDef.class.getClassLoader());
}
-
getProject().setProjectReference(instance);
}
if (instance == null) {
- throw new BuildException("<" + name + "> is unable to create "
- + "the <" + elementName + "> nested element");
+ throw new BuildException(
+ "<%s> is unable to create the <%s> nested element", name,
+ elementName);
}
return instance;
}
@@ -329,7 +321,9 @@ public class ScriptDef extends DefBase {
* @deprecated since 1.7.
* Use executeScript(attribute, elements, instance) instead.
*/
- public void executeScript(Map attributes, Map elements) {
+ @Deprecated
+ public void executeScript(Map<String, String> attributes,
+ Map<String, List<Object>> elements) {
executeScript(attributes, elements, null);
}
@@ -342,7 +336,8 @@ public class ScriptDef extends DefBase {
* @param elements a list of nested element values.
* @param instance the script instance; can be null
*/
- public void executeScript(Map attributes, Map elements, ScriptDefBase instance) {
+ public void executeScript(Map<String, String> attributes,
+ Map<String, List<Object>> elements, ScriptDefBase instance) {
ScriptRunnerBase runner = helper.getScriptRunner();
runner.addBean("attributes", attributes);
runner.addBean("elements", elements);
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java b/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java
index 95d15aa..a4a0bd6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java
@@ -36,10 +36,10 @@ import org.apache.tools.ant.Task;
public class ScriptDefBase extends Task implements DynamicConfigurator {
/** Nested elements */
- private Map nestedElementMap = new HashMap();
+ private Map<String, List<Object>> nestedElementMap = new HashMap<>();
/** Attributes */
- private Map attributes = new HashMap();
+ private Map<String, String> attributes = new HashMap<>();
private String text;
@@ -47,19 +47,20 @@ public class ScriptDefBase extends Task implements DynamicConfigurator {
* Locate the script defining task and execute the script by passing
* control to it
*/
+ @Override
public void execute() {
getScript().executeScript(attributes, nestedElementMap, this);
}
private ScriptDef getScript() {
String name = getTaskType();
- Map scriptRepository
- = (Map) getProject().getReference(MagicNames.SCRIPT_REPOSITORY);
+ Map<String, ScriptDef> scriptRepository =
+ getProject().getReference(MagicNames.SCRIPT_REPOSITORY);
if (scriptRepository == null) {
throw new BuildException("Script repository not found for " + name);
}
- ScriptDef definition = (ScriptDef) scriptRepository.get(getTaskType());
+ ScriptDef definition = scriptRepository.get(getTaskType());
if (definition == null) {
throw new BuildException("Script definition not found for " + name);
}
@@ -72,12 +73,10 @@ public class ScriptDefBase extends Task implements DynamicConfigurator {
* @param name the nested element name
* @return the element to be configured
*/
+ @Override
public Object createDynamicElement(String name) {
- List nestedElementList = (List) nestedElementMap.get(name);
- if (nestedElementList == null) {
- nestedElementList = new ArrayList();
- nestedElementMap.put(name, nestedElementList);
- }
+ List<Object> nestedElementList =
+ nestedElementMap.computeIfAbsent(name, k -> new ArrayList<>());
Object element = getScript().createNestedElement(name);
nestedElementList.add(element);
return element;
@@ -89,13 +88,14 @@ public class ScriptDefBase extends Task implements DynamicConfigurator {
* @param name the attribute name.
* @param value the attribute's string value
*/
+ @Override
public void setDynamicAttribute(String name, String value) {
ScriptDef definition = getScript();
if (!definition.isAttributeSupported(name)) {
- throw new BuildException("<" + getTaskType()
- + "> does not support the \"" + name + "\" attribute");
+ throw new BuildException(
+ "<%s> does not support the \"%s\" attribute", getTaskType(),
+ name);
}
-
attributes.put(name, value);
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
index c6614cb..66e0eb2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
@@ -388,6 +388,7 @@ public abstract class SOS extends Task implements SOSCmd {
*
* @throws BuildException on error.
*/
+ @Override
public void execute()
throws BuildException {
int result = 0;
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java
index 9095f07..3a82ea4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java
@@ -69,6 +69,7 @@ public class SOSCheckin extends SOS {
*
* @return Commandline the generated command to be executed
*/
+ @Override
protected Commandline buildCmdLine() {
commandLine = new Commandline();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java
index fab6fb9..a7b23c5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java
@@ -58,6 +58,7 @@ public class SOSCheckout extends SOS {
*
* @return Commandline the generated command to be executed
*/
+ @Override
protected Commandline buildCmdLine() {
commandLine = new Commandline();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java
index cdbf92b..b17e0c1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java
@@ -78,6 +78,7 @@ public class SOSGet extends SOS {
*
* @return Commandline the generated command to be executed
*/
+ @Override
protected Commandline buildCmdLine() {
commandLine = new Commandline();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java
index dd6b13a..0b41105 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java
@@ -63,6 +63,7 @@ public class SOSLabel extends SOS {
*
* @return Commandline the generated command to be executed
*/
+ @Override
protected Commandline buildCmdLine() {
commandLine = new Commandline();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
index 92dd348..84b4317 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
@@ -60,10 +60,6 @@ public class AntSoundPlayer implements LineListener, BuildListener {
private int loopsFail = 0;
private Long durationFail = null;
- /** Constructor for AntSoundPlayer. */
- public AntSoundPlayer() {
- }
-
/**
* @param file the location of the audio file to be played when the
* build is successful
@@ -102,7 +98,6 @@ public class AntSoundPlayer implements LineListener, BuildListener {
AudioInputStream audioInputStream = null;
-
try {
audioInputStream = AudioSystem.getAudioInputStream(file);
} catch (UnsupportedAudioFileException uafe) {
@@ -180,6 +175,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* clip if required.
* @param event the line event to follow
*/
+ @Override
public void update(LineEvent event) {
if (event.getType().equals(LineEvent.Type.STOP)) {
Line line = event.getLine();
@@ -192,6 +188,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* Fired before any targets are started.
* @param event ignored
*/
+ @Override
public void buildStarted(BuildEvent event) {
}
@@ -201,6 +198,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @param event the build finished event.
* @see BuildEvent#getException()
*/
+ @Override
public void buildFinished(BuildEvent event) {
if (event.getException() == null && fileSuccess != null) {
// build successful!
@@ -215,6 +213,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @param event ignored.
* @see BuildEvent#getTarget()
*/
+ @Override
public void targetStarted(BuildEvent event) {
}
@@ -224,6 +223,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @param event ignored.
* @see BuildEvent#getException()
*/
+ @Override
public void targetFinished(BuildEvent event) {
}
@@ -232,6 +232,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @param event ignored.
* @see BuildEvent#getTask()
*/
+ @Override
public void taskStarted(BuildEvent event) {
}
@@ -241,6 +242,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @param event ignored.
* @see BuildEvent#getException()
*/
+ @Override
public void taskFinished(BuildEvent event) {
}
@@ -250,6 +252,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @see BuildEvent#getMessage()
* @see BuildEvent#getPriority()
*/
+ @Override
public void messageLogged(BuildEvent event) {
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java
index 5de84cc..e7d1c31 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java
@@ -37,8 +37,10 @@ import javax.swing.JWindow;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
class SplashScreen extends JWindow implements ActionListener, BuildListener {
+ private static final long serialVersionUID = 1L;
private static final int FONT_SIZE = 12;
private JLabel text;
private JProgressBar pb;
@@ -118,6 +120,7 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
text.setText(txt);
}
+ @Override
public void actionPerformed(ActionEvent a) {
if (!hasProgressPattern()) {
if (total < MAX) {
@@ -129,31 +132,38 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
}
}
+ @Override
public void buildStarted(BuildEvent event) {
actionPerformed(null);
}
+ @Override
public void buildFinished(BuildEvent event) {
pb.setValue(MAX);
setVisible(false);
dispose();
}
+ @Override
public void targetStarted(BuildEvent event) {
actionPerformed(null);
}
+ @Override
public void targetFinished(BuildEvent event) {
actionPerformed(null);
}
+ @Override
public void taskStarted(BuildEvent event) {
actionPerformed(null);
}
+ @Override
public void taskFinished(BuildEvent event) {
actionPerformed(null);
}
+ @Override
public void messageLogged(BuildEvent event) {
actionPerformed(null);
if (hasProgressPattern()) {
@@ -162,12 +172,11 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
if (matcher != null && matcher.matches()) {
String gr = matcher.group(1);
try {
- int i = Math.min(new Integer(gr).intValue() * 2, MAX);
- pb.setValue(i);
+ pb.setValue(Math.min(Integer.parseInt(gr) * 2, MAX));
} catch (NumberFormatException e) {
- //TODO: how to reach logger?!?
- //log("Number parsing error in progressRegExp", Project.MSG_VERBOSE);
-
+ event.getProject().log(
+ "Number parsing error in progressRegExp",
+ Project.MSG_VERBOSE);
}
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
index 9d995bc..a3235f9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
@@ -20,7 +20,6 @@ package org.apache.tools.ant.taskdefs.optional.splash;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
@@ -237,9 +236,9 @@ public class SplashTask extends Task {
boolean success = false;
if (in != null) {
- DataInputStream din = new DataInputStream(in);
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ try (
+ DataInputStream din = new DataInputStream(in);
+ ByteArrayOutputStream bout = new ByteArrayOutputStream()){
int data;
while ((data = din.read()) != -1) {
bout.write((byte) data);
@@ -257,15 +256,6 @@ public class SplashTask extends Task {
} catch (Exception e) {
throw new BuildException(e);
} finally {
- try {
- din.close();
- } catch (IOException ioe) {
- // swallow if there was an error before so that
- // original error will be passed up
- if (success) {
- throw new BuildException(ioe); //NOSONAR
- }
- }
}
} else {
try {
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java
index c0236e1..1a26fa4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java
@@ -41,10 +41,8 @@ public abstract class AbstractSshMessage {
private final Session session;
private final boolean verbose;
private final boolean compressed;
- private LogListener listener = new LogListener() {
- public void log(final String message) {
- // do nothing;
- }
+ private LogListener listener = message -> {
+ // do nothing;
};
/**
@@ -97,9 +95,7 @@ public abstract class AbstractSshMessage {
* @throws JSchException on error
*/
protected ChannelSftp openSftpChannel() throws JSchException {
- final ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
-
- return channel;
+ return (ChannelSftp) session.openChannel("sftp");
}
/**
@@ -132,8 +128,9 @@ public abstract class AbstractSshMessage {
if (b == -1) {
// didn't receive any response
throw new BuildException("No response from server");
- } else if (b != 0) {
- final StringBuffer sb = new StringBuffer();
+ }
+ if (b != 0) {
+ final StringBuilder sb = new StringBuilder();
int c = in.read();
while (c > 0 && c != '\n') {
@@ -270,12 +267,12 @@ public abstract class AbstractSshMessage {
private long totalLength = 0;
private int percentTransmitted = 0;
+ @Override
public void init(final int op, final String src, final String dest, final long max) {
initFileSize = max;
- totalLength = 0;
- percentTransmitted = 0;
}
+ @Override
public boolean count(final long len) {
totalLength += len;
percentTransmitted = trackProgress(initFileSize,
@@ -284,6 +281,7 @@ public abstract class AbstractSshMessage {
return true;
}
+ @Override
public void end() {
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
index b5088a7..89230be 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
@@ -31,8 +32,8 @@ import java.util.StringTokenizer;
public class Directory {
private File directory;
- private Set childDirectories;
- private ArrayList files;
+ private Set<Directory> childDirectories;
+ private List<File> files;
private Directory parent;
/**
@@ -50,8 +51,8 @@ public class Directory {
*/
public Directory(File directory , Directory parent) {
this.parent = parent;
- this.childDirectories = new LinkedHashSet();
- this.files = new ArrayList();
+ this.childDirectories = new LinkedHashSet<>();
+ this.files = new ArrayList<>();
this.directory = directory;
}
@@ -77,7 +78,7 @@ public class Directory {
* Get an iterator over the child Directories.
* @return an iterator
*/
- public Iterator directoryIterator() {
+ public Iterator<Directory> directoryIterator() {
return childDirectories.iterator();
}
@@ -85,7 +86,7 @@ public class Directory {
* Get an iterator over the files.
* @return an iterator
*/
- public Iterator filesIterator() {
+ public Iterator<File> filesIterator() {
return files.iterator();
}
@@ -119,8 +120,7 @@ public class Directory {
* @return the child directory, or null if not found
*/
public Directory getChild(File dir) {
- for (Iterator i = childDirectories.iterator(); i.hasNext();) {
- Directory current = (Directory) i.next();
+ for (Directory current : childDirectories) {
if (current.getDirectory().equals(dir)) {
return current;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java
index d6abb95..2e426ee 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java
@@ -226,6 +226,7 @@ public abstract class SSHBase extends Task implements LogListener {
* This initializizs the known hosts and sets the default port.
* @throws BuildException on error
*/
+ @Override
public void init() throws BuildException {
super.init();
this.knownHosts = System.getProperty("user.home") + "/.ssh/known_hosts";
@@ -241,14 +242,17 @@ public abstract class SSHBase extends Task implements LogListener {
final JSch jsch = new JSch();
final SSHBase base = this;
if (verbose) {
- JSch.setLogger(new com.jcraft.jsch.Logger(){
- public boolean isEnabled(final int level){
- return true;
- }
- public void log(final int level, final String message){
- base.log(message, Project.MSG_INFO);
- }
- });
+ JSch.setLogger(new com.jcraft.jsch.Logger() {
+ @Override
+ public boolean isEnabled(final int level) {
+ return true;
+ }
+
+ @Override
+ public void log(final int level, final String message) {
+ base.log(message, Project.MSG_INFO);
+ }
+ });
}
if (null != userInfo.getKeyfile()) {
jsch.addIdentity(userInfo.getKeyfile());
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
index 3942003..1206d79 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
@@ -295,18 +295,16 @@ public class SSHExec extends SSHBase {
+ (inputProperty != null ? 1 : 0)
+ (inputString != null ? 1 : 0);
if (numberOfInputs > 1) {
- throw new BuildException("You can't specify more than one of"
- + " inputFile, inputProperty and"
- + " inputString.");
+ throw new BuildException(
+ "You can't specify more than one of inputFile, inputProperty and inputString.");
}
if (inputFile != null && !inputFile.exists()) {
- throw new BuildException("The input file "
- + inputFile.getAbsolutePath()
- + " does not exist.");
+ throw new BuildException("The input file %s does not exist.",
+ inputFile.getAbsolutePath());
}
Session session = null;
- final StringBuffer output = new StringBuffer();
+ final StringBuilder output = new StringBuilder();
try {
session = openSession();
/* called once */
@@ -314,32 +312,27 @@ public class SSHExec extends SSHBase {
log("cmd : " + command, Project.MSG_INFO);
executeCommand(session, command, output);
} else { // read command resource and execute for each command
- try {
- final BufferedReader br = new BufferedReader(
- new InputStreamReader(commandResource.getInputStream()));
- String cmd;
- while ((cmd = br.readLine()) != null) {
+ try (final BufferedReader br = new BufferedReader(
+ new InputStreamReader(commandResource.getInputStream()))) {
+ final Session s = session;
+ br.lines().forEach(cmd -> {
log("cmd : " + cmd, Project.MSG_INFO);
output.append(cmd).append(" : ");
- executeCommand(session, cmd, output);
+ executeCommand(s, cmd, output);
output.append("\n");
- }
- FileUtils.close(br);
+ });
} catch (final IOException e) {
if (getFailonerror()) {
throw new BuildException(e);
- } else {
- log("Caught exception: " + e.getMessage(),
- Project.MSG_ERR);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
}
} catch (final JSchException e) {
if (getFailonerror()) {
throw new BuildException(e);
- } else {
- log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
} finally {
if (outputProperty != null) {
getProject().setNewProperty(outputProperty, output.toString());
@@ -350,7 +343,7 @@ public class SSHExec extends SSHBase {
}
}
- private void executeCommand(final Session session, final String cmd, final StringBuffer sb)
+ private void executeCommand(final Session session, final String cmd, final StringBuilder sb)
throws BuildException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ByteArrayOutputStream errout = new ByteArrayOutputStream();
@@ -423,9 +416,8 @@ public class SSHExec extends SSHBase {
thread = null;
if (getFailonerror()) {
throw new BuildException(TIMEOUT_MESSAGE);
- } else {
- log(TIMEOUT_MESSAGE, Project.MSG_ERR);
}
+ log(TIMEOUT_MESSAGE, Project.MSG_ERR);
} else {
// stdout to outputFile
if (outputFile != null) {
@@ -450,9 +442,8 @@ public class SSHExec extends SSHBase {
final String msg = "Remote command failed with exit status " + ec;
if (getFailonerror()) {
throw new BuildException(msg);
- } else {
- log(msg, Project.MSG_ERR);
}
+ log(msg, Project.MSG_ERR);
}
}
} catch (final BuildException e) {
@@ -461,23 +452,19 @@ public class SSHExec extends SSHBase {
if (e.getMessage().indexOf("session is down") >= 0) {
if (getFailonerror()) {
throw new BuildException(TIMEOUT_MESSAGE, e);
- } else {
- log(TIMEOUT_MESSAGE, Project.MSG_ERR);
}
+ log(TIMEOUT_MESSAGE, Project.MSG_ERR);
} else {
if (getFailonerror()) {
throw new BuildException(e);
- } else {
- log("Caught exception: " + e.getMessage(),
- Project.MSG_ERR);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
} catch (final Exception e) {
if (getFailonerror()) {
throw new BuildException(e);
- } else {
- log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
} finally {
sb.append(out.toString());
FileUtils.close(istream);
@@ -498,9 +485,8 @@ public class SSHExec extends SSHBase {
try (FileWriter out = new FileWriter(to.getAbsolutePath(), append)) {
final StringReader in = new StringReader(from);
final char[] buffer = new char[BUFFER_SIZE];
- int bytesRead;
while (true) {
- bytesRead = in.read(buffer);
+ int bytesRead = in.read(buffer);
if (bytesRead == -1) {
break;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
index e9f2675..3fec911 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
@@ -19,7 +19,6 @@
package org.apache.tools.ant.taskdefs.optional.ssh;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -29,7 +28,6 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.TaskContainer;
-
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
@@ -45,10 +43,10 @@ public class SSHSession extends SSHBase {
/** units are milliseconds, default is 0=infinite */
private long maxwait = 0;
- private final Vector localTunnels = new Vector();
- private final Set localPortsUsed = new TreeSet();
- private final Vector remoteTunnels = new Vector();
- private final Set remotePortsUsed = new TreeSet();
+ private final List<LocalTunnel> localTunnels = new Vector<>();
+ private final Set<Integer> localPortsUsed = new TreeSet<>();
+ private final List<RemoteTunnel> remoteTunnels = new Vector<>();
+ private final Set<Integer> remotePortsUsed = new TreeSet<>();
private NestedSequential nestedSequential = null;
private static final String TIMEOUT_MESSAGE =
@@ -56,7 +54,7 @@ public class SSHSession extends SSHBase {
/** Optional Vector holding the nested tasks */
- private final Vector nestedTasks = new Vector();
+ private final List<Task> nestedTasks = new Vector<>();
/**
* Add a nested task to Sequential.
@@ -65,7 +63,7 @@ public class SSHSession extends SSHBase {
* <p>
*/
public void addTask(final Task nestedTask) {
- nestedTasks.addElement(nestedTask);
+ nestedTasks.add(nestedTask);
}
/**
@@ -148,48 +146,38 @@ public class SSHSession extends SSHBase {
throw new BuildException("Missing sequential element.");
}
-
Session session = null;
try {
// establish the session
session = openSession();
session.setTimeout((int) maxwait);
- for (final Iterator i = localTunnels.iterator(); i.hasNext();) {
- final LocalTunnel tunnel = (LocalTunnel) i.next();
+ for (LocalTunnel tunnel : localTunnels) {
session.setPortForwardingL(tunnel.getLPort(),
tunnel.getRHost(),
tunnel.getRPort());
}
- for (final Iterator i = remoteTunnels.iterator(); i.hasNext();) {
- final RemoteTunnel tunnel = (RemoteTunnel) i.next();
+ for (RemoteTunnel tunnel : remoteTunnels) {
session.setPortForwardingR(tunnel.getRPort(),
tunnel.getLHost(),
tunnel.getLPort());
}
- for (final Iterator i = nestedSequential.getNested().iterator();
- i.hasNext();) {
- final Task nestedTask = (Task) i.next();
- nestedTask.perform();
- }
+ nestedSequential.getNested().forEach(Task::perform);
// completed successfully
} catch (final JSchException e) {
if (e.getMessage().indexOf("session is down") >= 0) {
if (getFailonerror()) {
throw new BuildException(TIMEOUT_MESSAGE, e);
- } else {
- log(TIMEOUT_MESSAGE, Project.MSG_ERR);
}
+ log(TIMEOUT_MESSAGE, Project.MSG_ERR);
} else {
if (getFailonerror()) {
throw new BuildException(e);
- } else {
- log("Caught exception: " + e.getMessage(),
- Project.MSG_ERR);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
} catch (final BuildException e) {
// avoid wrapping it into yet another BuildException further down
@@ -197,9 +185,8 @@ public class SSHSession extends SSHBase {
} catch (final Exception e) {
if (getFailonerror()) {
throw new BuildException(e);
- } else {
- log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
} finally {
if (session != null && session.isConnected()) {
session.disconnect();
@@ -220,34 +207,44 @@ public class SSHSession extends SSHBase {
}
public class LocalTunnel {
- public LocalTunnel() {}
int lport = 0;
String rhost = null;
int rport = 0;
+
public void setLPort(final int lport) {
- final Integer portKey = new Integer(lport);
+ final Integer portKey = Integer.valueOf(lport);
if (localPortsUsed.contains(portKey)) {
- throw new BuildException("Multiple local tunnels defined to"
- + " use same local port " + lport);
+ throw new BuildException(
+ "Multiple local tunnels defined to use same local port %d",
+ lport);
}
localPortsUsed.add(portKey);
this.lport = lport;
}
- public void setRHost(final String rhost) { this.rhost = rhost; }
- public void setRPort(final int rport) { this.rport = rport; }
+
+ public void setRHost(final String rhost) {
+ this.rhost = rhost;
+ }
+
+ public void setRPort(final int rport) {
+ this.rport = rport;
+ }
+
public int getLPort() {
if (lport == 0) {
throw new BuildException("lport is required for LocalTunnel.");
}
return lport;
}
+
public String getRHost() {
if (rhost == null) {
throw new BuildException("rhost is required for LocalTunnel.");
}
return rhost;
}
+
public int getRPort() {
if (rport == 0) {
throw new BuildException("rport is required for LocalTunnel.");
@@ -257,34 +254,44 @@ public class SSHSession extends SSHBase {
}
public class RemoteTunnel {
- public RemoteTunnel() {}
int lport = 0;
String lhost = null;
int rport = 0;
- public void setLPort(final int lport) { this.lport = lport; }
- public void setLHost(final String lhost) { this.lhost = lhost; }
+
+ public void setLPort(final int lport) {
+ this.lport = lport;
+ }
+
+ public void setLHost(final String lhost) {
+ this.lhost = lhost;
+ }
+
public void setRPort(final int rport) {
- final Integer portKey = new Integer(rport);
+ final Integer portKey = Integer.valueOf(rport);
if (remotePortsUsed.contains(portKey)) {
- throw new BuildException("Multiple remote tunnels defined to"
- + " use same remote port " + rport);
+ throw new BuildException(
+ "Multiple remote tunnels defined to use same remote port %d",
+ rport);
}
remotePortsUsed.add(portKey);
this.rport = rport;
}
+
public int getLPort() {
if (lport == 0) {
throw new BuildException("lport is required for RemoteTunnel.");
}
return lport;
}
+
public String getLHost() {
if (lhost == null) {
throw new BuildException("lhost is required for RemoteTunnel.");
}
return lhost;
}
+
public int getRPort() {
if (rport == 0) {
throw new BuildException("rport is required for RemoteTunnel.");
@@ -311,13 +318,14 @@ public class SSHSession extends SSHBase {
* This is a simple task container.
*/
public static class NestedSequential implements TaskContainer {
- private final List<Task> nested = new ArrayList<Task>();
+ private final List<Task> nested = new ArrayList<>();
/**
* Add a task or type to the container.
*
* @param task an unknown element.
*/
+ @Override
public void addTask(final Task task) {
nested.add(task);
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java
index 54e7029..455d12b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java
@@ -35,8 +35,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
/** Constructor for SSHUserInfo. */
public SSHUserInfo() {
- super();
- this.trustAllCertificates = false;
+ this(null, false);
}
/**
@@ -71,6 +70,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* Gets the user's password.
* @return the user's password
*/
+ @Override
public String getPassword() {
return password;
}
@@ -135,6 +135,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* Returns the passphrase.
* @return String
*/
+ @Override
public String getPassphrase() {
return passphrase;
}
@@ -160,6 +161,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* @param message ignored
* @return true always
*/
+ @Override
public boolean promptPassphrase(String message) {
return true;
}
@@ -169,6 +171,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* @param passwordPrompt ignored
* @return true the first time this is called, false otherwise
*/
+ @Override
public boolean promptPassword(String passwordPrompt) {
return true;
}
@@ -178,6 +181,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* @param message ignored
* @return the value of trustAllCertificates
*/
+ @Override
public boolean promptYesNo(String message) {
return trustAllCertificates;
}
@@ -187,6 +191,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* Implement the UserInfo interface (noop).
* @param message ignored
*/
+ @Override
public void showMessage(String message) {
//log(message, Project.MSG_DEBUG);
}
@@ -201,6 +206,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
* @return the password in an size one array if there is a password
* and if the prompt and echo checks pass.
*/
+ @Override
public String[] promptKeyboardInteractive(String destination,
String name,
String instruction,
@@ -209,9 +215,7 @@ public class SSHUserInfo implements UserInfo, UIKeyboardInteractive {
if (prompt.length != 1 || echo[0] || this.password == null) {
return null;
}
- String[] response = new String[1];
- response[0] = this.password;
- return response;
+ return new String[] { this.password };
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
index 087a402..e68f38d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
@@ -21,9 +21,10 @@ package org.apache.tools.ant.taskdefs.optional.ssh;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
@@ -156,11 +157,9 @@ public class Scp extends SSHBase {
private static void validateRemoteUri(final String type, final String aToUri) {
if (!isRemoteUri(aToUri)) {
- throw new BuildException(type + " '" + aToUri + "' is invalid. "
- + "The 'remoteToDir' attribute must "
- + "have syntax like the "
- + "following: user:password@host:/path"
- + " - the :password part is optional");
+ throw new BuildException(
+ "%s '%s' is invalid. The 'remoteToDir' attribute must have syntax like the following: user:password@host:/path - the :password part is optional",
+ type, aToUri);
}
}
@@ -229,7 +228,7 @@ public class Scp extends SSHBase {
*/
public void add(ResourceCollection res) {
if (rcs == null) {
- rcs = new LinkedList<ResourceCollection>();
+ rcs = new LinkedList<>();
}
rcs.add(res);
}
@@ -271,24 +270,21 @@ public class Scp extends SSHBase {
throw new BuildException(
"Copying from a remote server to a remote server is not supported.");
} else {
- throw new BuildException("'todir' and 'file' attributes "
- + "must have syntax like the following: "
- + "user:password@host:/path");
+ throw new BuildException(
+ "'todir' and 'file' attributes must have syntax like the following: user:password@host:/path");
}
} catch (final Exception e) {
if (getFailonerror()) {
- if(e instanceof BuildException) {
+ if (e instanceof BuildException) {
final BuildException be = (BuildException) e;
- if(be.getLocation() == null) {
+ if (be.getLocation() == null) {
be.setLocation(getLocation());
}
throw be;
- } else {
- throw new BuildException(e);
}
- } else {
- log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
+ throw new BuildException(e);
}
+ log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
}
@@ -330,9 +326,8 @@ public class Scp extends SSHBase {
Session session = null;
try {
- final List<Directory> list = new ArrayList<Directory>(rcs.size());
- for (final Iterator<ResourceCollection> i = rcs.iterator(); i.hasNext();) {
- final ResourceCollection rc = (ResourceCollection) i.next();
+ final List<Directory> list = new ArrayList<>(rcs.size());
+ for (ResourceCollection rc : rcs) {
if (rc instanceof FileSet && rc.isFilesystemOnly()) {
FileSet fs = (FileSet) rc;
final Directory d = createDirectory(fs);
@@ -340,15 +335,15 @@ public class Scp extends SSHBase {
list.add(d);
}
} else {
- List<Directory> ds = createDirectoryCollection(rc);
- if (ds !=null) {
- list.addAll(ds);
- }
+ List<Directory> ds = createDirectoryCollection(rc);
+ if (ds != null) {
+ list.addAll(ds);
+ }
}
}
if (!list.isEmpty()) {
session = openSession();
- ScpToMessage message = null;
+ ScpToMessage message;
if (!isSftp) {
message = new ScpToMessage(getVerbose(), compressed, session,
list, file, preserveLastModified);
@@ -433,19 +428,19 @@ public class Scp extends SSHBase {
if (getUserInfo().getPassword() == null
&& getUserInfo().getKeyfile() == null) {
- throw new BuildException("neither password nor keyfile for user "
- + getUserInfo().getName() + " has been "
- + "given. Can't authenticate.");
+ throw new BuildException(
+ "neither password nor keyfile for user %s has been given. Can't authenticate.",
+ getUserInfo().getName());
}
final int indexOfPath = uri.indexOf(':', indexOfAt + 1);
if (indexOfPath == -1) {
- throw new BuildException("no remote path in " + uri);
+ throw new BuildException("no remote path in %s", uri);
}
setHost(uri.substring(indexOfAt + 1, indexOfPath));
String remotePath = uri.substring(indexOfPath + 1);
- if (remotePath.equals("")) {
+ if (remotePath.isEmpty()) {
remotePath = ".";
}
return remotePath;
@@ -462,28 +457,26 @@ public class Scp extends SSHBase {
private Directory createDirectory(final FileSet set) {
final DirectoryScanner scanner = set.getDirectoryScanner(getProject());
- Directory root = new Directory(scanner.getBasedir());
final String[] files = scanner.getIncludedFiles();
- if (files.length != 0) {
- for (int j = 0; j < files.length; j++) {
- final String[] path = Directory.getPath(files[j]);
- Directory current = root;
- File currentParent = scanner.getBasedir();
- for (int i = 0; i < path.length; i++) {
- final File file = new File(currentParent, path[i]);
- if (file.isDirectory()) {
- current.addDirectory(new Directory(file));
- current = current.getChild(file);
- currentParent = current.getDirectory();
- } else if (file.isFile()) {
- current.addFile(file);
- }
- }
- }
- } else {
+ if (files.length == 0) {
// skip
- root = null;
+ return null;
}
+ Directory root = new Directory(scanner.getBasedir());
+ Stream.of(files).map(Directory::getPath).forEach(path -> {
+ Directory current = root;
+ File currentParent = scanner.getBasedir();
+ for (String element : path) {
+ final File file = new File(currentParent, element);
+ if (file.isDirectory()) {
+ current.addDirectory(new Directory(file));
+ current = current.getChild(file);
+ currentParent = current.getDirectory();
+ } else if (file.isFile()) {
+ current.addFile(file);
+ }
+ }
+ });
return root;
}
@@ -493,21 +486,24 @@ public class Scp extends SSHBase {
throw new BuildException("Only FileSystem resources are supported.");
}
- List<Directory> ds = new ArrayList<Directory>();
+ List<Directory> ds = new ArrayList<>();
for (Resource r : rc) {
if (!r.isExists()) {
- throw new BuildException("Could not find resource " + r.toLongString() + " to scp.");
+ throw new BuildException("Could not find resource %s to scp.",
+ r.toLongString());
}
FileProvider fp = r.as(FileProvider.class);
if (fp == null) {
- throw new BuildException("Resource " + r.toLongString() + " is not a file.");
+ throw new BuildException("Resource %s is not a file.",
+ r.toLongString());
}
FileResource fr = ResourceUtils.asFileResource(fp);
File baseDir = fr.getBaseDir();
if (baseDir == null) {
- throw new BuildException("basedir for resource " + r.toLongString() + " is undefined.");
+ throw new BuildException(
+ "basedir for resource %s is undefined.", r.toLongString());
}
// if the basedir is set, the name will be relative to that
@@ -515,9 +511,8 @@ public class Scp extends SSHBase {
Directory root = new Directory(baseDir);
Directory current = root;
File currentParent = baseDir;
- final String[] path = Directory.getPath(name);
- for (int i = 0; i < path.length; i++) {
- final File file = new File(currentParent, path[i]);
+ for (String element : Directory.getPath(name)) {
+ final File file = new File(currentParent, element);
if (file.isDirectory()) {
current.addDirectory(new Directory(file));
current = current.getChild(file);
@@ -527,7 +522,7 @@ public class Scp extends SSHBase {
}
}
ds.add(root);
- }
+ }
return ds;
}
@@ -550,15 +545,8 @@ public class Scp extends SSHBase {
}
private BuildException exactlyOne(final String[] attrs, final String alt) {
- final StringBuffer buf = new StringBuffer("Exactly one of ").append(
- '[').append(attrs[0]);
- for (int i = 1; i < attrs.length; i++) {
- buf.append('|').append(attrs[i]);
- }
- buf.append(']');
- if (alt != null) {
- buf.append(" or ").append(alt);
- }
- return new BuildException(buf.append(" is required.").toString());
+ return new BuildException("Exactly one of [%s]%s is required",
+ Stream.of(attrs).collect(Collectors.joining("|")),
+ alt == null ? "" : " or " + alt);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java
index 8775c11..1ffb5bd 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java
@@ -149,6 +149,7 @@ public class ScpFromMessage extends AbstractSshMessage {
* @throws IOException on i/o errors
* @throws JSchException on errors detected by scp
*/
+ @Override
public void execute() throws IOException, JSchException {
String command = "scp -f ";
if (isRecursive) {
@@ -220,9 +221,9 @@ public class ScpFromMessage extends AbstractSshMessage {
private File parseAndCreateDirectory(final String serverResponse,
final File localFile) {
- int start = serverResponse.indexOf(" ");
+ int start = serverResponse.indexOf(' ');
// appears that the next token is not used and it's zero.
- start = serverResponse.indexOf(" ", start + 1);
+ start = serverResponse.indexOf(' ', start + 1);
final String directoryName = serverResponse.substring(start + 1);
if (localFile.isDirectory()) {
final File dir = new File(localFile, directoryName);
@@ -239,13 +240,13 @@ public class ScpFromMessage extends AbstractSshMessage {
final InputStream in)
throws IOException, JSchException {
int start = 0;
- int end = serverResponse.indexOf(" ", start + 1);
+ int end = serverResponse.indexOf(' ', start + 1);
start = end + 1;
- end = serverResponse.indexOf(" ", start + 1);
+ end = serverResponse.indexOf(' ', start + 1);
final long filesize = Long.parseLong(serverResponse.substring(start, end));
final String filename = serverResponse.substring(end + 1);
log("Receiving: " + filename + " : " + filesize);
- final File transferFile = (localFile.isDirectory())
+ final File transferFile = localFile.isDirectory()
? new File(localFile, filename)
: localFile;
fetchFile(transferFile, filesize, out, in);
@@ -277,7 +278,7 @@ public class ScpFromMessage extends AbstractSshMessage {
try {
while (true) {
length = in.read(buf, 0,
- (BUFFER_SIZE < filesize) ? BUFFER_SIZE
+ BUFFER_SIZE < filesize ? BUFFER_SIZE
: (int) filesize);
if (length < 0) {
throw new EOFException("Unexpected end of stream.");
@@ -327,10 +328,10 @@ public class ScpFromMessage extends AbstractSshMessage {
* returns the directory part of the remote file, if any.
*/
private static String remoteDir(final String remoteFile) {
- int index = remoteFile.lastIndexOf("/");
+ int index = remoteFile.lastIndexOf('/');
if (index < 0) {
- index = remoteFile.lastIndexOf("\\");
+ index = remoteFile.lastIndexOf('\\');
}
- return index > -1 ? remoteFile.substring(0, index + 1) : "";
+ return index < 0 ? "" : remoteFile.substring(0, index + 1);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
index 04f72d2..886d06d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
@@ -20,7 +20,7 @@ package org.apache.tools.ant.taskdefs.optional.ssh;
import java.io.File;
import java.io.IOException;
-
+import java.util.List;
import org.apache.tools.ant.util.FileUtils;
import com.jcraft.jsch.ChannelSftp;
@@ -103,6 +103,7 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
* @throws IOException on i/o errors
* @throws JSchException on errors detected by scp
*/
+ @Override
public void execute() throws IOException, JSchException {
final ChannelSftp channel = openSftpChannel();
try {
@@ -117,9 +118,9 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
}
getDir(channel, remoteFile, localFile);
} catch (final SftpException e) {
- final JSchException schException = new JSchException("Could not get '"+ remoteFile
- +"' to '"+localFile+"' - "
- +e.toString());
+ final JSchException schException =
+ new JSchException("Could not get '" + remoteFile + "' to '"
+ + localFile + "' - " + e.toString());
schException.initCause(e);
throw schException;
} finally {
@@ -143,13 +144,12 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
if (!localFile.exists()) {
localFile.mkdirs();
}
- final java.util.Vector files = channel.ls(remoteFile);
- final int size = files.size();
- for (int i = 0; i < size; i++) {
- final ChannelSftp.LsEntry le = (ChannelSftp.LsEntry) files.elementAt(i);
+ @SuppressWarnings("unchecked")
+ final List<ChannelSftp.LsEntry> files = channel.ls(remoteFile);
+ for (ChannelSftp.LsEntry le : files) {
final String name = le.getFilename();
if (le.getAttrs().isDir()) {
- if (name.equals(".") || name.equals("..")) {
+ if (".".equals(name) || "..".equals(name)) {
continue;
}
getDir(channel,
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java
index 214dd4e..67424f4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java
@@ -42,7 +42,7 @@ public class ScpToMessage extends AbstractSshMessage {
private File localFile;
private String remotePath;
- private List directoryList;
+ private List<Directory> directoryList;
private Integer fileMode, dirMode;
private boolean preserveLastModified;
@@ -124,7 +124,7 @@ public class ScpToMessage extends AbstractSshMessage {
*/
public ScpToMessage(final boolean verbose,
final Session session,
- final List aDirectoryList,
+ final List<Directory> aDirectoryList,
final String aRemotePath,
final boolean preserveLastModified) {
this(verbose, false, session, aDirectoryList, aRemotePath, preserveLastModified);
@@ -143,7 +143,7 @@ public class ScpToMessage extends AbstractSshMessage {
public ScpToMessage(final boolean verbose,
final boolean compressed,
final Session session,
- final List aDirectoryList,
+ final List<Directory> aDirectoryList,
final String aRemotePath,
final boolean preserveLastModified) {
this(verbose, compressed, session, aRemotePath);
@@ -176,7 +176,7 @@ public class ScpToMessage extends AbstractSshMessage {
*/
public ScpToMessage(final boolean verbose,
final Session session,
- final List aDirectoryList,
+ final List<Directory> aDirectoryList,
final String aRemotePath) {
this(verbose, session, aDirectoryList, aRemotePath, false);
}
@@ -184,19 +184,6 @@ public class ScpToMessage extends AbstractSshMessage {
/**
* Constructor for ScpToMessage.
* @param verbose if true do verbose logging
- * @param session the scp session to use
- * @param aRemotePath the remote path
- * @since Ant 1.6.2
- */
- private ScpToMessage(final boolean verbose,
- final Session session,
- final String aRemotePath) {
- this(verbose, false, session, aRemotePath);
- }
-
- /**
- * Constructor for ScpToMessage.
- * @param verbose if true do verbose logging
* @param compressed if true use compression
* @param session the scp session to use
* @param aRemotePath the remote path
@@ -229,7 +216,7 @@ public class ScpToMessage extends AbstractSshMessage {
* @param aRemotePath the remote path
*/
public ScpToMessage(final Session session,
- final List aDirectoryList,
+ final List<Directory> aDirectoryList,
final String aRemotePath) {
this(false, session, aDirectoryList, aRemotePath);
}
@@ -262,7 +249,6 @@ public class ScpToMessage extends AbstractSshMessage {
final String cmd = sb.toString();
final Channel channel = openExecChannel(cmd);
try {
-
final OutputStream out = channel.getOutputStream();
final InputStream in = channel.getInputStream();
@@ -294,8 +280,7 @@ public class ScpToMessage extends AbstractSshMessage {
channel.connect();
waitForAck(in);
- for (final Iterator i = directoryList.iterator(); i.hasNext();) {
- final Directory current = (Directory) i.next();
+ for (Directory current : directoryList) {
sendDirectory(current, in, out);
}
} finally {
@@ -308,12 +293,11 @@ public class ScpToMessage extends AbstractSshMessage {
private void sendDirectory(final Directory current,
final InputStream in,
final OutputStream out) throws IOException {
- for (final Iterator fileIt = current.filesIterator(); fileIt.hasNext();) {
- sendFileToRemote((File) fileIt.next(), in, out);
+ for (final Iterator<File> fileIt = current.filesIterator(); fileIt.hasNext();) {
+ sendFileToRemote(fileIt.next(), in, out);
}
- for (final Iterator dirIt = current.directoryIterator(); dirIt.hasNext();) {
- final Directory dir = (Directory) dirIt.next();
- sendDirectoryToRemote(dir, in, out);
+ for (final Iterator<Directory> dirIt = current.directoryIterator(); dirIt.hasNext();) {
+ sendDirectoryToRemote(dirIt.next(), in, out);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java
index 2b32907..dc8f2f1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java
@@ -38,7 +38,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
private File localFile;
private final String remotePath;
- private List directoryList;
+ private List<Directory> directoryList;
/**
* Constructor for a local file to remote.
@@ -67,7 +67,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
*/
public ScpToMessageBySftp(final boolean verbose,
final Session session,
- final List aDirectoryList,
+ final List<Directory> aDirectoryList,
final String aRemotePath) {
this(verbose, session, aRemotePath);
@@ -107,7 +107,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
* @param aRemotePath the remote path
*/
public ScpToMessageBySftp(final Session session,
- final List aDirectoryList,
+ final List<Directory> aDirectoryList,
final String aRemotePath) {
this(false, session, aDirectoryList, aRemotePath);
}
@@ -171,21 +171,19 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
throw new JSchException("Could not CD to '" + remotePath
+ "' - " + e.toString(), e);
}
- Directory current = null;
- try {
- for (final Iterator i = directoryList.iterator(); i.hasNext();) {
- current = (Directory) i.next();
+ for (Directory current : directoryList) {
+ try {
if (getVerbose()) {
log("Sending directory " + current);
}
sendDirectory(channel, current);
+ } catch (final SftpException e) {
+ String msg = "Error sending directory";
+ if (current != null && current.getDirectory() != null) {
+ msg += " '" + current.getDirectory().getName() + "'";
+ }
+ throw new JSchException(msg, e);
}
- } catch (final SftpException e) {
- String msg = "Error sending directory";
- if (current != null && current.getDirectory() != null) {
- msg += " '" + current.getDirectory().getName() + "'";
- }
- throw new JSchException(msg, e);
}
} finally {
if (channel != null) {
@@ -197,12 +195,11 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
private void sendDirectory(final ChannelSftp channel,
final Directory current)
throws IOException, SftpException {
- for (final Iterator fileIt = current.filesIterator(); fileIt.hasNext();) {
- sendFileToRemote(channel, (File) fileIt.next(), null);
+ for (final Iterator<File> fileIt = current.filesIterator(); fileIt.hasNext();) {
+ sendFileToRemote(channel, fileIt.next(), null);
}
- for (final Iterator dirIt = current.directoryIterator(); dirIt.hasNext();) {
- final Directory dir = (Directory) dirIt.next();
- sendDirectoryToRemote(channel, dir);
+ for (final Iterator<Directory> dirIt = current.directoryIterator(); dirIt.hasNext();) {
+ sendDirectoryToRemote(channel, dirIt.next());
}
}
@@ -263,6 +260,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
* Get the local file.
* @return the local file.
*/
+ @Override
public File getLocalFile() {
return localFile;
}
@@ -271,6 +269,7 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ {
* Get the remote path.
* @return the remote path.
*/
+ @Override
public String getRemotePath() {
return remotePath;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/testing/BlockFor.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/testing/BlockFor.java b/src/main/org/apache/tools/ant/taskdefs/optional/testing/BlockFor.java
index 4b2978a..9d8338e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/testing/BlockFor.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/testing/BlockFor.java
@@ -54,6 +54,7 @@ public class BlockFor extends WaitFor {
* @throws BuildTimeoutException on timeout, using the text in {@link #text}
*
*/
+ @Override
protected void processTimeout() throws BuildTimeoutException {
super.processTimeout();
throw new BuildTimeoutException(text, getLocation());
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java b/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java
index 2eb357a..a7eb85f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java
@@ -58,6 +58,19 @@ import org.apache.tools.ant.util.WorkerAnt;
*/
public class Funtest extends Task {
+ /** {@value} */
+ public static final String WARN_OVERRIDING = "Overriding previous definition of ";
+ /** {@value} */
+ public static final String APPLICATION_FORCIBLY_SHUT_DOWN = "Application forcibly shut down";
+ /** {@value} */
+ public static final String SHUTDOWN_INTERRUPTED = "Shutdown interrupted";
+ /** {@value} */
+ public static final String SKIPPING_TESTS
+ = "Condition failed -skipping tests";
+ /** Application exception : {@value} */
+ public static final String APPLICATION_EXCEPTION = "Application Exception";
+ /** Teardown exception : {@value} */
+ public static final String TEARDOWN_EXCEPTION = "Teardown Exception";
/**
* A condition that must be true before the tests are run. This makes it
@@ -158,20 +171,6 @@ public class Funtest extends Task {
*/
private BuildException taskException;
- /** {@value} */
- public static final String WARN_OVERRIDING = "Overriding previous definition of ";
- /** {@value} */
- public static final String APPLICATION_FORCIBLY_SHUT_DOWN = "Application forcibly shut down";
- /** {@value} */
- public static final String SHUTDOWN_INTERRUPTED = "Shutdown interrupted";
- /** {@value} */
- public static final String SKIPPING_TESTS
- = "Condition failed -skipping tests";
- /** Application exception : {@value} */
- public static final String APPLICATION_EXCEPTION = "Application Exception";
- /** Teardown exception : {@value} */
- public static final String TEARDOWN_EXCEPTION = "Teardown Exception";
-
/**
* Log if the definition is overriding something
*
@@ -378,8 +377,9 @@ public class Funtest extends Task {
* @param role role of the task
*/
private void validateTask(Task task, String role) {
- if (task!=null && task.getProject() == null) {
- throw new BuildException(role + " task is not bound to the project" + task);
+ if (task != null && task.getProject() == null) {
+ throw new BuildException("%s task is not bound to the project %s",
+ role, task);
}
}
@@ -392,6 +392,7 @@ public class Funtest extends Task {
* test failing that is more important.
* @throws BuildException if something was caught during the run or teardown.
*/
+ @Override
public void execute() throws BuildException {
//validation
@@ -566,12 +567,13 @@ public class Funtest extends Task {
}
private static class NestedCondition extends ConditionBase implements Condition {
+ @Override
public boolean eval() {
if (countConditions() != 1) {
throw new BuildException(
"A single nested condition is required.");
}
- return ((Condition) (getConditions().nextElement())).eval();
+ return getConditions().nextElement().eval();
}
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
index d3385e6..baced9e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
@@ -69,6 +69,7 @@ public abstract class AbstractAccessTask
* @ant.attribute ignore="true"
* @param cmdl A user supplied command line that we won't accept.
*/
+ @Override
public void setCommand(Commandline cmdl) {
throw new BuildException(getTaskType()
+ " doesn\'t support the command attribute",
@@ -81,6 +82,7 @@ public abstract class AbstractAccessTask
* @ant.attribute ignore="true"
* @param skip A user supplied boolean we won't accept.
*/
+ @Override
public void setSkipEmptyFilesets(boolean skip) {
throw new BuildException(getTaskType() + " doesn\'t support the "
+ "skipemptyfileset attribute",
@@ -93,6 +95,7 @@ public abstract class AbstractAccessTask
* @ant.attribute ignore="true"
* @param b A user supplied boolean we won't accept.
*/
+ @Override
public void setAddsourcefile(boolean b) {
throw new BuildException(getTaskType()
+ " doesn\'t support the addsourcefile attribute", getLocation());
@@ -103,6 +106,7 @@ public abstract class AbstractAccessTask
* @return true if a valid OS, for unix this is always true, otherwise
* use the superclasses' test (user set).
*/
+ @Override
protected boolean isValidOs() {
return getOs() == null && getOsFamily() == null
? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java
index 1279a2c..ecf819b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java
@@ -63,6 +63,7 @@ public class Chgrp extends AbstractAccessTask {
* Ensure that all the required arguments and other conditions have
* been set.
*/
+ @Override
protected void checkConfiguration() {
if (!haveGroup) {
throw new BuildException("Required attribute group not set in "
@@ -76,6 +77,7 @@ public class Chgrp extends AbstractAccessTask {
*
* @param e User supplied executable that we won't accept.
*/
+ @Override
public void setExecutable(String e) {
throw new BuildException(getTaskType()
+ " doesn\'t support the executable"
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chown.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chown.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chown.java
index 53f7253..cd827e6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chown.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chown.java
@@ -63,6 +63,7 @@ public class Chown extends AbstractAccessTask {
* Ensure that all the required arguments and other conditions have
* been set.
*/
+ @Override
protected void checkConfiguration() {
if (!haveOwner) {
throw new BuildException("Required attribute owner not set in"
@@ -76,6 +77,7 @@ public class Chown extends AbstractAccessTask {
*
* @param e User supplied executable that we won't accept.
*/
+ @Override
public void setExecutable(String e) {
throw new BuildException(getTaskType()
+ " doesn\'t support the executable"