You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2017/07/01 14:49:38 UTC

[3/4] ant-ivy git commit: Generics and Java 7 syntax in plugins package

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
index b1aafa9..c3ea1dd 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
@@ -32,7 +32,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -163,12 +162,12 @@ public final class XmlModuleDescriptorUpdater {
     private static class UpdaterHandler extends DefaultHandler implements LexicalHandler {
 
         /** standard attributes of ivy-module/info */
-        private static final Collection STD_ATTS = Arrays.asList(new String[] {"organisation",
-                "module", "branch", "revision", "status", "publication", "namespace"});
+        private static final Collection<String> STD_ATTS = Arrays.asList("organisation",
+                "module", "branch", "revision", "status", "publication", "namespace");
 
         /** elements that may appear inside ivy-module, in expected order */
-        private static final List MODULE_ELEMENTS = Arrays.asList(new String[] {"info",
-                "configurations", "publications", "dependencies", "conflicts"});
+        private static final List<String> MODULE_ELEMENTS = Arrays.asList("info",
+                "configurations", "publications", "dependencies", "conflicts");
 
         /** element position of "configurations" inside "ivy-module" */
         private static final int CONFIGURATIONS_POSITION = MODULE_ELEMENTS
@@ -178,16 +177,16 @@ public final class XmlModuleDescriptorUpdater {
         private static final int DEPENDENCIES_POSITION = MODULE_ELEMENTS.indexOf("dependencies");
 
         /** elements that may appear inside of ivy-module/info */
-        private static final Collection INFO_ELEMENTS = Arrays.asList(new String[] {"extends",
-                "ivyauthor", "license", "repository", "description"});
+        private static final Collection<String> INFO_ELEMENTS = Arrays.asList("extends",
+                "ivyauthor", "license", "repository", "description");
 
         private final ParserSettings settings;
 
         private final PrintWriter out;
 
-        private final Map resolvedRevisions;
+        private final Map<ModuleRevisionId, String> resolvedRevisions;
 
-        private final Map resolvedBranches;
+        private final Map<ModuleRevisionId, String> resolvedBranches;
 
         private final String status;
 
@@ -203,7 +202,7 @@ public final class XmlModuleDescriptorUpdater {
 
         private boolean inHeader = true;
 
-        private final List confs;
+        private final List<String> confs;
 
         private final URL relativePathCtx;
 
@@ -252,7 +251,7 @@ public final class XmlModuleDescriptorUpdater {
 
         private StringBuffer currentIndent = new StringBuffer();
 
-        private ArrayList indentLevels = new ArrayList(); // ArrayList<String>
+        private ArrayList<String> indentLevels = new ArrayList<>(); // ArrayList<String>
 
         // true if an ivy-module/info/description element has been found in the published descriptor
         private boolean hasDescription = false;
@@ -266,11 +265,11 @@ public final class XmlModuleDescriptorUpdater {
         // the new value of the defaultconf attribute on the publications tag
         private String newDefaultConf = null;
 
-        private Stack context = new Stack();
+        private Stack<String> context = new Stack<>();
 
-        private Stack buffers = new Stack();
+        private Stack<ExtendedBuffer> buffers = new Stack<>();
 
-        private Stack confAttributeBuffers = new Stack();
+        private Stack<ExtendedBuffer> confAttributeBuffers = new Stack<>();
 
         public void startElement(String uri, String localName, String qName, Attributes attributes)
                 throws SAXException {
@@ -315,11 +314,11 @@ public final class XmlModuleDescriptorUpdater {
                     || "ivy-module/dependencies/dependency/conf".equals(path)
                     || "ivy-module/dependencies/dependency/artifact/conf".equals(path)) {
                 buffers.push(new ExtendedBuffer(getContext()));
-                ((ExtendedBuffer) confAttributeBuffers.peek()).setDefaultPrint(false);
+                confAttributeBuffers.peek().setDefaultPrint(false);
                 String confName = substitute(settings, attributes.getValue("name"));
                 if (!confs.contains(confName)) {
-                    ((ExtendedBuffer) confAttributeBuffers.peek()).setPrint(true);
-                    ((ExtendedBuffer) buffers.peek()).setPrint(true);
+                    confAttributeBuffers.peek().setPrint(true);
+                    buffers.peek().setPrint(true);
                     write("<" + qName);
                     for (int i = 0; i < attributes.getLength(); i++) {
                         write(" " + attributes.getQName(i) + "=\""
@@ -340,7 +339,7 @@ public final class XmlModuleDescriptorUpdater {
                         String newConf = removeConfigurationsFromList(confName, confs);
                         if (newConf.length() > 0) {
                             write(" " + attributes.getQName(i) + "=\"" + newConf + "\"");
-                            ((ExtendedBuffer) buffers.peek()).setPrint(true);
+                            buffers.peek().setPrint(true);
                         }
                     } else {
                         write(" " + attributes.getQName(i) + "=\""
@@ -360,7 +359,7 @@ public final class XmlModuleDescriptorUpdater {
                         String newConf = removeConfigurationsFromList(confName, confs);
                         if (newConf.length() > 0) {
                             write(" " + attributes.getQName(i) + "=\"" + newConf + "\"");
-                            ((ExtendedBuffer) buffers.peek()).setPrint(true);
+                            buffers.peek().setPrint(true);
                         }
                     } else {
                         write(" " + attributes.getQName(i) + "=\""
@@ -439,7 +438,7 @@ public final class XmlModuleDescriptorUpdater {
             buffers.push(new ExtendedBuffer(getContext()));
             String confName = substitute(settings, attributes.getValue("name"));
             if (!confs.contains(confName)) {
-                ((ExtendedBuffer) buffers.peek()).setPrint(true);
+                buffers.peek().setPrint(true);
                 String extend = substitute(settings, attributes.getValue("extends"));
                 if (extend != null) {
                     for (StringTokenizer tok = new StringTokenizer(extend, ", "); tok
@@ -526,8 +525,7 @@ public final class XmlModuleDescriptorUpdater {
                 if (ns != null) {
                     mid = NameSpaceHelper.transform(mid, ns.getToSystemTransformer());
                 }
-                for (Iterator iter = resolvedRevisions.keySet().iterator(); iter.hasNext();) {
-                    ModuleRevisionId mrid = (ModuleRevisionId) iter.next();
+                for (ModuleRevisionId mrid : resolvedRevisions.keySet()) {
                     if (mrid.getModuleId().equals(mid)) {
                         branch = mrid.getBranch();
                         break;
@@ -537,19 +535,19 @@ public final class XmlModuleDescriptorUpdater {
 
             String revision = substitute(settings, attributes.getValue("rev"));
             String revisionConstraint = substitute(settings, attributes.getValue("revConstraint"));
-            Map extraAttributes = ExtendableItemHelper.getExtraAttributes(settings, attributes,
+            Map<String, String> extraAttributes = ExtendableItemHelper.getExtraAttributes(settings, attributes,
                 XmlModuleDescriptorParser.DEPENDENCY_REGULAR_ATTRIBUTES);
             ModuleRevisionId localMrid = ModuleRevisionId.newInstance(org, module, branch,
                 revision, extraAttributes);
             ModuleRevisionId systemMrid = ns == null ? localMrid : ns.getToSystemTransformer()
                     .transform(localMrid);
 
-            String newBranch = (String) resolvedBranches.get(systemMrid);
+            String newBranch = resolvedBranches.get(systemMrid);
 
             for (int i = 0; i < attributes.getLength(); i++) {
                 String attName = attributes.getQName(i);
                 if ("rev".equals(attName)) {
-                    String rev = (String) resolvedRevisions.get(systemMrid);
+                    String rev = resolvedRevisions.get(systemMrid);
                     if (rev != null) {
                         write(" rev=\"" + rev + "\"");
                         if (attributes.getIndex("branchConstraint") == -1
@@ -586,7 +584,7 @@ public final class XmlModuleDescriptorUpdater {
                         String newMapping = removeConfigurationsFromMapping(oldMapping, confs);
                         if (newMapping.length() > 0) {
                             write(" conf=\"" + newMapping + "\"");
-                            ((ExtendedBuffer) buffers.peek()).setPrint(true);
+                            buffers.peek().setPrint(true);
                         }
                     }
                 } else {
@@ -698,7 +696,7 @@ public final class XmlModuleDescriptorUpdater {
             String branch = null;
             String status = null;
             String namespace = null;
-            Map/* <String,String> */extraAttributes = null;
+            Map<String, String> extraAttributes = null;
 
             if (options.isMerge()) {
                 // get attributes from merged descriptor, ignoring raw XML
@@ -729,7 +727,7 @@ public final class XmlModuleDescriptorUpdater {
                 branch = substitute(settings, attributes.getValue("branch"));
                 status = substitute(settings, attributes.getValue("status"));
                 namespace = substitute(settings, attributes.getValue("namespace"));
-                extraAttributes = new LinkedHashMap(attributes.getLength());
+                extraAttributes = new LinkedHashMap<>(attributes.getLength());
                 for (int i = 0; i < attributes.getLength(); i++) {
                     String qname = attributes.getQName(i);
                     if (!STD_ATTS.contains(qname)) {
@@ -754,7 +752,7 @@ public final class XmlModuleDescriptorUpdater {
                 rev, ExtendableItemHelper
                         .getExtraAttributes(settings, attributes, new String[] {"organisation",
                                 "module", "revision", "status", "publication", "namespace"}));
-            ModuleRevisionId systemMid = ns == null ? localMid : ns.getToSystemTransformer()
+            ModuleRevisionId systemMid = (ns == null) ? localMid : ns.getToSystemTransformer()
                     .transform(localMid);
 
             write("<info");
@@ -779,8 +777,7 @@ public final class XmlModuleDescriptorUpdater {
                 write(" namespace=\"" + namespace + "\"");
             }
 
-            for (Iterator extras = extraAttributes.entrySet().iterator(); extras.hasNext();) {
-                Map.Entry extra = (Map.Entry) extras.next();
+            for (Map.Entry<String, String> extra : extraAttributes.entrySet()) {
                 write(" " + extra.getKey() + "=\"" + extra.getValue() + "\"");
             }
         }
@@ -790,13 +787,12 @@ public final class XmlModuleDescriptorUpdater {
         }
 
         private PrintWriter getWriter() {
-            return buffers.isEmpty() ? out : ((ExtendedBuffer) buffers.peek()).getWriter();
+            return buffers.isEmpty() ? out : buffers.peek().getWriter();
         }
 
         private String getContext() {
-            StringBuffer buf = new StringBuffer();
-            for (Iterator iter = context.iterator(); iter.hasNext();) {
-                String ctx = (String) iter.next();
+            StringBuilder buf = new StringBuilder();
+            for (String ctx : context) {
                 buf.append(ctx).append("/");
             }
             if (buf.length() > 0) {
@@ -811,26 +807,25 @@ public final class XmlModuleDescriptorUpdater {
         }
 
         private String removeConfigurationsFromMapping(String mapping, List confsToRemove) {
-            StringBuffer newMapping = new StringBuffer();
+            StringBuilder newMapping = new StringBuilder();
             String mappingSep = "";
             for (StringTokenizer tokenizer = new StringTokenizer(mapping, ";"); tokenizer
                     .hasMoreTokens();) {
                 String current = tokenizer.nextToken();
                 String[] ops = current.split("->");
-                String[] lhs = ops[0].split(",");
-                List confsToWrite = new ArrayList();
-                for (int j = 0; j < lhs.length; j++) {
-                    if (!confs.contains(lhs[j].trim())) {
-                        confsToWrite.add(lhs[j]);
+                List<String> confsToWrite = new ArrayList<>();
+                for (String lh : ops[0].split(",")) {
+                    if (!confs.contains(lh.trim())) {
+                        confsToWrite.add(lh);
                     }
                 }
                 if (!confsToWrite.isEmpty()) {
                     newMapping.append(mappingSep);
 
                     String sep = "";
-                    for (Iterator it = confsToWrite.iterator(); it.hasNext();) {
+                    for (String confToWrite : confsToWrite) {
                         newMapping.append(sep);
-                        newMapping.append(it.next());
+                        newMapping.append(confToWrite);
                         sep = ",";
                     }
                     if (ops.length == 2) {
@@ -845,7 +840,7 @@ public final class XmlModuleDescriptorUpdater {
         }
 
         private String removeConfigurationsFromList(String list, List confsToRemove) {
-            StringBuffer newList = new StringBuffer();
+            StringBuilder newList = new StringBuilder();
             String listSep = "";
             for (StringTokenizer tokenizer = new StringTokenizer(list, ","); tokenizer
                     .hasMoreTokens();) {
@@ -918,7 +913,7 @@ public final class XmlModuleDescriptorUpdater {
                 // add a default single-level indent until we see indents in the document
                 indentLevels.add("    ");
             }
-            String oneLevel = (String) indentLevels.get(0);
+            String oneLevel = indentLevels.get(0);
             for (int fill = indentLevels.size(); fill <= level; ++fill) {
                 indentLevels.add(indentLevels.get(fill - 1) + oneLevel);
             }
@@ -930,7 +925,7 @@ public final class XmlModuleDescriptorUpdater {
         private String getIndent() {
             int level = context.size() - 1;
             fillIndents(level);
-            return (String) indentLevels.get(level);
+            return indentLevels.get(level);
         }
 
         /**
@@ -956,7 +951,8 @@ public final class XmlModuleDescriptorUpdater {
             // we can add some useful comments
             PrintWriter out = getWriter();
 
-            Map inheritedItems = collateInheritedItems(merged, items);
+            Map<ModuleRevisionId, List<InheritableItem>> inheritedItems = collateInheritedItems(
+                merged, items);
             boolean hasItems = !inheritedItems.isEmpty();
 
             if (hasItems && includeContainer) {
@@ -968,18 +964,17 @@ public final class XmlModuleDescriptorUpdater {
                 justOpen = null;
             }
 
-            for (Iterator parents = inheritedItems.entrySet().iterator(); parents.hasNext();) {
-                Map.Entry entry = (Map.Entry) parents.next();
-                ModuleRevisionId parent = (ModuleRevisionId) entry.getKey();
-                List list = (List) entry.getValue();
+            for (Map.Entry<ModuleRevisionId, List<InheritableItem>> entry : inheritedItems
+                    .entrySet()) {
+                ModuleRevisionId parent = entry.getKey();
+                List<InheritableItem> list = entry.getValue();
 
                 if (justOpen != null) {
                     out.println(">");
                     justOpen = null; // helps endElement() decide how to write close tags
                 }
                 writeInheritanceComment(itemName, parent);
-                for (int c = 0; c < list.size(); ++c) {
-                    InheritableItem item = (InheritableItem) list.get(c);
+                for (InheritableItem item : list) {
                     out.print(getIndent());
                     printer.print(merged, item, out);
                 }
@@ -1015,20 +1010,20 @@ public final class XmlModuleDescriptorUpdater {
          * @return maps parent ModuleRevisionId to a List of InheritedItems imported from that
          *         parent
          */
-        private Map/* <ModuleRevisionId,List> */collateInheritedItems(ModuleDescriptor merged,
-                InheritableItem[] items) {
-            LinkedHashMap/* <ModuleRevisionId,List> */inheritedItems = new LinkedHashMap();
-            for (int i = 0; i < items.length; ++i) {
-                ModuleRevisionId source = items[i].getSourceModule();
+        private Map<ModuleRevisionId, List<InheritableItem>> collateInheritedItems(
+                ModuleDescriptor merged, InheritableItem[] items) {
+            Map<ModuleRevisionId, List<InheritableItem>> inheritedItems = new LinkedHashMap<>();
+            for (InheritableItem item : items) {
+                ModuleRevisionId source = item.getSourceModule();
                 // ignore items that are defined directly in the child descriptor
                 if (source != null
                         && !source.getModuleId().equals(merged.getModuleRevisionId().getModuleId())) {
-                    List accum = (List) inheritedItems.get(source);
+                    List<InheritableItem> accum = inheritedItems.get(source);
                     if (accum == null) {
-                        accum = new ArrayList();
+                        accum = new ArrayList<>();
                         inheritedItems.put(source, accum);
                     }
-                    accum.add(items[i]);
+                    accum.add(item);
                 }
             }
             return inheritedItems;
@@ -1156,7 +1151,7 @@ public final class XmlModuleDescriptorUpdater {
             }
 
             if (!buffers.isEmpty()) {
-                ExtendedBuffer buffer = (ExtendedBuffer) buffers.peek();
+                ExtendedBuffer buffer = buffers.peek();
                 if (buffer.getContext().equals(path)) {
                     buffers.pop();
                     if (buffer.isPrint()) {
@@ -1166,7 +1161,7 @@ public final class XmlModuleDescriptorUpdater {
             }
 
             if (!confAttributeBuffers.isEmpty()) {
-                ExtendedBuffer buffer = (ExtendedBuffer) confAttributeBuffers.peek();
+                ExtendedBuffer buffer = confAttributeBuffers.peek();
                 if (buffer.getContext().equals(path)) {
                     confAttributeBuffers.pop();
                 }
@@ -1223,10 +1218,8 @@ public final class XmlModuleDescriptorUpdater {
                 justOpen = null;
             }
 
-            StringBuffer comment = new StringBuffer();
-            comment.append(ch, start, length);
             write("<!--");
-            write(comment.toString());
+            write(String.valueOf(ch, start, length));
             write("-->");
 
             if (inHeader) {
@@ -1259,10 +1252,7 @@ public final class XmlModuleDescriptorUpdater {
             }
             XMLHelper.parse(inSrc, null, updaterHandler, updaterHandler);
         } catch (ParserConfigurationException e) {
-            IllegalStateException ise = new IllegalStateException(
-                    "impossible to update Ivy files: parser problem");
-            ise.initCause(e);
-            throw ise;
+            throw new IllegalStateException("impossible to update Ivy files: parser problem", e);
         }
     }
 
@@ -1313,7 +1303,7 @@ public final class XmlModuleDescriptorUpdater {
     /**
      * Prints a descriptor item's XML representation
      */
-    protected static interface ItemPrinter {
+    protected interface ItemPrinter {
         /**
          * Print an XML representation of <code>item</code> to <code>out</code>.
          *
@@ -1324,7 +1314,7 @@ public final class XmlModuleDescriptorUpdater {
          *            {@link Configuration}
          * @param out PrintWriter
          */
-        public void print(ModuleDescriptor parent, Object item, PrintWriter out);
+        void print(ModuleDescriptor parent, Object item, PrintWriter out);
     }
 
     protected static class DependencyPrinter implements ItemPrinter {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
index 8792f72..db8c469 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -67,17 +66,15 @@ public final class XmlModuleDescriptorWriter {
         if (output.getParentFile() != null) {
             output.getParentFile().mkdirs();
         }
-        PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output),
-                "UTF-8"));
-        try {
+        try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output),
+                "UTF-8"))) {
             out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
             if (licenseHeader != null) {
                 out.print(licenseHeader);
             }
-            StringBuffer xmlNamespace = new StringBuffer();
-            Map namespaces = md.getExtraAttributesNamespaces();
-            for (Iterator iter = namespaces.entrySet().iterator(); iter.hasNext();) {
-                Entry ns = (Entry) iter.next();
+            StringBuilder xmlNamespace = new StringBuilder();
+            Map<String, String> namespaces = md.getExtraAttributesNamespaces();
+            for (Map.Entry<String, String> ns : namespaces.entrySet()) {
                 xmlNamespace.append(" xmlns:").append(ns.getKey()).append("=\"")
                         .append(ns.getValue()).append("\"");
             }
@@ -93,8 +90,6 @@ public final class XmlModuleDescriptorWriter {
             printPublications(md, out);
             printDependencies(md, out);
             out.println("</ivy-module>");
-        } finally {
-            out.close();
         }
     }
 
@@ -102,8 +97,7 @@ public final class XmlModuleDescriptorWriter {
         DependencyDescriptor[] dds = md.getDependencies();
         if (dds.length > 0) {
             out.println("\t<dependencies>");
-            for (int i = 0; i < dds.length; i++) {
-                DependencyDescriptor dep = dds[i];
+            for (DependencyDescriptor dep : dds) {
                 out.print("\t\t");
                 printDependency(md, dep, out);
             }
@@ -188,27 +182,21 @@ public final class XmlModuleDescriptorWriter {
     }
 
     private static void printAllMediators(ModuleDescriptor md, PrintWriter out) {
-        Map/* <MapMatcher, DependencyDescriptorMediator> */mediators = md
+        Map<MapMatcher, DependencyDescriptorMediator> mediators = md
                 .getAllDependencyDescriptorMediators().getAllRules();
 
-        for (Iterator iterator = mediators.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry mediatorRule = (Map.Entry) iterator.next();
-            MapMatcher matcher = (MapMatcher) mediatorRule.getKey();
-            DependencyDescriptorMediator mediator = (DependencyDescriptorMediator) mediatorRule
-                    .getValue();
+        for (Map.Entry<MapMatcher, DependencyDescriptorMediator> mediatorRule : mediators.entrySet()) {
+            MapMatcher matcher = mediatorRule.getKey();
+            DependencyDescriptorMediator mediator = mediatorRule.getValue();
 
             if (mediator instanceof OverrideDependencyDescriptorMediator) {
                 OverrideDependencyDescriptorMediator oddm = (OverrideDependencyDescriptorMediator) mediator;
 
-                out.print("\t\t<override");
-                out.print(" org=\""
-                        + XMLHelper.escape((String) matcher.getAttributes().get(
-                            IvyPatternHelper.ORGANISATION_KEY)) + "\"");
-                out.print(" module=\""
-                        + XMLHelper.escape((String) matcher.getAttributes().get(
-                            IvyPatternHelper.MODULE_KEY)) + "\"");
-                out.print(" matcher=\"" + XMLHelper.escape(matcher.getPatternMatcher().getName())
-                        + "\"");
+                out.print(String.format("\t\t<override org=\"%s\" module=\"%s\" matcher=\"%s\"",
+                        XMLHelper.escape(matcher.getAttributes().get(IvyPatternHelper.ORGANISATION_KEY)),
+                        XMLHelper.escape(matcher.getAttributes().get(IvyPatternHelper.MODULE_KEY)),
+                        XMLHelper.escape(matcher.getPatternMatcher().getName())
+                ));
                 if (oddm.getBranch() != null) {
                     out.print(" branch=\"" + XMLHelper.escape(oddm.getBranch()) + "\"");
                 }
@@ -226,17 +214,17 @@ public final class XmlModuleDescriptorWriter {
     private static void printAllExcludes(ModuleDescriptor md, PrintWriter out) {
         ExcludeRule[] excludes = md.getAllExcludeRules();
         if (excludes.length > 0) {
-            for (int j = 0; j < excludes.length; j++) {
+            for (ExcludeRule exclude : excludes) {
                 out.print("\t\t<exclude");
                 out.print(" org=\""
-                        + XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation())
+                        + XMLHelper.escape(exclude.getId().getModuleId().getOrganisation())
                         + "\"");
                 out.print(" module=\""
-                        + XMLHelper.escape(excludes[j].getId().getModuleId().getName()) + "\"");
-                out.print(" artifact=\"" + XMLHelper.escape(excludes[j].getId().getName()) + "\"");
-                out.print(" type=\"" + XMLHelper.escape(excludes[j].getId().getType()) + "\"");
-                out.print(" ext=\"" + XMLHelper.escape(excludes[j].getId().getExt()) + "\"");
-                String[] ruleConfs = excludes[j].getConfigurations();
+                        + XMLHelper.escape(exclude.getId().getModuleId().getName()) + "\"");
+                out.print(" artifact=\"" + XMLHelper.escape(exclude.getId().getName()) + "\"");
+                out.print(" type=\"" + XMLHelper.escape(exclude.getId().getType()) + "\"");
+                out.print(" ext=\"" + XMLHelper.escape(exclude.getId().getExt()) + "\"");
+                String[] ruleConfs = exclude.getConfigurations();
                 if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < ruleConfs.length; k++) {
@@ -247,7 +235,7 @@ public final class XmlModuleDescriptorWriter {
                     }
                     out.print("\"");
                 }
-                out.print(" matcher=\"" + XMLHelper.escape(excludes[j].getMatcher().getName())
+                out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName())
                         + "\"");
                 out.println("/>");
             }
@@ -257,17 +245,17 @@ public final class XmlModuleDescriptorWriter {
     private static void printDependencyExcludeRules(ModuleDescriptor md, PrintWriter out,
             ExcludeRule[] excludes) {
         if (excludes.length > 0) {
-            for (int j = 0; j < excludes.length; j++) {
+            for (ExcludeRule exclude : excludes) {
                 out.print("\t\t\t<exclude");
                 out.print(" org=\""
-                        + XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation())
+                        + XMLHelper.escape(exclude.getId().getModuleId().getOrganisation())
                         + "\"");
                 out.print(" module=\""
-                        + XMLHelper.escape(excludes[j].getId().getModuleId().getName()) + "\"");
-                out.print(" name=\"" + XMLHelper.escape(excludes[j].getId().getName()) + "\"");
-                out.print(" type=\"" + XMLHelper.escape(excludes[j].getId().getType()) + "\"");
-                out.print(" ext=\"" + XMLHelper.escape(excludes[j].getId().getExt()) + "\"");
-                String[] ruleConfs = excludes[j].getConfigurations();
+                        + XMLHelper.escape(exclude.getId().getModuleId().getName()) + "\"");
+                out.print(" name=\"" + XMLHelper.escape(exclude.getId().getName()) + "\"");
+                out.print(" type=\"" + XMLHelper.escape(exclude.getId().getType()) + "\"");
+                out.print(" ext=\"" + XMLHelper.escape(exclude.getId().getExt()) + "\"");
+                String[] ruleConfs = exclude.getConfigurations();
                 if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < ruleConfs.length; k++) {
@@ -278,7 +266,7 @@ public final class XmlModuleDescriptorWriter {
                     }
                     out.print("\"");
                 }
-                out.print(" matcher=\"" + XMLHelper.escape(excludes[j].getMatcher().getName())
+                out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName())
                         + "\"");
                 out.println("/>");
             }
@@ -288,12 +276,12 @@ public final class XmlModuleDescriptorWriter {
     private static void printDependencyIncludeRules(ModuleDescriptor md, PrintWriter out,
             IncludeRule[] includes) {
         if (includes.length > 0) {
-            for (int j = 0; j < includes.length; j++) {
+            for (IncludeRule include : includes) {
                 out.print("\t\t\t<include");
-                out.print(" name=\"" + XMLHelper.escape(includes[j].getId().getName()) + "\"");
-                out.print(" type=\"" + XMLHelper.escape(includes[j].getId().getType()) + "\"");
-                out.print(" ext=\"" + XMLHelper.escape(includes[j].getId().getExt()) + "\"");
-                String[] ruleConfs = includes[j].getConfigurations();
+                out.print(" name=\"" + XMLHelper.escape(include.getId().getName()) + "\"");
+                out.print(" type=\"" + XMLHelper.escape(include.getId().getType()) + "\"");
+                out.print(" ext=\"" + XMLHelper.escape(include.getId().getExt()) + "\"");
+                String[] ruleConfs = include.getConfigurations();
                 if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < ruleConfs.length; k++) {
@@ -304,7 +292,7 @@ public final class XmlModuleDescriptorWriter {
                     }
                     out.print("\"");
                 }
-                out.print(" matcher=\"" + XMLHelper.escape(includes[j].getMatcher().getName())
+                out.print(" matcher=\"" + XMLHelper.escape(include.getMatcher().getName())
                         + "\"");
                 out.println("/>");
             }
@@ -314,12 +302,12 @@ public final class XmlModuleDescriptorWriter {
     private static void printDependencyArtefacts(ModuleDescriptor md, PrintWriter out,
             DependencyArtifactDescriptor[] depArtifacts) {
         if (depArtifacts.length > 0) {
-            for (int j = 0; j < depArtifacts.length; j++) {
+            for (DependencyArtifactDescriptor depArtifact : depArtifacts) {
                 out.print("\t\t\t<artifact");
-                out.print(" name=\"" + XMLHelper.escape(depArtifacts[j].getName()) + "\"");
-                out.print(" type=\"" + XMLHelper.escape(depArtifacts[j].getType()) + "\"");
-                out.print(" ext=\"" + XMLHelper.escape(depArtifacts[j].getExt()) + "\"");
-                String[] dadconfs = depArtifacts[j].getConfigurations();
+                out.print(" name=\"" + XMLHelper.escape(depArtifact.getName()) + "\"");
+                out.print(" type=\"" + XMLHelper.escape(depArtifact.getType()) + "\"");
+                out.print(" ext=\"" + XMLHelper.escape(depArtifact.getExt()) + "\"");
+                String[] dadconfs = depArtifact.getConfigurations();
                 if (!Arrays.asList(dadconfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < dadconfs.length; k++) {
@@ -330,7 +318,7 @@ public final class XmlModuleDescriptorWriter {
                     }
                     out.print("\"");
                 }
-                printExtraAttributes(depArtifacts[j], out, " ");
+                printExtraAttributes(depArtifact, out, " ");
                 out.println("/>");
             }
         }
@@ -362,16 +350,15 @@ public final class XmlModuleDescriptorWriter {
      * @param prefix
      *            the string to write before writing the attributes (if any)
      */
-    private static void printExtraAttributes(Map extra, PrintWriter out, String prefix) {
+    private static void printExtraAttributes(Map<String, String> extra, PrintWriter out, String prefix) {
         if (extra == null) {
             return;
         }
 
         String delim = prefix;
-        for (Iterator iter = extra.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            out.print(delim + entry.getKey() + "=\""
-                    + XMLHelper.escape(entry.getValue().toString()) + "\"");
+        for (Map.Entry<String, String> entry : extra.entrySet()) {
+            out.print(String.format("%s%s=\"%s\"", delim, entry.getKey(),
+                    XMLHelper.escape(entry.getValue())));
             delim = " ";
         }
     }
@@ -379,13 +366,13 @@ public final class XmlModuleDescriptorWriter {
     private static void printPublications(ModuleDescriptor md, PrintWriter out) {
         out.println("\t<publications>");
         Artifact[] artifacts = md.getAllArtifacts();
-        for (int i = 0; i < artifacts.length; i++) {
+        for (Artifact artifact : artifacts) {
             out.print("\t\t<artifact");
-            out.print(" name=\"" + XMLHelper.escape(artifacts[i].getName()) + "\"");
-            out.print(" type=\"" + XMLHelper.escape(artifacts[i].getType()) + "\"");
-            out.print(" ext=\"" + XMLHelper.escape(artifacts[i].getExt()) + "\"");
-            out.print(" conf=\"" + XMLHelper.escape(getConfs(md, artifacts[i])) + "\"");
-            printExtraAttributes(artifacts[i], out, " ");
+            out.print(" name=\"" + XMLHelper.escape(artifact.getName()) + "\"");
+            out.print(" type=\"" + XMLHelper.escape(artifact.getType()) + "\"");
+            out.print(" ext=\"" + XMLHelper.escape(artifact.getExt()) + "\"");
+            out.print(" conf=\"" + XMLHelper.escape(getConfs(md, artifact)) + "\"");
+            printExtraAttributes(artifact, out, " ");
             out.println("/>");
         }
         out.println("\t</publications>");
@@ -395,8 +382,7 @@ public final class XmlModuleDescriptorWriter {
         Configuration[] confs = md.getConfigurations();
         if (confs.length > 0) {
             out.println("\t<configurations>");
-            for (int i = 0; i < confs.length; i++) {
-                Configuration conf = confs[i];
+            for (Configuration conf : confs) {
                 out.print("\t\t");
                 printConfiguration(conf, out);
             }
@@ -463,8 +449,7 @@ public final class XmlModuleDescriptorWriter {
         if (requireInnerInfoElement(md)) {
             out.println("\t>");
             ExtendsDescriptor[] parents = md.getInheritedDescriptors();
-            for (int i = 0; i < parents.length; i++) {
-                ExtendsDescriptor parent = parents[i];
+            for (ExtendsDescriptor parent : parents) {
                 ModuleRevisionId mrid = parent.getParentRevisionId();
                 out.print("\t\t<extends organisation=\"" + XMLHelper.escape(mrid.getOrganisation())
                         + "\"" + " module=\"" + XMLHelper.escape(mrid.getName()) + "\""
@@ -478,8 +463,7 @@ public final class XmlModuleDescriptorWriter {
                 out.println("/>");
             }
             License[] licenses = md.getLicenses();
-            for (int i = 0; i < licenses.length; i++) {
-                License license = licenses[i];
+            for (License license : licenses) {
                 out.print("\t\t<license ");
                 if (license.getName() != null) {
                     out.print("name=\"" + XMLHelper.escape(license.getName()) + "\" ");
@@ -561,12 +545,12 @@ public final class XmlModuleDescriptorWriter {
     }
 
     private static String getConfs(ModuleDescriptor md, Artifact artifact) {
-        StringBuffer ret = new StringBuffer();
+        StringBuilder ret = new StringBuilder();
 
         String[] confs = md.getConfigurationsNames();
-        for (int i = 0; i < confs.length; i++) {
-            if (Arrays.asList(md.getArtifacts(confs[i])).contains(artifact)) {
-                ret.append(confs[i]).append(",");
+        for (String conf : confs) {
+            if (Arrays.asList(md.getArtifacts(conf)).contains(artifact)) {
+                ret.append(conf).append(",");
             }
         }
         if (ret.length() > 0) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java b/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java
index c2b853b..49ff22c 100644
--- a/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java
+++ b/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java
@@ -50,18 +50,16 @@ public class LogReportOutputter implements ReportOutputter {
 
         if (settings.logModulesInUse() && ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
             Message.info("\t:: modules in use:");
-            List dependencies = new ArrayList(report.getDependencies());
+            List<IvyNode> dependencies = new ArrayList<>(report.getDependencies());
             Collections.sort(dependencies);
             if (dependencies.size() > 0) {
                 String[] confs = report.getConfigurations();
-                for (int i = 0; i < dependencies.size(); i++) {
-                    IvyNode node = (IvyNode) dependencies.get(i);
+                for (IvyNode node : dependencies) {
                     if (node.isCompletelyEvicted() || node.hasProblem()) {
                         continue;
                     }
-                    List nodeConfs = new ArrayList(confs.length);
-                    for (int j = 0; j < confs.length; j++) {
-                        String conf = confs[j];
+                    List<String> nodeConfs = new ArrayList<>(confs.length);
+                    for (String conf : confs) {
                         if (report.getConfigurationReport(conf).getModuleRevisionIds()
                                 .contains(node.getResolvedId())) {
                             nodeConfs.add(conf);
@@ -77,22 +75,21 @@ public class LogReportOutputter implements ReportOutputter {
 
         if (evicted.length > 0 && ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
             Message.info("\t:: evicted modules:");
-            for (int i = 0; i < evicted.length; i++) {
-                Collection allEvictingNodes = evicted[i].getAllEvictingNodesDetails();
+            for (IvyNode evictedNode : evicted) {
+                Collection<String> allEvictingNodes = evictedNode.getAllEvictingNodesDetails();
                 if (allEvictingNodes == null) {
-                    Message.info("\t" + evicted[i] + " transitively in "
-                            + Arrays.asList(evicted[i].getEvictedConfs()));
+                    Message.info("\t" + evictedNode + " transitively in "
+                            + Arrays.asList(evictedNode.getEvictedConfs()));
                 } else if (allEvictingNodes.isEmpty()) {
-                    Message.info("\t" + evicted[i] + " by [] ("
-                            + evicted[i].getAllEvictingConflictManagers() + ") in "
-                            + Arrays.asList(evicted[i].getEvictedConfs()));
+                    Message.info(
+                        "\t" + evictedNode + " by [] (" + evictedNode.getAllEvictingConflictManagers()
+                                + ") in " + Arrays.asList(evictedNode.getEvictedConfs()));
                 } else {
-                    Message.info("\t" + evicted[i] + " by " + allEvictingNodes + " in "
-                            + Arrays.asList(evicted[i].getEvictedConfs()));
+                    Message.info("\t" + evictedNode + " by " + allEvictingNodes + " in "
+                            + Arrays.asList(evictedNode.getEvictedConfs()));
                 }
-                String[] confs = evicted[i].getEvictedConfs();
-                for (int j = 0; j < confs.length; j++) {
-                    EvictionData evictedData = evicted[i].getEvictedData(confs[j]);
+                for (String conf : evictedNode.getEvictedConfs()) {
+                    EvictionData evictedData = evictedNode.getEvictedData(conf);
                     if (evictedData.getParent() != null) {
                         Message.verbose("\t  in " + evictedData.getParent() + " with "
                                 + evictedData.getConflictManager());
@@ -128,9 +125,8 @@ public class LogReportOutputter implements ReportOutputter {
             Message.rawinfo(line.toString());
             Message.rawinfo("\t" + new String(sep));
 
-            String[] confs = report.getConfigurations();
-            for (int i = 0; i < confs.length; i++) {
-                output(report.getConfigurationReport(confs[i]));
+            for (String conf : report.getConfigurations()) {
+                output(report.getConfigurationReport(conf));
             }
             Message.rawinfo("\t" + new String(sep));
         }
@@ -141,8 +137,8 @@ public class LogReportOutputter implements ReportOutputter {
             Message.warn("\t::          UNRESOLVED DEPENDENCIES         ::");
             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
         }
-        for (int i = 0; i < unresolved.length; i++) {
-            Message.warn("\t:: " + unresolved[i] + ": " + unresolved[i].getProblemMessage());
+        for (IvyNode anUnresolved : unresolved) {
+            Message.warn("\t:: " + anUnresolved + ": " + anUnresolved.getProblemMessage());
         }
         if (unresolved.length > 0) {
             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
@@ -155,8 +151,8 @@ public class LogReportOutputter implements ReportOutputter {
             Message.warn("\t:: ^ see resolution messages for details  ^ ::");
             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
         }
-        for (int i = 0; i < errors.length; i++) {
-            Message.warn("\t:: " + errors[i].getArtifact());
+        for (ArtifactDownloadReport error : errors) {
+            Message.warn("\t:: " + error.getArtifact());
         }
         if (errors.length > 0) {
             Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java b/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java
index 0c5d9f7..3e0f801 100644
--- a/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java
+++ b/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java
@@ -43,8 +43,8 @@ public class XmlReportOutputter implements ReportOutputter {
     public void output(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options)
             throws IOException {
         String[] confs = report.getConfigurations();
-        for (int i = 0; i < confs.length; i++) {
-            output(report.getConfigurationReport(confs[i]), report.getResolveId(), confs, cacheMgr);
+        for (String conf : confs) {
+            output(report.getConfigurationReport(conf), report.getResolveId(), confs, cacheMgr);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/report/XmlReportParser.java b/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
index a0d5737..a914ad2 100644
--- a/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
+++ b/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
@@ -65,7 +65,7 @@ public class XmlReportParser {
             private boolean isDefault;
 
             // Use a TreeMap to order by
-            private SortedMap<Integer, List<ArtifactDownloadReport>> revisionsMap = new TreeMap<Integer, List<ArtifactDownloadReport>>();
+            private SortedMap<Integer, List<ArtifactDownloadReport>> revisionsMap = new TreeMap<>();
 
             private List<ArtifactDownloadReport> revisionArtifacts = null;
 
@@ -75,7 +75,7 @@ public class XmlReportParser {
                     organisation = attributes.getValue("organisation");
                     module = attributes.getValue("name");
                 } else if ("revision".equals(qName)) {
-                    revisionArtifacts = new ArrayList<ArtifactDownloadReport>();
+                    revisionArtifacts = new ArrayList<>();
                     branch = attributes.getValue("branch");
                     revision = attributes.getValue("name");
                     isDefault = Boolean.valueOf(attributes.getValue("default"));
@@ -83,14 +83,14 @@ public class XmlReportParser {
                     // report generated with a previous version,
                     // in which case, we put it at the last position
                     String pos = attributes.getValue("position");
-                    position = pos == null ? getMaxPos() + 1 : Integer.valueOf(pos).intValue();
+                    position = pos == null ? getMaxPos() + 1 : Integer.valueOf(pos);
                     if (attributes.getValue("error") != null) {
                         hasError = true;
                         skip = true;
                     } else if (attributes.getValue("evicted") != null) {
                         skip = true;
                     } else {
-                        revisionsMap.put(new Integer(position), revisionArtifacts);
+                        revisionsMap.put(position, revisionArtifacts);
                         mrid = ModuleRevisionId.newInstance(organisation, module, branch, revision,
                             ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
                         mrids.add(mrid);
@@ -186,7 +186,7 @@ public class XmlReportParser {
                     String name = attributes.getValue("module");
                     String branch = attributes.getValue("branch");
                     String revision = attributes.getValue("revision");
-                    Map<String, String> extraAttributes = new HashMap<String, String>();
+                    Map<String, String> extraAttributes = new HashMap<>();
                     for (int i = 0; i < attributes.getLength(); i++) {
                         String attName = attributes.getQName(i);
                         if (attName.startsWith("extra-")) {
@@ -217,22 +217,21 @@ public class XmlReportParser {
 
             private int getMaxPos() {
                 return revisionsMap.isEmpty() ? -1
-                        : ((Integer) revisionsMap.keySet().toArray()[revisionsMap.size() - 1])
-                                .intValue();
+                        : (Integer) revisionsMap.keySet().toArray()[revisionsMap.size() - 1];
             }
         }
 
-        private List<ModuleRevisionId> mrids = new ArrayList<ModuleRevisionId>();
+        private List<ModuleRevisionId> mrids = new ArrayList<>();
 
-        private List<ModuleRevisionId> defaultMrids = new ArrayList<ModuleRevisionId>();
+        private List<ModuleRevisionId> defaultMrids = new ArrayList<>();
 
-        private List<ModuleRevisionId> realMrids = new ArrayList<ModuleRevisionId>();
+        private List<ModuleRevisionId> realMrids = new ArrayList<>();
 
-        private List<Artifact> artifacts = new ArrayList<Artifact>();
+        private List<Artifact> artifacts = new ArrayList<>();
 
-        private List<ArtifactDownloadReport> artifactReports = new ArrayList<ArtifactDownloadReport>();
+        private List<ArtifactDownloadReport> artifactReports = new ArrayList<>();
 
-        private Map<ModuleRevisionId, MetadataArtifactDownloadReport> metadataReports = new HashMap<ModuleRevisionId, MetadataArtifactDownloadReport>();
+        private Map<ModuleRevisionId, MetadataArtifactDownloadReport> metadataReports = new HashMap<>();
 
         private ModuleRevisionId mRevisionId;
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java b/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
index 080c658..9f33c01 100644
--- a/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
+++ b/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
@@ -25,10 +25,8 @@ import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.ivy.core.cache.ArtifactOrigin;
 import org.apache.ivy.core.module.descriptor.License;
@@ -76,11 +74,10 @@ public class XmlReportWriter {
         if (mrid.getBranch() != null) {
             out.println("\t\tbranch=\"" + XMLHelper.escape(mrid.getBranch()) + "\"");
         }
-        Map extraAttributes = mrid.getExtraAttributes();
-        for (Iterator it = extraAttributes.entrySet().iterator(); it.hasNext();) {
-            Map.Entry entry = (Entry) it.next();
+        Map<String, String> extraAttributes = mrid.getExtraAttributes();
+        for (Map.Entry<String, String> entry : extraAttributes.entrySet()) {
             out.println("\t\textra-" + entry.getKey() + "=\""
-                    + XMLHelper.escape(entry.getValue().toString()) + "\"");
+                    + XMLHelper.escape(entry.getValue()) + "\"");
         }
         out.println("\t\tconf=\"" + XMLHelper.escape(report.getConfiguration()) + "\"");
         out.println("\t\tconfs=\"" + XMLHelper.escape(StringUtils.join(confs, ", ")) + "\"");
@@ -89,14 +86,12 @@ public class XmlReportWriter {
         out.println("\t<dependencies>");
 
         // create a list of ModuleRevisionIds indicating the position for each dependency
-        List dependencies = new ArrayList(report.getModuleRevisionIds());
+        List<ModuleRevisionId> dependencies = new ArrayList<>(report.getModuleRevisionIds());
 
-        for (Iterator iter = report.getModuleIds().iterator(); iter.hasNext();) {
-            ModuleId mid = (ModuleId) iter.next();
+        for (ModuleId mid : report.getModuleIds()) {
             out.println("\t\t<module organisation=\"" + XMLHelper.escape(mid.getOrganisation())
                     + "\"" + " name=\"" + XMLHelper.escape(mid.getName()) + "\">");
-            for (Iterator it2 = report.getNodes(mid).iterator(); it2.hasNext();) {
-                IvyNode dep = (IvyNode) it2.next();
+            for (IvyNode dep : report.getNodes(mid)) {
                 ouputRevision(report, out, dependencies, dep);
             }
             out.println("\t\t</module>");
@@ -107,13 +102,13 @@ public class XmlReportWriter {
     }
 
     private void ouputRevision(ConfigurationResolveReport report, PrintWriter out,
-            List dependencies, IvyNode dep) {
-        Map extraAttributes;
+            List<ModuleRevisionId> dependencies, IvyNode dep) {
+        Map<String, String> extraAttributes;
         ModuleDescriptor md = null;
         if (dep.getModuleRevision() != null) {
             md = dep.getModuleRevision().getDescriptor();
         }
-        StringBuffer details = new StringBuffer();
+        StringBuilder details = new StringBuilder();
         if (dep.isLoaded()) {
             details.append(" status=\"");
             details.append(XMLHelper.escape(dep.getDescriptor().getStatus()));
@@ -145,36 +140,32 @@ public class XmlReportWriter {
         if (md != null && md.getHomePage() != null) {
             details.append(" homepage=\"").append(XMLHelper.escape(md.getHomePage())).append("\"");
         }
-        extraAttributes = md != null ? md.getExtraAttributes() : dep.getResolvedId()
+        extraAttributes = (md != null) ? md.getExtraAttributes() : dep.getResolvedId()
                 .getExtraAttributes();
-        for (Iterator iterator = extraAttributes.keySet().iterator(); iterator.hasNext();) {
-            String attName = (String) iterator.next();
-            details.append(" extra-").append(attName).append("=\"")
-                    .append(XMLHelper.escape(extraAttributes.get(attName).toString())).append("\"");
+        for (Map.Entry<String, String> entry : extraAttributes.entrySet()) {
+            details.append(" extra-").append(entry.getKey()).append("=\"")
+                    .append(XMLHelper.escape(entry.getValue())).append("\"");
         }
-        String defaultValue = dep.getDescriptor() != null ? " default=\""
-                + dep.getDescriptor().isDefault() + "\"" : "";
-        int position = dependencies.indexOf(dep.getResolvedId());
-        out.println("\t\t\t<revision name=\""
-                + XMLHelper.escape(dep.getResolvedId().getRevision())
-                + "\""
-                + (dep.getResolvedId().getBranch() == null ? "" : " branch=\""
-                        + XMLHelper.escape(dep.getResolvedId().getBranch()) + "\"") + details
-                + " downloaded=\"" + dep.isDownloaded() + "\"" + " searched=\"" + dep.isSearched()
-                + "\"" + defaultValue + " conf=\""
-                + toString(dep.getConfigurations(report.getConfiguration())) + "\""
-                + " position=\"" + position + "\">");
+        out.println(String.format("\t\t\t<revision name=\"%s\"%s%s downloaded=\"%s\" searched=\"%s\"%s conf=\"%s\" position=\"%d\">",
+                XMLHelper.escape(dep.getResolvedId().getRevision()),
+                (dep.getResolvedId().getBranch() == null) ? "" : " branch=\""
+                + XMLHelper.escape(dep.getResolvedId().getBranch()) + "\"",
+                details, dep.isDownloaded(), dep.isSearched(),
+                (dep.getDescriptor() == null) ? "" : " default=\""
+                + dep.getDescriptor().isDefault() + "\"",
+                toString(dep.getConfigurations(report.getConfiguration())),
+                dependencies.indexOf(dep.getResolvedId())));
         if (md != null) {
             License[] licenses = md.getLicenses();
-            for (int i = 0; i < licenses.length; i++) {
+            for (License license : licenses) {
                 String lurl;
-                if (licenses[i].getUrl() != null) {
-                    lurl = " url=\"" + XMLHelper.escape(licenses[i].getUrl()) + "\"";
+                if (license.getUrl() != null) {
+                    lurl = " url=\"" + XMLHelper.escape(license.getUrl()) + "\"";
                 } else {
                     lurl = "";
                 }
-                out.println("\t\t\t\t<license name=\"" + XMLHelper.escape(licenses[i].getName())
-                        + "\"" + lurl + "/>");
+                out.println("\t\t\t\t<license name=\"" + XMLHelper.escape(license.getName()) + "\""
+                        + lurl + "/>");
             }
         }
         outputMetadataArtifact(out, dep);
@@ -188,10 +179,9 @@ public class XmlReportWriter {
             IvyNode dep) {
         if (dep.isEvicted(report.getConfiguration())) {
             EvictionData ed = dep.getEvictedData(report.getConfiguration());
-            Collection selected = ed.getSelected();
+            Collection<IvyNode> selected = ed.getSelected();
             if (selected != null) {
-                for (Iterator it3 = selected.iterator(); it3.hasNext();) {
-                    IvyNode sel = (IvyNode) it3.next();
+                for (IvyNode sel : selected) {
                     out.println("\t\t\t\t<evicted-by rev=\""
                             + XMLHelper.escape(sel.getResolvedId().getRevision()) + "\"/>");
                 }
@@ -230,69 +220,50 @@ public class XmlReportWriter {
 
     private void outputCallers(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) {
         Caller[] callers = dep.getCallers(report.getConfiguration());
-        for (int i = 0; i < callers.length; i++) {
-            StringBuffer callerDetails = new StringBuffer();
-            Map callerExtraAttributes = callers[i].getDependencyDescriptor().getExtraAttributes();
-            for (Iterator iterator = callerExtraAttributes.keySet().iterator(); iterator.hasNext();) {
-                String attName = (String) iterator.next();
-                callerDetails.append(" extra-").append(attName).append("=\"")
-                        .append(XMLHelper.escape(callerExtraAttributes.get(attName).toString()))
-                        .append("\"");
+        for (Caller caller : callers) {
+            StringBuilder callerDetails = new StringBuilder();
+            Map<String, String> callerExtraAttributes = caller.getDependencyDescriptor()
+                    .getExtraAttributes();
+            for (Map.Entry<String, String> entry : callerExtraAttributes.entrySet()) {
+                callerDetails.append(" extra-").append(entry.getKey()).append("=\"")
+                        .append(XMLHelper.escape(entry.getValue())).append("\"");
             }
 
-            out.println("\t\t\t\t<caller organisation=\""
-                    + XMLHelper.escape(callers[i].getModuleRevisionId().getOrganisation())
-                    + "\""
-                    + " name=\""
-                    + XMLHelper.escape(callers[i].getModuleRevisionId().getName())
-                    + "\""
-                    + " conf=\""
-                    + XMLHelper.escape(toString(callers[i].getCallerConfigurations()))
-                    + "\""
-                    + " rev=\""
-                    + XMLHelper.escape(callers[i].getAskedDependencyId(dep.getData()).getRevision())
-                    + "\""
-                    + " rev-constraint-default=\""
-                    + XMLHelper.escape(callers[i].getDependencyDescriptor()
-                            .getDependencyRevisionId().getRevision())
-                    + "\""
-                    + " rev-constraint-dynamic=\""
-                    + XMLHelper.escape(callers[i].getDependencyDescriptor()
-                            .getDynamicConstraintDependencyRevisionId().getRevision()) + "\""
-                    + " callerrev=\""
-                    + XMLHelper.escape(callers[i].getModuleRevisionId().getRevision()) + "\""
-                    + callerDetails + "/>");
+            out.println(String.format("\t\t\t\t<caller organisation=\"%s\" name=\"%s\" conf=\"%s\" rev=\"%s\" rev-constraint-default=\"%s\" rev-constraint-dynamic=\"%s\" callerrev=\"%s\"%s/>",
+                    XMLHelper.escape(caller.getModuleRevisionId().getOrganisation()),
+                    XMLHelper.escape(caller.getModuleRevisionId().getName()),
+                    XMLHelper.escape(toString(caller.getCallerConfigurations())),
+                    XMLHelper.escape(caller.getAskedDependencyId(dep.getData()).getRevision()),
+                    XMLHelper.escape(caller.getDependencyDescriptor().getDependencyRevisionId().getRevision()),
+                    XMLHelper.escape(caller.getDependencyDescriptor().getDynamicConstraintDependencyRevisionId().getRevision()),
+                    XMLHelper.escape(caller.getModuleRevisionId().getRevision()), callerDetails));
         }
     }
 
     private void outputArtifacts(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) {
-        Map extraAttributes;
-        ArtifactDownloadReport[] adr = report.getDownloadReports(dep.getResolvedId());
         out.println("\t\t\t\t<artifacts>");
-        for (int i = 0; i < adr.length; i++) {
-            out.print("\t\t\t\t\t<artifact name=\"" + XMLHelper.escape(adr[i].getName())
-                    + "\" type=\"" + XMLHelper.escape(adr[i].getType()) + "\" ext=\""
-                    + XMLHelper.escape(adr[i].getExt()) + "\"");
-            extraAttributes = adr[i].getArtifact().getExtraAttributes();
-            for (Iterator iterator = extraAttributes.keySet().iterator(); iterator.hasNext();) {
-                String attName = (String) iterator.next();
-                out.print(" extra-" + attName + "=\""
-                        + XMLHelper.escape(extraAttributes.get(attName).toString()) + "\"");
+        for (ArtifactDownloadReport adr : report.getDownloadReports(dep.getResolvedId())) {
+            out.print("\t\t\t\t\t<artifact name=\"" + XMLHelper.escape(adr.getName())
+                    + "\" type=\"" + XMLHelper.escape(adr.getType()) + "\" ext=\""
+                    + XMLHelper.escape(adr.getExt()) + "\"");
+            for (Map.Entry<String, String> entry : adr.getArtifact().getExtraAttributes().entrySet()) {
+                out.print(" extra-" + entry.getKey() + "=\""
+                        + XMLHelper.escape(entry.getValue()) + "\"");
             }
-            out.print(" status=\"" + XMLHelper.escape(adr[i].getDownloadStatus().toString()) + "\"");
-            out.print(" details=\"" + XMLHelper.escape(adr[i].getDownloadDetails()) + "\"");
-            out.print(" size=\"" + adr[i].getSize() + "\"");
-            out.print(" time=\"" + adr[i].getDownloadTimeMillis() + "\"");
-            if (adr[i].getLocalFile() != null) {
+            out.print(" status=\"" + XMLHelper.escape(adr.getDownloadStatus().toString()) + "\"");
+            out.print(" details=\"" + XMLHelper.escape(adr.getDownloadDetails()) + "\"");
+            out.print(" size=\"" + adr.getSize() + "\"");
+            out.print(" time=\"" + adr.getDownloadTimeMillis() + "\"");
+            if (adr.getLocalFile() != null) {
                 out.print(" location=\""
-                        + XMLHelper.escape(adr[i].getLocalFile().getAbsolutePath()) + "\"");
+                        + XMLHelper.escape(adr.getLocalFile().getAbsolutePath()) + "\"");
             }
-            if (adr[i].getUnpackedLocalFile() != null) {
+            if (adr.getUnpackedLocalFile() != null) {
                 out.print(" unpackedFile=\""
-                        + XMLHelper.escape(adr[i].getUnpackedLocalFile().getAbsolutePath()) + "\"");
+                        + XMLHelper.escape(adr.getUnpackedLocalFile().getAbsolutePath()) + "\"");
             }
 
-            ArtifactOrigin origin = adr[i].getArtifactOrigin();
+            ArtifactOrigin origin = adr.getArtifactOrigin();
             if (origin != null) {
                 out.println(">");
                 out.println("\t\t\t\t\t\t<origin-location is-local=\""
@@ -307,12 +278,12 @@ public class XmlReportWriter {
     }
 
     private String toString(String[] strs) {
-        StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < strs.length; i++) {
-            buf.append(strs[i]);
-            if (i + 1 < strs.length) {
+        StringBuilder buf = new StringBuilder();
+        for (String str : strs) {
+            if (buf.length() > 0) {
                 buf.append(", ");
             }
+            buf.append(str);
         }
         return XMLHelper.escape(buf.toString());
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/RepositoryCopyProgressListener.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/RepositoryCopyProgressListener.java b/src/java/org/apache/ivy/plugins/repository/RepositoryCopyProgressListener.java
index 2f89630..1a11636 100644
--- a/src/java/org/apache/ivy/plugins/repository/RepositoryCopyProgressListener.java
+++ b/src/java/org/apache/ivy/plugins/repository/RepositoryCopyProgressListener.java
@@ -31,7 +31,7 @@ public class RepositoryCopyProgressListener implements CopyProgressListener {
 
     public void start(CopyProgressEvent evt) {
         if (totalLength != null) {
-            repository.fireTransferStarted(totalLength.longValue());
+            repository.fireTransferStarted(totalLength);
         } else {
             repository.fireTransferStarted();
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/file/FileRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/file/FileRepository.java b/src/java/org/apache/ivy/plugins/repository/file/FileRepository.java
index 0ac4baf..853b5fe 100644
--- a/src/java/org/apache/ivy/plugins/repository/file/FileRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/file/FileRepository.java
@@ -72,7 +72,7 @@ public class FileRepository extends AbstractRepository {
 
     private void copy(File src, File destination, boolean overwrite) throws IOException {
         try {
-            getProgressListener().setTotalLength(new Long(src.length()));
+            getProgressListener().setTotalLength(src.length());
             if (!FileUtil.copy(src, destination, getProgressListener(), overwrite)) {
                 if (!overwrite && destination.exists()) {
                     throw new IOException("file copy not done from " + src + " to " + destination
@@ -81,10 +81,7 @@ public class FileRepository extends AbstractRepository {
                     throw new IOException("file copy not done from " + src + " to " + destination);
                 }
             }
-        } catch (IOException ex) {
-            fireTransferError(ex);
-            throw ex;
-        } catch (RuntimeException ex) {
+        } catch (IOException | RuntimeException ex) {
             fireTransferError(ex);
             throw ex;
         } finally {
@@ -96,14 +93,14 @@ public class FileRepository extends AbstractRepository {
         return progress;
     }
 
-    public List list(String parent) throws IOException {
+    public List<String> list(String parent) throws IOException {
         File dir = getFile(parent);
         if (dir.exists() && dir.isDirectory()) {
             String[] names = dir.list();
             if (names != null) {
-                List ret = new ArrayList(names.length);
-                for (int i = 0; i < names.length; i++) {
-                    ret.add(parent + getFileSeparator() + names[i]);
+                List<String> ret = new ArrayList<>(names.length);
+                for (String name : names) {
+                    ret.add(parent + getFileSeparator() + name);
                 }
                 return ret;
             }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java b/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
index 7a1cf28..b3ea9be 100644
--- a/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 
@@ -57,12 +58,9 @@ public class JarRepository extends AbstractRepository {
             if (entry == null) {
                 throw new FileNotFoundException();
             }
-            getProgressListener().setTotalLength(new Long(entry.getSize()));
+            getProgressListener().setTotalLength(entry.getSize());
             FileUtil.copy(jarFile.getInputStream(entry), destination, getProgressListener());
-        } catch (IOException ex) {
-            fireTransferError(ex);
-            throw ex;
-        } catch (RuntimeException ex) {
+        } catch (IOException | RuntimeException ex) {
             fireTransferError(ex);
             throw ex;
         } finally {
@@ -70,16 +68,17 @@ public class JarRepository extends AbstractRepository {
         }
     }
 
-    public List/* <String> */list(String parent) throws IOException {
+    public List<String> list(String parent) throws IOException {
         ZipEntry parentEntry = jarFile.getEntry(parent);
         if (parentEntry == null || !parentEntry.isDirectory()) {
             return null;
         }
-        List/* <String> */children = new ArrayList();
-        Enumeration entries = jarFile.entries();
+        List<String> children = new ArrayList<>();
+        Enumeration<JarEntry> entries = jarFile.entries();
         while (entries.hasMoreElements()) {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            if (entry.getName().startsWith(parent) && entry.getName().equals(parentEntry.getName())) {
+            JarEntry entry = entries.nextElement();
+            if (entry.getName().startsWith(parent)
+                    && entry.getName().equals(parentEntry.getName())) {
                 children.add(entry.getName());
             }
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java b/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
index d1e18e4..1aeda94 100644
--- a/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
@@ -24,7 +24,6 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivy.plugins.repository.BasicResource;
@@ -91,17 +90,14 @@ public class SFTPRepository extends AbstractSshBasedRepository {
         try {
             ChannelSftp c = getSftpChannel(path);
 
-            Collection r = c.ls(getPath(path));
+            // ls() returns a Vector of LsEntry
+            Collection<LsEntry> r = c.ls(getPath(path));
 
             if (r != null) {
-                for (Iterator iter = r.iterator(); iter.hasNext();) {
-                    Object obj = iter.next();
-                    if (obj instanceof LsEntry) {
-                        LsEntry entry = (LsEntry) obj;
-                        SftpATTRS attrs = entry.getAttrs();
-                        return new BasicResource(path, true, attrs.getSize(), attrs.getMTime()
-                                * MILLIS_PER_SECOND, false);
-                    }
+                for (LsEntry entry : r) {
+                    SftpATTRS attrs = entry.getAttrs();
+                    return new BasicResource(path, true, attrs.getSize(),
+                            attrs.getMTime() * MILLIS_PER_SECOND, false);
                 }
             }
         } catch (Exception e) {
@@ -117,16 +113,9 @@ public class SFTPRepository extends AbstractSshBasedRepository {
         try {
             String path = getPath(resource.getName());
             return c.get(path);
-        } catch (SftpException e) {
-            IOException ex = new IOException("impossible to open stream for " + resource + " on "
-                    + getHost() + (e.getMessage() != null ? ": " + e.getMessage() : ""));
-            ex.initCause(e);
-            throw ex;
-        } catch (URISyntaxException e) {
-            IOException ex = new IOException("impossible to open stream for " + resource + " on "
-                    + getHost() + (e.getMessage() != null ? ": " + e.getMessage() : ""));
-            ex.initCause(e);
-            throw ex;
+        } catch (SftpException | URISyntaxException e) {
+            throw new IOException("impossible to open stream for " + resource + " on "
+                    + getHost() + (e.getMessage() != null ? ": " + e.getMessage() : ""), e);
         }
     }
 
@@ -136,16 +125,9 @@ public class SFTPRepository extends AbstractSshBasedRepository {
         try {
             String path = getPath(source);
             c.get(path, destination.getAbsolutePath(), new MyProgressMonitor());
-        } catch (SftpException e) {
-            IOException ex = new IOException("impossible to get " + source + " on " + getHost()
-                    + (e.getMessage() != null ? ": " + e.getMessage() : ""));
-            ex.initCause(e);
-            throw ex;
-        } catch (URISyntaxException e) {
-            IOException ex = new IOException("impossible to get " + source + " on " + getHost()
-                    + (e.getMessage() != null ? ": " + e.getMessage() : ""));
-            ex.initCause(e);
-            throw ex;
+        } catch (SftpException | URISyntaxException e) {
+            throw new IOException("impossible to get " + source + " on " + getHost()
+                    + (e.getMessage() != null ? ": " + e.getMessage() : ""), e);
         }
     }
 
@@ -161,14 +143,8 @@ public class SFTPRepository extends AbstractSshBasedRepository {
                 mkdirs(path.substring(0, path.lastIndexOf('/')), c);
             }
             c.put(source.getAbsolutePath(), path, new MyProgressMonitor());
-        } catch (SftpException e) {
-            IOException ex = new IOException(e.getMessage());
-            ex.initCause(e);
-            throw ex;
-        } catch (URISyntaxException e) {
-            IOException ex = new IOException(e.getMessage());
-            ex.initCause(e);
-            throw ex;
+        } catch (SftpException | URISyntaxException e) {
+            throw new IOException(e.getMessage(), e);
         }
     }
 
@@ -201,36 +177,26 @@ public class SFTPRepository extends AbstractSshBasedRepository {
     }
 
     @SuppressWarnings("unchecked")
-    public List list(String parent) throws IOException {
+    public List<String> list(String parent) throws IOException {
         try {
             ChannelSftp c = getSftpChannel(parent);
             String path = getPath(parent);
-            Collection r = c.ls(path);
+            Collection<LsEntry> r = c.ls(path);
             if (r != null) {
                 if (!path.endsWith("/")) {
                     path = parent + "/";
                 }
-                List result = new ArrayList();
-                for (Iterator iter = r.iterator(); iter.hasNext();) {
-                    Object obj = iter.next();
-                    if (obj instanceof LsEntry) {
-                        LsEntry entry = (LsEntry) obj;
-                        if (".".equals(entry.getFilename()) || "..".equals(entry.getFilename())) {
-                            continue;
-                        }
-                        result.add(path + entry.getFilename());
+                List<String> result = new ArrayList<>();
+                for (LsEntry entry : r) {
+                    if (".".equals(entry.getFilename()) || "..".equals(entry.getFilename())) {
+                        continue;
                     }
+                    result.add(path + entry.getFilename());
                 }
                 return result;
             }
-        } catch (SftpException e) {
-            IOException ex = new IOException("Failed to return a listing for '" + parent + "'");
-            ex.initCause(e);
-            throw ex;
-        } catch (URISyntaxException usex) {
-            IOException ex = new IOException("Failed to return a listing for '" + parent + "'");
-            ex.initCause(usex);
-            throw ex;
+        } catch (SftpException | URISyntaxException e) {
+            throw new IOException("Failed to return a listing for '" + parent + "'", e);
         }
         return null;
     }
@@ -272,9 +238,7 @@ public class SFTPRepository extends AbstractSshBasedRepository {
                 Message.verbose(":: SFTP :: connected to " + host + "!");
                 SshCache.getInstance().attachChannelSftp(session, channel);
             } catch (JSchException e) {
-                IOException ex = new IOException(e.getMessage());
-                ex.initCause(e);
-                throw ex;
+                throw new IOException(e.getMessage(), e);
             }
         }
         return channel;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java b/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java
index d61c0ba..d96d0c2 100644
--- a/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java
@@ -61,7 +61,7 @@ public abstract class AbstractSshBasedRepository extends AbstractRepository {
     /**
      * hashmap of user/hosts with credentials. key is hostname, value is Credentials
      **/
-    private static HashMap credentialsCache = new HashMap();
+    private static final HashMap<String, Credentials> credentialsCache = new HashMap<>();
 
     private static final int MAX_CREDENTIALS_CACHE_SIZE = 100;
 
@@ -91,7 +91,7 @@ public abstract class AbstractSshBasedRepository extends AbstractRepository {
             }
             if (uri.getUserInfo() != null) {
                 String userInfo = uri.getUserInfo();
-                if (userInfo.indexOf(":") == -1) {
+                if (!userInfo.contains(":")) {
                     user = userInfo;
                 } else {
                     user = userInfo.substring(0, userInfo.indexOf(":"));

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java b/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
index a8579dd..8e5a5e1 100644
--- a/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
+++ b/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
@@ -154,7 +154,7 @@ public class Scp {
     }
 
     private String receiveLine(InputStream is) throws IOException, RemoteScpException {
-        StringBuffer sb = new StringBuffer(DEFAULT_LINE_BUFFER_LENGTH);
+        StringBuilder sb = new StringBuilder(DEFAULT_LINE_BUFFER_LENGTH);
 
         while (true) {
 
@@ -290,8 +290,8 @@ public class Scp {
             } else {
                 channel.connect();
             }
-        } catch (JSchException e1) {
-            throw (IOException) new IOException("Channel connection problems").initCause(e1);
+        } catch (JSchException jsche) {
+            throw new IOException("Channel connection problems", jsche);
         }
 
         readResponse(is);
@@ -375,8 +375,8 @@ public class Scp {
             } else {
                 channel.connect();
             }
-        } catch (JSchException e1) {
-            throw (IOException) new IOException("Channel connection problems").initCause(e1);
+        } catch (JSchException jsche) {
+            throw new IOException("Channel connection problems", jsche);
         }
         os.write(0x0);
         os.flush();
@@ -452,7 +452,7 @@ public class Scp {
 
     /**
      * @return ChannelExec
-     * @throws JSchException
+     * @throws JSchException if something goes wrong
      */
     private ChannelExec getExecChannel() throws JSchException {
         ChannelExec channel;
@@ -515,8 +515,7 @@ public class Scp {
             if (channel != null) {
                 channel.disconnect();
             }
-            throw (IOException) new IOException("Error during SCP transfer." + e.getMessage())
-                    .initCause(e);
+            throw new IOException("Error during SCP transfer." + e.getMessage(), e);
         }
     }
 
@@ -570,8 +569,7 @@ public class Scp {
             if (channel != null) {
                 channel.disconnect();
             }
-            throw (IOException) new IOException("Error during SCP transfer." + e.getMessage())
-                    .initCause(e);
+            throw new IOException("Error during SCP transfer. " + e.getMessage(), e);
         }
     }
 
@@ -602,8 +600,7 @@ public class Scp {
             fileInfo = receiveStream(channel, remoteFile, null);
             channel.disconnect();
         } catch (JSchException e) {
-            throw (IOException) new IOException("Error during SCP transfer." + e.getMessage())
-                    .initCause(e);
+            throw new IOException("Error during SCP transfer. " + e.getMessage(), e);
         } finally {
             if (channel != null) {
                 channel.disconnect();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java b/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java
index 7b24ecb..f056380 100644
--- a/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java
+++ b/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java
@@ -153,12 +153,12 @@ public final class SshCache {
      *
      * @see #createCacheKey(String, String, int) for details
      */
-    private Map uriCacheMap = new HashMap();
+    private final Map<String, Entry> uriCacheMap = new HashMap<>();
 
     /**
      * key is the session itself
      */
-    private Map sessionCacheMap = new HashMap();
+    private final Map<Session, Entry> sessionCacheMap = new HashMap<>();
 
     /**
      * retrieves a session entry for a given hostname from the cache
@@ -172,7 +172,7 @@ public final class SshCache {
      * @return null or the existing entry
      */
     private Entry getCacheEntry(String user, String host, int port) {
-        return (Entry) uriCacheMap.get(createCacheKey(user, host, port));
+        return uriCacheMap.get(createCacheKey(user, host, port));
     }
 
     /**
@@ -203,7 +203,7 @@ public final class SshCache {
      * @return null or the existing entry
      */
     private Entry getCacheEntry(Session session) {
-        return (Entry) sessionCacheMap.get(session);
+        return sessionCacheMap.get(session);
     }
 
     /**
@@ -220,7 +220,7 @@ public final class SshCache {
      *            Session to save
      */
     private void setSession(String user, String host, int port, Session newSession) {
-        Entry entry = (Entry) uriCacheMap.get(createCacheKey(user, host, port));
+        Entry entry = uriCacheMap.get(createCacheKey(user, host, port));
         Session oldSession = null;
         if (entry != null) {
             oldSession = entry.getSession();
@@ -251,7 +251,7 @@ public final class SshCache {
      *            to clear
      */
     public void clearSession(Session session) {
-        Entry entry = (Entry) sessionCacheMap.get(session);
+        Entry entry = sessionCacheMap.get(session);
         if (entry != null) {
             setSession(entry.getUser(), entry.getHost(), entry.getPort(), null);
         }
@@ -375,9 +375,7 @@ public final class SshCache {
                 if (passFile != null && passFile.exists()) {
                     passFile.delete();
                 }
-                IOException ex = new IOException(e.getMessage());
-                ex.initCause(e);
-                throw ex;
+                throw new IOException(e.getMessage(), e);
             }
         }
         return session;