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:11 UTC

[11/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/net/FTPTaskMirrorImpl.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 35f01b3..f546b23 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -28,14 +28,16 @@ import java.io.OutputStream;
 import java.nio.file.Files;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.Vector;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
 
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPFile;
@@ -65,7 +67,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
     private final FTPTask task;
-    private Set dirCache = new HashSet();
+    private Set<File> dirCache = new HashSet<>();
     private int transferred = 0;
     private int skipped = 0;
 
@@ -83,6 +85,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
      *
      */
     protected static class FTPFileProxy extends File {
+        private static final long serialVersionUID = 1L;
 
         private final FTPFile file;
         private final String[] parts;
@@ -110,34 +113,34 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             parts = FileUtils.getPathStack(completePath);
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#exists()
          */
+        @Override
         public boolean exists() {
             return true;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#getAbsolutePath()
          */
+        @Override
         public String getAbsolutePath() {
             return name;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#getName()
          */
+        @Override
         public String getName() {
             return parts.length > 0 ? parts[parts.length - 1] : name;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#getParent()
          */
+        @Override
         public String getParent() {
             String result = "";
             for(int i = 0; i < parts.length - 1; i++){
@@ -146,53 +149,53 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             return result;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#getPath()
          */
+        @Override
         public String getPath() {
             return name;
         }
 
-
         /**
          * FTP files are stored as absolute paths
          * @return true
          */
+        @Override
         public boolean isAbsolute() {
             return true;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#isDirectory()
          */
+        @Override
         public boolean isDirectory() {
             return file == null;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#isFile()
          */
+        @Override
         public boolean isFile() {
             return file != null;
         }
 
-
         /**
          * FTP files cannot be hidden
          *
          * @return  false
          */
+        @Override
         public boolean isHidden() {
             return false;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#lastModified()
          */
+        @Override
         public long lastModified() {
             if (file != null) {
                 return file.getTimestamp().getTimeInMillis();
@@ -200,10 +203,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             return 0;
         }
 
-
         /* (non-Javadoc)
          * @see java.io.File#length()
          */
+        @Override
         public long length() {
             if (file != null) {
                 return file.getSize();
@@ -244,11 +247,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             this.setFollowSymlinks(false);
         }
 
-
         /**
          * scans the remote directory,
          * storing internally the included files, directories, ...
          */
+        @Override
         public void scan() {
             if (includes == null) {
                 // No includes supplied, so set it to 'matches all'
@@ -259,12 +262,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 excludes = new String[0];
             }
 
-            filesIncluded = new VectorSet();
-            filesNotIncluded = new Vector();
-            filesExcluded = new VectorSet();
-            dirsIncluded = new VectorSet();
-            dirsNotIncluded = new Vector();
-            dirsExcluded = new VectorSet();
+            filesIncluded = new VectorSet<>();
+            filesNotIncluded = new Vector<>();
+            filesExcluded = new VectorSet<>();
+            dirsIncluded = new VectorSet<>();
+            dirsNotIncluded = new Vector<>();
+            dirsExcluded = new VectorSet<>();
 
             try {
                 String cwd = ftp.printWorkingDirectory();
@@ -279,7 +282,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             }
         }
 
-
         /**
          * this routine is actually checking all the include patterns in
          * order to avoid scanning everything under base dir
@@ -287,7 +289,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
          */
         private void checkIncludePatterns() {
 
-            Hashtable newroots = new Hashtable();
+            Map<String, String> newroots = new Hashtable<>();
             // put in the newroots vector the include patterns without
             // wildcard tokens
             for (int icounter = 0; icounter < includes.length; icounter++) {
@@ -312,75 +314,73 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             } else {
                 // only scan directories that can include matched files or
                 // directories
-                Enumeration enum2 = newroots.keys();
-
-                while (enum2.hasMoreElements()) {
-                    String currentelement = (String) enum2.nextElement();
-                    String originalpattern = (String) newroots.get(currentelement);
-                    AntFTPFile myfile = new AntFTPFile(baseFTPFile, currentelement);
-                    boolean isOK = true;
-                    boolean traversesSymlinks = false;
-                    String path = null;
-
-                    if (myfile.exists()) {
-                        forceRemoteSensitivityCheck();
-                        if (remoteSensitivityChecked
-                            && remoteSystemCaseSensitive && isFollowSymlinks()) {
-                            // cool case,
-                            //we do not need to scan all the subdirs in the relative path
-                            path = myfile.getFastRelativePath();
-                        } else {
-                            // may be on a case insensitive file system.  We want
-                            // the results to show what's really on the disk, so
-                            // we need to double check.
-                            try {
-                                path = myfile.getRelativePath();
-                                traversesSymlinks = myfile.isTraverseSymlinks();
-                            }  catch (IOException be) {
-                                throw new BuildException(be, task.getLocation());
-                            } catch (BuildException be) {
-                                isOK = false;
-                            }
-                        }
-                    } else {
+                newroots.forEach(
+                    (k, v) -> scanRoot(new AntFTPFile(baseFTPFile, k), v));
+            }
+        }
+
+        private void scanRoot(AntFTPFile myfile, String originalpattern) {
+            String currentelement;
+            boolean isOK = true;
+            boolean traversesSymlinks = false;
+            String path = null;
+
+            if (myfile.exists()) {
+                forceRemoteSensitivityCheck();
+                if (remoteSensitivityChecked
+                    && remoteSystemCaseSensitive && isFollowSymlinks()) {
+                    // cool case,
+                    //we do not need to scan all the subdirs in the relative path
+                    path = myfile.getFastRelativePath();
+                } else {
+                    // may be on a case insensitive file system.  We want
+                    // the results to show what's really on the disk, so
+                    // we need to double check.
+                    try {
+                        path = myfile.getRelativePath();
+                        traversesSymlinks = myfile.isTraverseSymlinks();
+                    }  catch (IOException be) {
+                        throw new BuildException(be, task.getLocation());
+                    } catch (BuildException be) {
                         isOK = false;
                     }
-                    if (isOK) {
-                        currentelement = path.replace(task.getSeparator().charAt(0), File.separatorChar);
-                        if (!isFollowSymlinks()
-                            && traversesSymlinks) {
-                            continue;
-                        }
+                }
+            } else {
+                isOK = false;
+            }
+            if (isOK) {
+                currentelement = path.replace(task.getSeparator().charAt(0), File.separatorChar);
+                if (!isFollowSymlinks()
+                    && traversesSymlinks) {
+                    return;
+                }
 
-                        if (myfile.isDirectory()) {
-                            if (isIncluded(currentelement)
-                                && currentelement.length() > 0) {
-                                accountForIncludedDir(currentelement, myfile, true);
-                            }  else {
-                                if (currentelement.length() > 0) {
-                                    if (currentelement.charAt(currentelement
-                                                              .length() - 1)
-                                        != File.separatorChar) {
-                                        currentelement =
-                                            currentelement + File.separatorChar;
-                                    }
-                                }
-                                scandir(myfile.getAbsolutePath(), currentelement, true);
-                            }
-                        } else {
-                            if (isCaseSensitive
-                                && originalpattern.equals(currentelement)) {
-                                accountForIncludedFile(currentelement);
-                            } else if (!isCaseSensitive
-                                       && originalpattern
-                                       .equalsIgnoreCase(currentelement)) {
-                                accountForIncludedFile(currentelement);
+                if (myfile.isDirectory()) {
+                    if (isIncluded(currentelement)
+                        && currentelement.length() > 0) {
+                        accountForIncludedDir(currentelement, myfile, true);
+                    }  else {
+                        if (currentelement.length() > 0) {
+                            if (currentelement.charAt(currentelement
+                                                      .length() - 1)
+                                != File.separatorChar) {
+                                currentelement =
+                                    currentelement + File.separatorChar;
                             }
                         }
+                        scandir(myfile.getAbsolutePath(), currentelement, true);
                     }
+                } else if (isCaseSensitive
+                    && originalpattern.equals(currentelement)) {
+                    accountForIncludedFile(currentelement);
+                } else if (!isCaseSensitive
+                           && originalpattern
+                           .equalsIgnoreCase(currentelement)) {
+                    accountForIncludedFile(currentelement);
                 }
             }
         }
+
         /**
          * scans a particular directory. populates the scannedDirs cache.
          *
@@ -398,8 +398,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 if (!ftp.changeWorkingDirectory(dir)) {
                     return;
                 }
-                String completePath = null;
-                if (!vpath.equals("")) {
+                String completePath;
+                if (!"".equals(vpath)) {
                     completePath = rootPath + task.getSeparator()
                         + vpath.replace(File.separatorChar, task.getSeparator().charAt(0));
                 } else {
@@ -414,8 +414,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 for (int i = 0; i < newfiles.length; i++) {
                     FTPFile file = newfiles[i];
                     if (file != null
-                        && !file.getName().equals(".")
-                        && !file.getName().equals("..")) {
+                        && !".".equals(file.getName())
+                        && !"..".equals(file.getName())) {
                         String name = vpath + file.getName();
                         scannedDirs.put(name, new FTPFileProxy(file));
                         if (isFunctioningAsDirectory(ftp, dir, file)) {
@@ -462,7 +462,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
 
                 if (isIncluded(name)) {
                     if (!isExcluded(name)
-                        && isSelected(name, (File) scannedDirs.get(name))) {
+                        && isSelected(name, scannedDirs.get(name))) {
                         filesIncluded.addElement(name);
                     } else {
                         filesExcluded.addElement(name);
@@ -519,19 +519,21 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 }
             }
         }
+
         /**
          * temporary table to speed up the various scanning methods below
          *
          * @since Ant 1.6
          */
-        private Map fileListMap = new HashMap();
+        private Map<String, FTPFile[]> fileListMap = new HashMap<>();
+
         /**
          * List of all scanned directories.
          *
          * @since Ant 1.6
          */
 
-        private Map scannedDirs = new HashMap();
+        private Map<String, FTPFileProxy> scannedDirs = new HashMap<>();
 
         /**
          * Has the directory with the given path relative to the base
@@ -552,6 +554,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             fileListMap.clear();
             scannedDirs.clear();
         }
+
         /**
          * list the files present in one directory.
          * @param directory full path on the remote side
@@ -563,8 +566,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             String currentPath = directory;
             if (changedir) {
                 try {
-                    boolean result = ftp.changeWorkingDirectory(directory);
-                    if (!result) {
+                    if (!ftp.changeWorkingDirectory(directory)) {
                         return null;
                     }
                     currentPath = ftp.printWorkingDirectory();
@@ -574,9 +576,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             }
             if (fileListMap.containsKey(currentPath)) {
                 task.log("filelist map used in listing files", Project.MSG_DEBUG);
-                return ((FTPFile[]) fileListMap.get(currentPath));
+                return fileListMap.get(currentPath);
             }
-            FTPFile[] result = null;
+            FTPFile[] result;
             try {
                 result = ftp.listFiles();
             } catch (IOException ioe) {
@@ -598,6 +600,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 }
             }
         }
+
         /**
          * cd into one directory and
          * list the files present in one directory.
@@ -607,6 +610,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         public FTPFile[] listFiles(String directory) {
             return listFiles(directory, true);
         }
+
         private void checkRemoteSensitivity(FTPFile[] array, String directory) {
             if (array == null) {
                 return;
@@ -615,8 +619,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             String target = null;
             for (int icounter = 0; icounter < array.length; icounter++) {
                 if (array[icounter] != null && array[icounter].isDirectory()) {
-                    if (!array[icounter].getName().equals(".")
-                        && !array[icounter].getName().equals("..")) {
+                    if (!".".equals(array[icounter].getName())
+                        && !"..".equals(array[icounter].getName())) {
                         candidateFound = true;
                         target = fiddleName(array[icounter].getName());
                         task.log("will try to cd to "
@@ -656,8 +660,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 remoteSensitivityChecked = true;
             }
         }
+
         private String fiddleName(String origin) {
-            StringBuffer result = new StringBuffer();
+            StringBuilder result = new StringBuilder();
             for (int icounter = 0; icounter < origin.length(); icounter++) {
                 if (Character.isLowerCase(origin.charAt(icounter))) {
                     result.append(Character.toUpperCase(origin.charAt(icounter)));
@@ -669,6 +674,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             }
             return result.toString();
         }
+
         /**
          * an AntFTPFile is a representation of a remote file
          * @since Ant 1.6
@@ -693,6 +699,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             private boolean relativePathCalculated = false;
             private boolean traversesSymlinks = false;
             private String relativePath = "";
+
             /**
              * constructor
              * @param client ftp client variable
@@ -704,6 +711,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 this.ftpFile = ftpFile;
                 this.curpwd = curpwd;
             }
+
             /**
              * other constructor
              * @param parent the parent file
@@ -712,7 +720,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public AntFTPFile(AntFTPFile parent, String path) {
                 this.parent = parent;
                 this.client = parent.client;
-                Vector pathElements = SelectorUtils.tokenizePath(path);
+                List<String> pathElements = SelectorUtils.tokenizePath(path);
                 try {
                     boolean result = this.client.changeWorkingDirectory(parent.getAbsolutePath());
                     //this should not happen, except if parent has been deleted by another process
@@ -721,35 +729,35 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     }
                     this.curpwd = parent.getAbsolutePath();
                 } catch (IOException ioe) {
-                    throw new BuildException("could not change working dir to "
-                                             + parent.curpwd);
+                    throw new BuildException(
+                        "could not change working dir to %s", parent.curpwd);
                 }
                 final int size = pathElements.size();
                 for (int fcount = 0; fcount < size - 1; fcount++) {
-                    String currentPathElement = (String) pathElements.elementAt(fcount);
+                    String currentPathElement = pathElements.get(fcount);
                     try {
-                        boolean result = this.client.changeWorkingDirectory(currentPathElement);
-                        if (!result && !isCaseSensitive()
-                            && (remoteSystemCaseSensitive || !remoteSensitivityChecked)) {
-                            currentPathElement = findPathElementCaseUnsensitive(this.curpwd,
-                                                                                currentPathElement);
-                            if (currentPathElement == null) {
-                                return;
+                        if (!this.client.changeWorkingDirectory(currentPathElement)) {
+                            if (!isCaseSensitive() && (remoteSystemCaseSensitive
+                                || !remoteSensitivityChecked)) {
+                                currentPathElement =
+                                    findPathElementCaseUnsensitive(this.curpwd,
+                                        currentPathElement);
+                                if (currentPathElement == null) {
+                                    return;
+                                }
                             }
-                        } else if (!result) {
                             return;
                         }
-                        this.curpwd = getCurpwdPlusFileSep()
-                            + currentPathElement;
+                        this.curpwd =
+                            getCurpwdPlusFileSep() + currentPathElement;
                     } catch (IOException ioe) {
-                        throw new BuildException("could not change working dir to "
-                                                 + (String) pathElements.elementAt(fcount)
-                                                 + " from " + this.curpwd);
+                        throw new BuildException(
+                            "could not change working dir to %s from %s",
+                            currentPathElement, this.curpwd);
                     }
-
                 }
-                String lastpathelement = (String) pathElements.elementAt(size - 1);
-                FTPFile [] theFiles = listFiles(this.curpwd);
+                String lastpathelement = pathElements.get(size - 1);
+                FTPFile[] theFiles = listFiles(this.curpwd);
                 this.ftpFile = getFile(theFiles, lastpathelement);
             }
             /**
@@ -766,10 +774,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 if (theFiles == null) {
                     return null;
                 }
-                for (int icounter = 0; icounter < theFiles.length; icounter++) {
-                    if (theFiles[icounter] != null
-                        && theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement)) {
-                        return theFiles[icounter].getName();
+                for (FTPFile f : theFiles) {
+                    if (f != null
+                        && f.getName().equalsIgnoreCase(soughtPathElement)) {
+                        return f.getName();
                     }
                 }
                 return null;
@@ -779,8 +787,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
              * @return  true if the file exists
              */
             public boolean exists() {
-                return (ftpFile != null);
+                return ftpFile != null;
             }
+
             /**
              * if the file is a symbolic link, find out to what it is pointing
              * @return the target of the symbolic link
@@ -788,6 +797,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public String getLink() {
                 return ftpFile.getLink();
             }
+
             /**
              * get the name of the file
              * @return the name of the file
@@ -795,6 +805,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public String getName() {
                 return ftpFile.getName();
             }
+
             /**
              * find out the absolute path of the file
              * @return absolute path as string
@@ -802,6 +813,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public String getAbsolutePath() {
                 return getCurpwdPlusFileSep() + ftpFile.getName();
             }
+
             /**
              * find out the relative path assuming that the path used to construct
              * this AntFTPFile was spelled properly with regards to case.
@@ -816,6 +828,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 }
                 return null;
             }
+
             /**
              * find out the relative path to the rootPath of the enclosing scanner.
              * this relative path is spelled exactly like on disk,
@@ -842,6 +855,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 }
                 return relativePath;
             }
+
             /**
              * get the relative path of this file
              * @param currentPath          base path
@@ -849,19 +863,20 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
              * @return relative path
              */
             private String getRelativePath(String currentPath, String currentRelativePath) {
-                Vector pathElements = SelectorUtils.tokenizePath(getAbsolutePath(), task.getSeparator());
-                Vector pathElements2 = SelectorUtils.tokenizePath(currentPath,
-                                                                  task.getSeparator());
+                List<String> pathElements = SelectorUtils
+                    .tokenizePath(getAbsolutePath(), task.getSeparator());
+                List<String> pathElements2 = SelectorUtils
+                    .tokenizePath(currentPath, task.getSeparator());
                 String relPath = currentRelativePath;
                 final int size = pathElements.size();
                 for (int pcount = pathElements2.size(); pcount < size; pcount++) {
-                    String currentElement = (String) pathElements.elementAt(pcount);
+                    String currentElement = pathElements.get(pcount);
                     FTPFile[] theFiles = listFiles(currentPath);
                     FTPFile theFile = null;
                     if (theFiles != null) {
                         theFile = getFile(theFiles, currentElement);
                     }
-                    if (!relPath.equals("")) {
+                    if (!"".equals(relPath)) {
                         relPath = relPath + task.getSeparator();
                     }
                     if (theFile == null) {
@@ -881,6 +896,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 }
                 return relPath;
             }
+
             /**
              * find a file matching a string in an array of FTPFile.
              * This method will find "alpha" when requested for "ALPHA"
@@ -894,19 +910,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 if (theFiles == null) {
                     return null;
                 }
-                for (int fcount = 0; fcount < theFiles.length; fcount++) {
-                    if (theFiles[fcount] != null) {
-                        if (theFiles[fcount].getName().equals(lastpathelement)) {
-                            return theFiles[fcount];
-                        } else if (!isCaseSensitive()
-                                   && theFiles[fcount].getName().equalsIgnoreCase(
-                                                                                  lastpathelement)) {
-                            return theFiles[fcount];
-                        }
-                    }
-                }
-                return null;
+                Predicate<String> test =
+                    isCaseSensitive() ? lastpathelement::equals
+                        : lastpathelement::equalsIgnoreCase;
+                return Stream.of(theFiles).filter(f -> test.test(f.getName()))
+                    .findFirst().orElse(null);
             }
+
             /**
              * tell if a file is a directory.
              * note that it will return false for symbolic links pointing to directories.
@@ -915,6 +925,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public boolean isDirectory() {
                 return ftpFile.isDirectory();
             }
+
             /**
              * tell if a file is a symbolic link
              * @return <code>true</code> for symbolic links
@@ -922,6 +933,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public boolean isSymbolicLink() {
                 return ftpFile.isSymbolicLink();
             }
+
             /**
              * return the attached FTP client object.
              * Warning : this instance is really shared with the enclosing class.
@@ -938,6 +950,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             protected void setCurpwd(String curpwd) {
                 this.curpwd = curpwd;
             }
+
             /**
              * returns the path of the directory containing the AntFTPFile.
              * of the full path of the file itself in case of AntFTPRootFile
@@ -946,6 +959,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public String getCurpwd() {
                 return curpwd;
             }
+
             /**
              * returns the path of the directory containing the AntFTPFile.
              * of the full path of the file itself in case of AntFTPRootFile
@@ -957,6 +971,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 String sep = task.getSeparator();
                 return curpwd.endsWith(sep) ? curpwd : curpwd + sep;
             }
+
             /**
              * find out if a symbolic link is encountered in the relative path of this file
              * from rootPath.
@@ -977,16 +992,19 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
              * Get a string rep of this object.
              * @return a string containing the pwd and the file.
              */
+            @Override
             public String toString() {
                 return "AntFtpFile: " + curpwd + "%" + ftpFile;
             }
         }
+
         /**
          * special class to represent the remote directory itself
          * @since Ant 1.6
          */
         protected class AntFTPRootFile extends AntFTPFile {
             private String remotedir;
+
             /**
              * constructor
              * @param aclient FTP client
@@ -1002,24 +1020,29 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     throw new BuildException(ioe, task.getLocation());
                 }
             }
+
             /**
              * find the absolute path
              * @return absolute path
              */
+            @Override
             public String getAbsolutePath() {
                 return this.getCurpwd();
             }
+
             /**
              * find out the relative path to root
              * @return empty string
              * @throws BuildException actually never
              * @throws IOException  actually never
              */
+            @Override
             public String getRelativePath() throws BuildException, IOException {
                 return "";
             }
         }
     }
+
     /**
      * check FTPFiles to check whether they function as directories too
      * the FTPFile API seem to make directory and symbolic links incompatible
@@ -1034,7 +1057,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         String currentWorkingDir = null;
         if (file.isDirectory()) {
             return true;
-        } else if (file.isFile()) {
+        }
+        if (file.isFile()) {
             return false;
         }
         try {
@@ -1060,14 +1084,16 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                                           Project.MSG_ERR);
                 } finally {
                     if (!comeback) {
-                        throw new BuildException("could not cd back to " + dir //NOSONAR
-                                                 + " while checking a symlink");
+                        throw new BuildException(
+                            "could not cd back to %s while checking a symlink",
+                            dir);
                     }
                 }
             }
         }
         return result;
     }
+
     /**
      * check FTPFiles to check whether they function as directories too
      * the FTPFile API seem to make directory and symbolic links incompatible
@@ -1080,7 +1106,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
     private boolean isFunctioningAsFile(FTPClient ftp, String dir, FTPFile file) {
         if (file.isDirectory()) {
             return false;
-        } else if (file.isFile()) {
+        }
+        if (file.isFile()) {
             return true;
         }
         return !isFunctioningAsDirectory(ftp, dir, file);
@@ -1099,7 +1126,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         h.execute(r, descr);
     }
 
-
     /**
      * For each file in the fileset, do the appropriate action: send, get,
      * delete, or list.
@@ -1130,16 +1156,17 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         } else {
             dsfiles = ds.getIncludedFiles();
         }
-        String dir = null;
 
         if ((ds.getBasedir() == null)
-            && ((task.getAction() == FTPTask.SEND_FILES) || (task.getAction() == FTPTask.GET_FILES))) {
-            throw new BuildException("the dir attribute must be set for send "
-                                     + "and get actions");
-        } else {
-            if ((task.getAction() == FTPTask.SEND_FILES) || (task.getAction() == FTPTask.GET_FILES)) {
-                dir = ds.getBasedir().getAbsolutePath();
-            }
+            && ((task.getAction() == FTPTask.SEND_FILES)
+                || (task.getAction() == FTPTask.GET_FILES))) {
+            throw new BuildException(
+                "the dir attribute must be set for send and get actions");
+        }
+        String dir = null;
+        if ((task.getAction() == FTPTask.SEND_FILES)
+            || (task.getAction() == FTPTask.GET_FILES)) {
+            dir = ds.getBasedir().getAbsolutePath();
         }
 
         // If we are doing a listing, we need the output stream created now.
@@ -1160,11 +1187,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 // the trunk does not let itself be removed before the leaves
                 for (int i = dsfiles.length - 1; i >= 0; i--) {
                     final String dsfile = dsfiles[i];
-                    executeRetryable(h, new Retryable() {
-                            public void execute() throws IOException {
-                                rmDir(ftp, dsfile);
-                            }
-                        }, dsfile);
+                    executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile);
                 }
             } else {
                 final BufferedWriter fbw = bw;
@@ -1175,32 +1198,30 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 }
                 for (int i = 0; i < dsfiles.length; i++) {
                     final String dsfile = dsfiles[i];
-                    executeRetryable(h, new Retryable() {
-                            public void execute() throws IOException {
-                                switch (task.getAction()) {
-                                case FTPTask.SEND_FILES:
-                                    sendFile(ftp, fdir, dsfile);
-                                    break;
-                                case FTPTask.GET_FILES:
-                                    getFile(ftp, fdir, dsfile);
-                                    break;
-                                case FTPTask.DEL_FILES:
-                                    delFile(ftp, dsfile);
-                                    break;
-                                case FTPTask.LIST_FILES:
-                                    listFile(ftp, fbw, dsfile);
-                                    break;
-                                case FTPTask.CHMOD:
-                                    doSiteCommand(ftp, "chmod " + task.getChmod() + " "
-                                                  + resolveFile(dsfile));
-                                    transferred++;
-                                    break;
-                                default:
-                                    throw new BuildException("unknown ftp action "
-                                                             + task.getAction());
-                                }
-                            }
-                        }, dsfile);
+                    executeRetryable(h, () -> {
+                        switch (task.getAction()) {
+                        case FTPTask.SEND_FILES:
+                            sendFile(ftp, fdir, dsfile);
+                            break;
+                        case FTPTask.GET_FILES:
+                            getFile(ftp, fdir, dsfile);
+                            break;
+                        case FTPTask.DEL_FILES:
+                            delFile(ftp, dsfile);
+                            break;
+                        case FTPTask.LIST_FILES:
+                            listFile(ftp, fbw, dsfile);
+                            break;
+                        case FTPTask.CHMOD:
+                            doSiteCommand(ftp, "chmod " + task.getChmod() + " "
+                                          + resolveFile(dsfile));
+                            transferred++;
+                            break;
+                        default:
+                            throw new BuildException("unknown ftp action %s",
+                                task.getAction());
+                        }
+                    }, dsfile);
                 }
             }
         } finally {
@@ -1227,29 +1248,26 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         transferred = 0;
         skipped = 0;
 
-        if (task.getFilesets().size() == 0) {
+        if (task.getFilesets().isEmpty()) {
             throw new BuildException("at least one fileset must be specified.");
-        } else {
-            // get files from filesets
-            final int size = task.getFilesets().size();
-            for (int i = 0; i < size; i++) {
-                FileSet fs = (FileSet) task.getFilesets().elementAt(i);
-
-                if (fs != null) {
-                    transferFiles(ftp, fs);
-                }
+        }
+        // get files from filesets
+        for (FileSet fs : task.getFilesets()) {
+            if (fs != null) {
+                transferFiles(ftp, fs);
             }
         }
-
-        task.log(transferred + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()] + " "
-                 + FTPTask.COMPLETED_ACTION_STRS[task.getAction()]);
+        task.log(
+            transferred + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()]
+                + " " + FTPTask.COMPLETED_ACTION_STRS[task.getAction()]);
         if (skipped != 0) {
-            task.log(skipped + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()]
-                     + " were not successfully " + FTPTask.COMPLETED_ACTION_STRS[task.getAction()]);
+            task.log(
+                skipped + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()]
+                    + " were not successfully "
+                    + FTPTask.COMPLETED_ACTION_STRS[task.getAction()]);
         }
     }
 
-
     /**
      * Correct a file path to correspond to the remote host requirements. This
      * implementation currently assumes that the remote end can handle
@@ -1266,7 +1284,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                             task.getSeparator().charAt(0));
     }
 
-
     /**
      * Creates all parent directories specified in a complete relative
      * pathname. Attempts to create existing directories will not cause
@@ -1287,7 +1304,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             return;
         }
 
-        Vector parents = new Vector();
+        Vector<File> parents = new Vector<>();
         String dirname;
 
         while ((dirname = dir.getParent()) != null) {
@@ -1307,13 +1324,14 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             String parent = dir.getParent();
             if (parent != null) {
                 if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
-                    throw new BuildException("could not change to "
-                                             + "directory: " + ftp.getReplyString());
+                    throw new BuildException(
+                        "could not change to directory: %s",
+                        ftp.getReplyString());
                 }
             }
 
             while (i >= 0) {
-                dir = (File) parents.elementAt(i--);
+                dir = parents.elementAt(i--);
                 // check if dir exists by trying to change into it.
                 if (!ftp.changeWorkingDirectory(dir.getName())) {
                     // could not change to it - try to create it
@@ -1323,8 +1341,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                         handleMkDirFailure(ftp);
                     }
                     if (!ftp.changeWorkingDirectory(dir.getName())) {
-                        throw new BuildException("could not change to "
-                                                 + "directory: " + ftp.getReplyString());
+                        throw new BuildException(
+                            "could not change to directory: %s",
+                            ftp.getReplyString());
                     }
                 }
                 dirCache.add(dir);
@@ -1332,6 +1351,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             ftp.changeWorkingDirectory(cwd);
         }
     }
+
     /**
      * auto find the time difference between local and remote
      * @param ftp handle to ftp client
@@ -1348,8 +1368,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath()));
             ftp.storeFile(tempFile.getName(), instream);
             instream.close();
-            boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode());
-            if (success) {
+            if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
                 FTPFile [] ftpFiles = ftp.listFiles(tempFile.getName());
                 if (ftpFiles.length == 1) {
                     long remoteTimeStamp = ftpFiles[0].getTimestamp().getTime().getTime();
@@ -1368,11 +1387,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
         return returnValue;
     }
+
     /**
      *  find a suitable name for local and remote temporary file
      */
     private File findFileName(FTPClient ftp) {
-        FTPFile [] theFiles = null;
+        FTPFile[] theFiles = null;
         final int maxIterations = 1000;
         for (int counter = 1; counter < maxIterations; counter++) {
             File localFile = FILE_UTILS.createTempFile(
@@ -1430,10 +1450,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 task.log("Could not date test remote file: " + remoteFile
                          + "assuming out of date.", Project.MSG_VERBOSE);
                 return false;
-            } else {
-                throw new BuildException("could not date test remote file: "
-                                         + ftp.getReplyString());
             }
+            throw new BuildException("could not date test remote file: %s",
+                ftp.getReplyString());
         }
 
         long remoteTimestamp = files[0].getTimestamp().getTime().getTime();
@@ -1441,16 +1460,16 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         long adjustedRemoteTimestamp = remoteTimestamp + task.getTimeDiffMillis()
             + task.getGranularityMillis();
 
-        StringBuffer msg;
+        StringBuilder msg;
         synchronized(TIMESTAMP_LOGGING_SDF) {
-            msg = new StringBuffer("   [")
+            msg = new StringBuilder("   [")
                 .append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp)))
                 .append("] local");
         }
         task.log(msg.toString(), Project.MSG_VERBOSE);
 
         synchronized(TIMESTAMP_LOGGING_SDF) {
-            msg = new StringBuffer("   [")
+            msg = new StringBuilder("   [")
                 .append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp)))
                 .append("] remote");
         }
@@ -1465,9 +1484,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
 
         if (task.getAction() == FTPTask.SEND_FILES) {
             return adjustedRemoteTimestamp >= localTimestamp;
-        } else {
-            return localTimestamp >= adjustedRemoteTimestamp;
         }
+        return localTimestamp >= adjustedRemoteTimestamp;
     }
 
 
@@ -1480,28 +1498,21 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
      */
     protected void doSiteCommand(FTPClient ftp, String theCMD)
         throws IOException, BuildException {
-        boolean rc;
-        String[] myReply = null;
 
         task.log("Doing Site Command: " + theCMD, Project.MSG_VERBOSE);
 
-        rc = ftp.sendSiteCommand(theCMD);
-
-        if (!rc) {
-            task.log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN);
+        if (!ftp.sendSiteCommand(theCMD)) {
+            task.log("Failed to issue Site Command: " + theCMD,
+                Project.MSG_WARN);
         } else {
-
-            myReply = ftp.getReplyStrings();
-
-            for (int x = 0; x < myReply.length; x++) {
-                if (myReply[x].indexOf("200") == -1) {
-                    task.log(myReply[x], Project.MSG_WARN);
+            for (String reply : ftp.getReplyStrings()) {
+                if (reply.indexOf("200") == -1) {
+                    task.log(reply, Project.MSG_WARN);
                 }
             }
         }
     }
 
-
     /**
      * Sends a single file to the remote host. <code>filename</code> may
      * contain a relative path specification. When this is the case, <code>sendFile</code>
@@ -1540,9 +1551,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
 
             ftp.storeFile(resolveFile(filename), instream);
 
-            boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode());
-
-            if (!success) {
+            if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
                 String s = "could not put file: " + ftp.getReplyString();
 
                 if (task.isSkipFailedTransfers()) {
@@ -1567,7 +1576,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
     }
 
-
     /**
      * Delete a file from the remote host.
      * @param ftp ftp client
@@ -1628,7 +1636,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
     }
 
-
     /**
      * Retrieve a single file from the remote host. <code>filename</code> may
      * contain a relative path specification. <p>
@@ -1699,7 +1706,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
     }
 
-
     /**
      * List information about a single file from the remote host. <code>filename</code>
      * may contain a relative path specification. <p>
@@ -1728,7 +1734,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
     }
 
-
     /**
      * Create the specified directory on the remote host.
      *
@@ -1754,10 +1759,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         if (dir.startsWith("/")) {
             ftp.changeWorkingDirectory("/");
         }
-        String subdir = "";
         StringTokenizer st = new StringTokenizer(dir, "/");
         while (st.hasMoreTokens()) {
-            subdir = st.nextToken();
+            String subdir = st.nextToken();
             task.log("Checking " + subdir, Project.MSG_DEBUG);
             if (!ftp.changeWorkingDirectory(subdir)) {
                 if (!ftp.makeDirectory(subdir)) {
@@ -1804,6 +1808,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
     }
 
+    @Override
     public void doFTP() throws BuildException {
         FTPClient ftp = null;
 
@@ -1818,8 +1823,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             ftp.setRemoteVerificationEnabled(task.getEnableRemoteVerification());
             ftp.connect(task.getServer(), task.getPort());
             if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
-                throw new BuildException("FTP connection failed: "
-                                         + ftp.getReplyString());
+                throw new BuildException("FTP connection failed: %s",
+                    ftp.getReplyString());
             }
 
             task.log("connected", Project.MSG_VERBOSE);
@@ -1835,14 +1840,14 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             if (task.isBinary()) {
                 ftp.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
                 if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
-                    throw new BuildException("could not set transfer type: "
-                                             + ftp.getReplyString());
+                    throw new BuildException("could not set transfer type: %s",
+                        ftp.getReplyString());
                 }
             } else {
                 ftp.setFileType(org.apache.commons.net.ftp.FTP.ASCII_FILE_TYPE);
                 if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
-                    throw new BuildException("could not set transfer type: "
-                                             + ftp.getReplyString());
+                    throw new BuildException("could not set transfer type: %s",
+                        ftp.getReplyString());
                 }
             }
 
@@ -1850,8 +1855,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 task.log("entering passive mode", Project.MSG_VERBOSE);
                 ftp.enterLocalPassiveMode();
                 if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
-                    throw new BuildException("could not enter into passive "
-                                             + "mode: " + ftp.getReplyString());
+                    throw new BuildException(
+                        "could not enter into passive mode: %s",
+                        ftp.getReplyString());
                 }
             }
 
@@ -1860,55 +1866,46 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             // E.G. switching between a UNIX file system mode and
             // a legacy file system.
             if (task.getInitialSiteCommand() != null) {
-                RetryHandler h = new RetryHandler(task.getRetriesAllowed(), task);
                 final FTPClient lftp = ftp;
-                executeRetryable(h, new Retryable() {
-                        public void execute() throws IOException {
-                            doSiteCommand(lftp, task.getInitialSiteCommand());
-                        }
-                    }, "initial site command: " + task.getInitialSiteCommand());
+                executeRetryable(new RetryHandler(task.getRetriesAllowed(), task),
+                    () -> doSiteCommand(lftp, task.getInitialSiteCommand()),
+                    "initial site command: " + task.getInitialSiteCommand());
             }
 
-
             // For a unix ftp server you can set the default mask for all files
             // created.
 
             if (task.getUmask() != null) {
-                RetryHandler h = new RetryHandler(task.getRetriesAllowed(), task);
                 final FTPClient lftp = ftp;
-                executeRetryable(h, new Retryable() {
-                        public void execute() throws IOException {
-                            doSiteCommand(lftp, "umask " + task.getUmask());
-                        }
-                    }, "umask " + task.getUmask());
+                executeRetryable(
+                    new RetryHandler(task.getRetriesAllowed(), task),
+                    () -> doSiteCommand(lftp, "umask " + task.getUmask()),
+                    "umask " + task.getUmask());
             }
 
             // If the action is MK_DIR, then the specified remote
             // directory is the directory to create.
 
             if (task.getAction() == FTPTask.MK_DIR) {
-                RetryHandler h = new RetryHandler(task.getRetriesAllowed(), task);
                 final FTPClient lftp = ftp;
-                executeRetryable(h, new Retryable() {
-                        public void execute() throws IOException {
-                            makeRemoteDir(lftp, task.getRemotedir());
-                        }
-                    }, task.getRemotedir());
+                executeRetryable(
+                    new RetryHandler(task.getRetriesAllowed(), task),
+                    () -> makeRemoteDir(lftp, task.getRemotedir()),
+                    task.getRemotedir());
             } else if (task.getAction() == FTPTask.SITE_CMD) {
-                RetryHandler h = new RetryHandler(task.getRetriesAllowed(), task);
                 final FTPClient lftp = ftp;
-                executeRetryable(h, new Retryable() {
-                        public void execute() throws IOException {
-                            doSiteCommand(lftp, task.getSiteCommand());
-                        }
-                    }, "Site Command: " + task.getSiteCommand());
+                executeRetryable(
+                    new RetryHandler(task.getRetriesAllowed(), task),
+                    () -> doSiteCommand(lftp, task.getSiteCommand()),
+                    "Site Command: " + task.getSiteCommand());
             } else {
                 if (task.getRemotedir() != null) {
                     task.log("changing the remote directory", Project.MSG_VERBOSE);
                     ftp.changeWorkingDirectory(task.getRemotedir());
                     if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
-                        throw new BuildException("could not change remote "
-                                                 + "directory: " + ftp.getReplyString());
+                        throw new BuildException(
+                            "could not change remote directory: %s",
+                            ftp.getReplyString());
                     }
                 }
                 if (task.isNewer() && task.isTimeDiffAuto()) {
@@ -1919,7 +1916,6 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                 task.log(FTPTask.ACTION_STRS[task.getAction()] + " " + FTPTask.ACTION_TARGET_STRS[task.getAction()]);
                 transferFiles(ftp);
             }
-
         } catch (IOException ex) {
             throw new BuildException("error during FTP transfer: " + ex, ex);
         } finally {
@@ -1935,4 +1931,3 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
         }
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
index fca4215..01db77a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
@@ -28,12 +28,14 @@ import org.apache.tools.ant.taskdefs.email.EmailTask;
  *
  * @since Ant1.4
  */
+@Deprecated
 public class MimeMail extends EmailTask {
     /**
      * Executes this build task.
      *
      * @exception BuildException On error.
      */
+    @Override
     public void execute()
         throws BuildException {
         log("DEPRECATED - The " + getTaskName() + " task is deprecated. "

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
index d88874f..ff24beb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
@@ -22,7 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Calendar;
-import java.util.Enumeration;
+import java.util.List;
 import java.util.Vector;
 
 import org.apache.commons.net.bsd.RExecClient;
@@ -68,7 +68,7 @@ public class RExecTask extends Task {
     /**
      *  The list of read/write commands for this session
      */
-    private Vector rexecTasks = new Vector();
+    private List<RExecSubTask> rexecTasks = new Vector<>();
 
     /**
      *  If true, adds a CR to beginning of login script
@@ -97,7 +97,7 @@ public class RExecTask extends Task {
          */
         public void execute(AntRExecClient rexec)
                 throws BuildException {
-            throw new BuildException("Shouldn't be able instantiate a SubTask directly");
+            throw new BuildException("Shouldn't be able to instantiate a SubTask directly");
         }
 
         /**
@@ -127,6 +127,7 @@ public class RExecTask extends Task {
          * @param rexec the task to use
          * @throws BuildException on error
          */
+        @Override
         public void execute(AntRExecClient rexec)
                throws BuildException {
            rexec.sendString(taskString, echoString);
@@ -153,6 +154,7 @@ public class RExecTask extends Task {
          * @param rexec the task to use
          * @throws BuildException on error
          */
+        @Override
         public void execute(AntRExecClient rexec)
                throws BuildException {
             rexec.waitForString(taskString, timeout);
@@ -202,7 +204,7 @@ public class RExecTask extends Task {
         public void waitForString(String s, Integer timeout) {
             InputStream is = this.getInputStream();
             try {
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 int windowStart = -s.length();
                 if (timeout == null || timeout.intValue() == 0) {
                     while (windowStart < 0
@@ -253,6 +255,7 @@ public class RExecTask extends Task {
                 throw new BuildException(e, getLocation());
             }
         }
+
         /**
          * Read from the rexec session until the EOF is found or
          * the timeout has been reached
@@ -261,15 +264,15 @@ public class RExecTask extends Task {
         public void waitForEOF(Integer timeout) {
             InputStream is = this.getInputStream();
             try {
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 if (timeout == null || timeout.intValue() == 0) {
                 int read;
                     while ((read = is.read()) != -1) {
                         char c = (char) read;
                         sb.append(c);
                         if (c == '\n') {
-                        log(sb.toString(), Project.MSG_INFO);
-                        sb.delete(0, sb.length());
+                            log(sb.toString(), Project.MSG_INFO);
+                            sb.delete(0, sb.length());
                         }
                     }
                 } else {
@@ -281,24 +284,24 @@ public class RExecTask extends Task {
                             Thread.sleep(PAUSE_TIME);
                         }
                         if (is.available() == 0) {
-                        log(sb.toString(), Project.MSG_INFO);
-                            throw new BuildException(
-                                                     "Response timed-out waiting for EOF",
-                                                     getLocation());
+                            log(sb.toString(), Project.MSG_INFO);
+                                throw new BuildException(
+                                                         "Response timed-out waiting for EOF",
+                                                         getLocation());
                         }
                         read =  is.read();
                         if (read != -1) {
-                        char c = (char) read;
-                        sb.append(c);
-                        if (c == '\n') {
+                            char c = (char) read;
+                            sb.append(c);
+                            if (c == '\n') {
                                 log(sb.toString(), Project.MSG_INFO);
                                 sb.delete(0, sb.length());
-                        }
+                            }
                         }
                     }
                 }
                 if (sb.length() > 0) {
-                log(sb.toString(), Project.MSG_INFO);
+                    log(sb.toString(), Project.MSG_INFO);
                 }
             } catch (BuildException be) {
                 throw be;
@@ -306,8 +309,8 @@ public class RExecTask extends Task {
                 throw new BuildException(e, getLocation());
             }
         }
-
     }
+
     /**
      *  A string to wait for from the server.
      *  A subTask &lt;read&gt; tag was found.  Create the object,
@@ -316,10 +319,11 @@ public class RExecTask extends Task {
      */
 
     public RExecSubTask createRead() {
-        RExecSubTask task = (RExecSubTask) new RExecRead();
-        rexecTasks.addElement(task);
+        RExecSubTask task = new RExecRead();
+        rexecTasks.add(task);
         return task;
     }
+
     /**
      *  Add text to send to the server
      *  A subTask &lt;write&gt; tag was found.  Create the object,
@@ -327,16 +331,18 @@ public class RExecTask extends Task {
      * @return a write sub task
      */
     public RExecSubTask createWrite() {
-        RExecSubTask task = (RExecSubTask) new RExecWrite();
-        rexecTasks.addElement(task);
+        RExecSubTask task = new RExecWrite();
+        rexecTasks.add(task);
         return task;
     }
+
     /**
      *  Verify that all parameters are included.
      *  Connect and possibly login.
      *  Iterate through the list of Reads and writes.
      * @throws BuildException on error
      */
+    @Override
     public void execute() throws BuildException {
         /**  A server name is required to continue */
         if (server == null) {
@@ -363,7 +369,7 @@ public class RExecTask extends Task {
                 throw new BuildException("Can't connect to " + server);
             }
             if (userid != null && password != null && command != null //NOSONAR
-                && rexecTasks.size() == 0) {
+                && rexecTasks.isEmpty()) {
                 // simple one-shot execution
                 rexec.rexec(userid, password, command);
             } else {
@@ -384,13 +390,14 @@ public class RExecTask extends Task {
                     String msg = "Error disconnecting from " + server;
                     if (success) {
                         throw new BuildException(msg); //NOSONAR
-                    } else { // don't hide inner exception
-                        log(msg, Project.MSG_ERR);
                     }
+                    // don't hide inner exception
+                    log(msg, Project.MSG_ERR);
                 }
             }
         }
     }
+
     /**
      *  Process a 'typical' login.  If it differs, use the read
      *  and write tasks explicitly
@@ -404,6 +411,7 @@ public class RExecTask extends Task {
         rexec.waitForString("assword:");
         rexec.sendString(password, false);
     }
+
     /**
      * Set the the command to execute on the server;
      * @param c a <code>String</code> value
@@ -419,6 +427,7 @@ public class RExecTask extends Task {
     public void setInitialCR(boolean b) {
         this.addCarriageReturn = b;
     }
+
     /**
      *  Set the the login password to use
      * required if <tt>userid</tt> is set.
@@ -452,6 +461,7 @@ public class RExecTask extends Task {
     public void setTimeout(Integer i) {
         this.defaultTimeout = i;
     }
+
     /**
      * Set the the login id to use on the server;
      * required if <tt>password</tt> is set.
@@ -473,9 +483,7 @@ public class RExecTask extends Task {
             login(rexec);
         }
         /**  Process each sub command */
-        Enumeration tasksToRun = rexecTasks.elements();
-        while (tasksToRun != null && tasksToRun.hasMoreElements()) {
-            RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
+        for (RExecSubTask task : rexecTasks) {
             if (task instanceof RExecRead && defaultTimeout != null) {
                 ((RExecRead) task).setDefaultTimeout(defaultTimeout);
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
index 1e1f659..748afcf 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
@@ -175,7 +175,6 @@ public class SetProxy extends Task {
      * apply to all network connections
      * Relevant docs: buglist #4183340
      */
-
     public void applyWebProxySettings() {
         boolean settingsChanged = false;
         boolean enablingProxy = false;
@@ -261,6 +260,7 @@ public class SetProxy extends Task {
      *
      * @exception BuildException thrown in unrecoverable error.
      */
+    @Override
     public void execute() throws BuildException {
         applyWebProxySettings();
     }
@@ -275,6 +275,7 @@ public class SetProxy extends Task {
             auth = new PasswordAuthentication(user, pass.toCharArray());
         }
 
+        @Override
         protected PasswordAuthentication getPasswordAuthentication() {
             return auth;
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
index a89e7a9..412ef93 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
@@ -22,7 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Calendar;
-import java.util.Enumeration;
+import java.util.List;
 import java.util.Vector;
 
 import org.apache.commons.net.telnet.TelnetClient;
@@ -34,7 +34,6 @@ import org.apache.tools.ant.Task;
  * Automates the telnet protocol.
  *
  */
-
 public class TelnetTask extends Task {
     private static final int WAIT_INTERVAL = 250;
     private static final int TELNET_PORT = 23;
@@ -62,7 +61,7 @@ public class TelnetTask extends Task {
     /**
      *  The list of read/write commands for this session
      */
-    private Vector telnetTasks = new Vector();
+    private List<TelnetSubTask> telnetTasks = new Vector<>();
 
     /**
      *  If true, adds a CR to beginning of login script
@@ -81,6 +80,7 @@ public class TelnetTask extends Task {
      *  Iterate through the list of Reads and writes
      * @throws BuildException on error
      */
+    @Override
     public void execute() throws BuildException {
        /**  A server name is required to continue */
        if (server == null) {
@@ -111,9 +111,7 @@ public class TelnetTask extends Task {
                login(telnet);
            }
            /**  Process each sub command */
-           Enumeration tasksToRun = telnetTasks.elements();
-           while (tasksToRun != null && tasksToRun.hasMoreElements()) {
-               TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement();
+           for (TelnetSubTask task : telnetTasks) {
                if (task instanceof TelnetRead && defaultTimeout != null) {
                    ((TelnetRead) task).setDefaultTimeout(defaultTimeout);
                }
@@ -209,8 +207,8 @@ public class TelnetTask extends Task {
      */
 
     public TelnetSubTask createRead() {
-        TelnetSubTask task = (TelnetSubTask) new TelnetRead();
-        telnetTasks.addElement(task);
+        TelnetSubTask task = new TelnetRead();
+        telnetTasks.add(task);
         return task;
     }
 
@@ -221,8 +219,8 @@ public class TelnetTask extends Task {
      * @return a write telnet sub task
      */
     public TelnetSubTask createWrite() {
-        TelnetSubTask task = (TelnetSubTask) new TelnetWrite();
-        telnetTasks.addElement(task);
+        TelnetSubTask task = new TelnetWrite();
+        telnetTasks.add(task);
         return task;
     }
 
@@ -271,6 +269,7 @@ public class TelnetTask extends Task {
          * @param telnet the task to use
          * @throws BuildException on error
          */
+        @Override
         public void execute(AntTelnetClient telnet)
                throws BuildException {
            telnet.sendString(taskString, echoString);
@@ -297,6 +296,7 @@ public class TelnetTask extends Task {
          * @param telnet the task to use
          * @throws BuildException on error
          */
+        @Override
         public void execute(AntTelnetClient telnet)
                throws BuildException {
             telnet.waitForString(taskString, timeout);
@@ -346,7 +346,7 @@ public class TelnetTask extends Task {
         public void waitForString(String s, Integer timeout) {
             InputStream is = this.getInputStream();
             try {
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 int windowStart = -s.length();
                 if (timeout == null || timeout.intValue() == 0) {
                     while (windowStart < 0

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
index 7bcfef9..9d844a1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
@@ -28,7 +28,6 @@ import java.io.OutputStream;
 import java.nio.file.Files;
 import java.text.MessageFormat;
 import java.text.ParseException;
-import java.util.Enumeration;
 import java.util.Random;
 import java.util.Vector;
 
@@ -79,10 +78,20 @@ public class Pvcs extends org.apache.tools.ant.Task {
     private static final int POS_2 = 2;
     private static final int POS_3 = 3;
 
+    /**
+     * Constant for the thing to execute
+     */
+    private static final String PCLI_EXE = "pcli";
+
+    /**
+     * Constant for the thing to execute
+     */
+    private static final String GET_EXE = "get";
+
     private String pvcsbin;
     private String repository;
     private String pvcsProject;
-    private Vector pvcsProjects;
+    private Vector<PvcsProject> pvcsProjects;
     private String workspace;
     private String force;
     private String promotiongroup;
@@ -94,21 +103,25 @@ public class Pvcs extends org.apache.tools.ant.Task {
     private String lineStart;
     private String userId;
     private String config;
-    /**
-     * Constant for the thing to execute
-     */
-    private static final String PCLI_EXE = "pcli";
-
-    /*
-     * Constant for the PCLI listversionedfiles recursive i a format "get" understands
-     */
-    // private static final String PCLI_LVF_ARGS = "lvf -z -aw";
 
     /**
-     * Constant for the thing to execute
+     * Creates a Pvcs object
      */
-    private static final String GET_EXE = "get";
-
+    public Pvcs() {
+        super();
+        pvcsProject = null;
+        pvcsProjects = new Vector<>();
+        workspace = null;
+        repository = null;
+        pvcsbin = null;
+        force = null;
+        promotiongroup = null;
+        label = null;
+        ignorerc = false;
+        updateOnly = false;
+        lineStart = "\"P:";
+        filenameFormat = "{0}-arc({1})";
+    }
 
     /**
      * Run the command.
@@ -124,7 +137,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
             exe.setWorkingDirectory(aProj.getBaseDir());
             exe.setCommandline(cmd.getCommandline());
             return exe.execute();
-        } catch (java.io.IOException e) {
+        } catch (IOException e) {
             String msg = "Failed executing: " + cmd.toString()
                 + ". Exception: " + e.getMessage();
             throw new BuildException(msg, getLocation());
@@ -132,7 +145,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
     }
 
     private String getExecutable(String exe) {
-        StringBuffer correctedExe = new StringBuffer();
+        StringBuilder correctedExe = new StringBuilder();
         if (getPvcsbin() != null) {
             if (pvcsbin.endsWith(File.separator)) {
                 correctedExe.append(pvcsbin);
@@ -146,10 +159,11 @@ public class Pvcs extends org.apache.tools.ant.Task {
     /**
      * @exception org.apache.tools.ant.BuildException Something is stopping the build...
      */
-    public void execute() throws org.apache.tools.ant.BuildException {
+    @Override
+    public void execute() throws BuildException {
         int result = 0;
 
-        if (repository == null || repository.trim().equals("")) {
+        if (repository == null || repository.trim().isEmpty()) {
             throw new BuildException("Required argument repository not specified");
         }
 
@@ -183,12 +197,11 @@ public class Pvcs extends org.apache.tools.ant.Task {
             commandLine.createArgument().setValue(getPvcsproject());
         }
         if (!getPvcsprojects().isEmpty()) {
-            Enumeration e = getPvcsprojects().elements();
-            while (e.hasMoreElements()) {
-                String projectName = ((PvcsProject) e.nextElement()).getName();
-                if (projectName == null || (projectName.trim()).equals("")) {
-                    throw new BuildException("name is a required attribute "
-                        + "of pvcsproject");
+            for (PvcsProject pvcsProject : getPvcsprojects()) {
+                String projectName = pvcsProject.getName();
+                if (projectName == null || projectName.trim().isEmpty()) {
+                    throw new BuildException(
+                        "name is a required attribute of pvcsproject");
                 }
                 commandLine.createArgument().setValue(projectName);
             }
@@ -298,9 +311,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
      * Parses the file and creates the folders specified in the output section
      */
     private void createFolders(File file) throws IOException, ParseException {
-        BufferedReader in = null;
-        try {
-            in = new BufferedReader(new FileReader(file));
+        try (BufferedReader in = new BufferedReader(new FileReader(file))) {
             MessageFormat mf = new MessageFormat(getFilenameFormat());
             String line = in.readLine();
             while (line != null) {
@@ -318,7 +329,10 @@ public class Pvcs extends org.apache.tools.ant.Task {
                     int index = f.lastIndexOf(File.separator);
                     if (index > -1) {
                         File dir = new File(f.substring(0, index));
-                        if (!dir.exists()) {
+                        if (dir.exists()) {
+                            log(dir.getAbsolutePath() + " exists. Skipping",
+                                Project.MSG_VERBOSE);
+                        } else {
                             log("Creating " + dir.getAbsolutePath(),
                                 Project.MSG_VERBOSE);
                             if (dir.mkdirs() || dir.isDirectory()) {
@@ -329,9 +343,6 @@ public class Pvcs extends org.apache.tools.ant.Task {
                                     + dir.getAbsolutePath(),
                                     Project.MSG_INFO);
                             }
-                        } else {
-                            log(dir.getAbsolutePath() + " exists. Skipping",
-                                Project.MSG_VERBOSE);
                         }
                     } else {
                         log("File separator problem with " + line,
@@ -342,8 +353,6 @@ public class Pvcs extends org.apache.tools.ant.Task {
                 }
                 line = in.readLine();
             }
-        } finally {
-            FileUtils.close(in);
         }
     }
 
@@ -355,20 +364,14 @@ public class Pvcs extends org.apache.tools.ant.Task {
      */
     private void massagePCLI(File in, File out)
         throws IOException {
-        BufferedReader inReader = null;
-        BufferedWriter outWriter = null;
-        try {
-            inReader = new BufferedReader(new FileReader(in));
-            outWriter = new BufferedWriter(new FileWriter(out));
-            String s = null;
-            while ((s = inReader.readLine()) != null) {
-                String sNormal = s.replace('\\', '/');
-                outWriter.write(sNormal);
+        try (BufferedReader inReader = new BufferedReader(new FileReader(in));
+                BufferedWriter outWriter =
+                    new BufferedWriter(new FileWriter(out))) {
+            for (String line : (Iterable<String>) () -> inReader.lines()
+                .map(s -> s.replace('\\', '/')).iterator()) {
+                outWriter.write(line);
                 outWriter.newLine();
             }
-        } finally {
-            FileUtils.close(inReader);
-            FileUtils.close(outWriter);
         }
     }
 
@@ -458,7 +461,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
      * Get name of the project in the PVCS repository
      * @return Vector
      */
-    public Vector getPvcsprojects() {
+    public Vector<PvcsProject> getPvcsprojects() {
         return pvcsProjects;
     }
 
@@ -523,11 +526,7 @@ public class Pvcs extends org.apache.tools.ant.Task {
      * @param f String (yes/no)
      */
     public void setForce(String f) {
-        if (f != null && f.equalsIgnoreCase("yes")) {
-            force = "yes";
-        } else {
-            force = "no";
-        }
+        force = "yes".equalsIgnoreCase(f) ? "yes" : "no";
     }
 
     /**
@@ -654,23 +653,5 @@ public class Pvcs extends org.apache.tools.ant.Task {
         userId = u;
     }
 
-    /**
-     * Creates a Pvcs object
-     */
-    public Pvcs() {
-        super();
-        pvcsProject = null;
-        pvcsProjects = new Vector();
-        workspace = null;
-        repository = null;
-        pvcsbin = null;
-        force = null;
-        promotiongroup = null;
-        label = null;
-        ignorerc = false;
-        updateOnly = false;
-        lineStart = "\"P:";
-        filenameFormat = "{0}-arc({1})";
-    }
 }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java
index a8c6a2a..8f0aed7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java
@@ -26,11 +26,6 @@ package org.apache.tools.ant.taskdefs.optional.pvcs;
 public class PvcsProject {
     private String name;
 
-    /** no arg constructor */
-    public PvcsProject() {
-        super();
-    }
-
     /**
      * Set the name of the project
      * @param name the value to use.