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/18 05:02:20 UTC

[3/7] ant-ivy git commit: Add generics and Java 7 syntax to core

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/search/SearchEngine.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/search/SearchEngine.java b/src/java/org/apache/ivy/core/search/SearchEngine.java
index 3fde263..9a508cd 100644
--- a/src/java/org/apache/ivy/core/search/SearchEngine.java
+++ b/src/java/org/apache/ivy/core/search/SearchEngine.java
@@ -57,13 +57,13 @@ public class SearchEngine {
      * @return String[]
      */
     public String[] listTokenValues(String token, Map<String, Object> otherTokenValues) {
-        Set<String> entries = new LinkedHashSet<String>();
+        Set<String> entries = new LinkedHashSet<>();
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] values = resolver.listTokenValues(new String[] {token},
                 otherTokenValues);
-            for (int i = 0; i < values.length; i++) {
-                entries.add(values[i].get(token));
+            for (Map<String, String> value : values) {
+                entries.add(value.get(token));
             }
         }
 
@@ -71,13 +71,13 @@ public class SearchEngine {
     }
 
     public OrganisationEntry[] listOrganisationEntries() {
-        Set<OrganisationEntry> entries = new HashSet<OrganisationEntry>();
+        Set<OrganisationEntry> entries = new HashSet<>();
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] orgs = resolver.listTokenValues(
                 new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>());
-            for (int i = 0; i < orgs.length; i++) {
-                String org = orgs[i].get(IvyPatternHelper.ORGANISATION_KEY);
+            for (Map<String, String> oe : orgs) {
+                String org = oe.get(IvyPatternHelper.ORGANISATION_KEY);
                 entries.add(new OrganisationEntry(resolver, org));
             }
         }
@@ -86,13 +86,13 @@ public class SearchEngine {
     }
 
     public String[] listOrganisations() {
-        Set<String> entries = new HashSet<String>();
+        Set<String> entries = new HashSet<>();
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] orgs = resolver.listTokenValues(
                 new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>());
-            for (int i = 0; i < orgs.length; i++) {
-                entries.add(orgs[i].get(IvyPatternHelper.ORGANISATION_KEY));
+            for (Map<String, String> org : orgs) {
+                entries.add(org.get(IvyPatternHelper.ORGANISATION_KEY));
             }
         }
 
@@ -100,16 +100,16 @@ public class SearchEngine {
     }
 
     public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
-        Set<ModuleEntry> entries = new HashSet<ModuleEntry>();
+        Set<ModuleEntry> entries = new HashSet<>();
 
-        Map<String, Object> tokenValues = new HashMap<String, Object>();
+        Map<String, Object> tokenValues = new HashMap<>();
         tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] modules = resolver.listTokenValues(
                 new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
-            for (int i = 0; i < modules.length; i++) {
-                String module = modules[i].get(IvyPatternHelper.MODULE_KEY);
+            for (Map<String, String> me : modules) {
+                String module = me.get(IvyPatternHelper.MODULE_KEY);
                 entries.add(new ModuleEntry(org, module));
             }
         }
@@ -118,16 +118,16 @@ public class SearchEngine {
     }
 
     public String[] listModules(String org) {
-        Set<String> entries = new HashSet<String>();
+        Set<String> entries = new HashSet<>();
 
-        Map<String, Object> tokenValues = new HashMap<String, Object>();
+        Map<String, Object> tokenValues = new HashMap<>();
         tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] modules = resolver.listTokenValues(
                 new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
-            for (int i = 0; i < modules.length; i++) {
-                entries.add(modules[i].get(IvyPatternHelper.MODULE_KEY));
+            for (Map<String, String> module : modules) {
+                entries.add(module.get(IvyPatternHelper.MODULE_KEY));
             }
         }
 
@@ -135,18 +135,17 @@ public class SearchEngine {
     }
 
     public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
-        Set<RevisionEntry> entries = new HashSet<RevisionEntry>();
+        Set<RevisionEntry> entries = new HashSet<>();
 
-        Map<String, Object> tokenValues = new HashMap<String, Object>();
+        Map<String, Object> tokenValues = new HashMap<>();
         tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, module.getOrganisation());
         tokenValues.put(IvyPatternHelper.MODULE_KEY, module.getModule());
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] revisions = resolver.listTokenValues(
                 new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
-            for (int i = 0; i < revisions.length; i++) {
-                String revision = revisions[i].get(IvyPatternHelper.REVISION_KEY);
-                entries.add(new RevisionEntry(module, revision));
+            for (Map<String, String> revision : revisions) {
+                entries.add(new RevisionEntry(module, revision.get(IvyPatternHelper.REVISION_KEY)));
             }
         }
 
@@ -154,17 +153,17 @@ public class SearchEngine {
     }
 
     public String[] listRevisions(String org, String module) {
-        Set<String> entries = new HashSet<String>();
+        Set<String> entries = new HashSet<>();
 
-        Map<String, Object> tokenValues = new HashMap<String, Object>();
+        Map<String, Object> tokenValues = new HashMap<>();
         tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
         tokenValues.put(IvyPatternHelper.MODULE_KEY, module);
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] revisions = resolver.listTokenValues(
                 new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
-            for (int i = 0; i < revisions.length; i++) {
-                entries.add(revisions[i].get(IvyPatternHelper.REVISION_KEY));
+            for (Map<String, String> revision : revisions) {
+                entries.add(revision.get(IvyPatternHelper.REVISION_KEY));
             }
         }
 
@@ -183,9 +182,9 @@ public class SearchEngine {
      * @return ModuleId[]
      */
     public ModuleId[] listModules(ModuleId moduleCrit, PatternMatcher matcher) {
-        List<ModuleId> ret = new ArrayList<ModuleId>();
+        List<ModuleId> ret = new ArrayList<>();
 
-        Map<String, Object> criteria = new HashMap<String, Object>();
+        Map<String, Object> criteria = new HashMap<>();
         addMatcher(matcher, moduleCrit.getOrganisation(), criteria,
             IvyPatternHelper.ORGANISATION_KEY);
         addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
@@ -195,9 +194,9 @@ public class SearchEngine {
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
-            for (int i = 0; i < moduleIdAsMap.length; i++) {
-                String org = moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
-                String name = moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
+            for (Map<String, String> moduleId : moduleIdAsMap) {
+                String org = moduleId.get(IvyPatternHelper.ORGANISATION_KEY);
+                String name = moduleId.get(IvyPatternHelper.MODULE_KEY);
                 ModuleId modId = ModuleId.newInstance(org, name);
                 ret.add(NameSpaceHelper.transform(modId, resolver.getNamespace()
                         .getToSystemTransformer()));
@@ -219,9 +218,9 @@ public class SearchEngine {
      * @return ModuleRevisionId[]
      */
     public ModuleRevisionId[] listModules(ModuleRevisionId moduleCrit, PatternMatcher matcher) {
-        List<ModuleRevisionId> ret = new ArrayList<ModuleRevisionId>();
+        List<ModuleRevisionId> ret = new ArrayList<>();
 
-        Map<String, Object> criteria = new HashMap<String, Object>();
+        Map<String, Object> criteria = new HashMap<>();
         for (Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
             addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
         }
@@ -231,21 +230,20 @@ public class SearchEngine {
 
         for (DependencyResolver resolver : settings.getResolvers()) {
             Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
-            for (int i = 0; i < moduleIdAsMap.length; i++) {
-                String org = moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
-                String name = moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
-                String branch = moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
-                String rev = moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
-
-                Map<String, String> foundExtraAtts = new HashMap<String, String>();
-                Set<String> qualAttributes = moduleCrit.getQualifiedExtraAttributes().keySet();
-                for (String qualifiedKey : qualAttributes) {
+            for (Map<String, String> moduleId : moduleIdAsMap) {
+                String org = moduleId.get(IvyPatternHelper.ORGANISATION_KEY);
+                String name = moduleId.get(IvyPatternHelper.MODULE_KEY);
+                String branch = moduleId.get(IvyPatternHelper.BRANCH_KEY);
+                String rev = moduleId.get(IvyPatternHelper.REVISION_KEY);
+
+                Map<String, String> foundExtraAtts = new HashMap<>();
+                for (String qualifiedKey : moduleCrit.getQualifiedExtraAttributes().keySet()) {
                     String value = null;
                     int colonIndex = qualifiedKey.indexOf(':');
                     if (colonIndex == -1) {
-                        value = moduleIdAsMap[i].get(qualifiedKey);
+                        value = moduleId.get(qualifiedKey);
                     } else {
-                        value = moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex + 1));
+                        value = moduleId.get(qualifiedKey.substring(colonIndex + 1));
                     }
 
                     if (value != null) {
@@ -278,7 +276,7 @@ public class SearchEngine {
      */
     public ModuleRevisionId[] listModules(DependencyResolver resolver, ModuleRevisionId moduleCrit,
             PatternMatcher matcher) {
-        Map<String, Object> criteria = new HashMap<String, Object>();
+        Map<String, Object> criteria = new HashMap<>();
         for (Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
             addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
         }
@@ -287,23 +285,21 @@ public class SearchEngine {
                 .toArray(new String[moduleCrit.getAttributes().size()]);
 
         Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
-        Set<ModuleRevisionId> result = new LinkedHashSet<ModuleRevisionId>(); // we use a Set to
-                                                                              // remove duplicates
-        for (int i = 0; i < moduleIdAsMap.length; i++) {
-            String org = moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
-            String name = moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
-            String branch = moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
-            String rev = moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
-
-            Map<String, String> foundExtraAtts = new HashMap<String, String>();
-            Set<String> qualExtraAttributes = moduleCrit.getQualifiedExtraAttributes().keySet();
-            for (String qualifiedKey : qualExtraAttributes) {
+        Set<ModuleRevisionId> result = new LinkedHashSet<>(); // we use a Set to remove duplicates
+        for (Map<String, String> moduleId : moduleIdAsMap) {
+            String org = moduleId.get(IvyPatternHelper.ORGANISATION_KEY);
+            String name = moduleId.get(IvyPatternHelper.MODULE_KEY);
+            String branch = moduleId.get(IvyPatternHelper.BRANCH_KEY);
+            String rev = moduleId.get(IvyPatternHelper.REVISION_KEY);
+
+            Map<String, String> foundExtraAtts = new HashMap<>();
+            for (String qualifiedKey : moduleCrit.getQualifiedExtraAttributes().keySet()) {
                 String value = null;
                 int colonIndex = qualifiedKey.indexOf(':');
                 if (colonIndex == -1) {
-                    value = moduleIdAsMap[i].get(qualifiedKey);
+                    value = moduleId.get(qualifiedKey);
                 } else {
-                    value = moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex + 1));
+                    value = moduleId.get(qualifiedKey.substring(colonIndex + 1));
                 }
 
                 if (value != null) {
@@ -335,16 +331,16 @@ public class SearchEngine {
 
     public Collection<ModuleRevisionId> findModuleRevisionIds(DependencyResolver resolver,
             ModuleRevisionId pattern, PatternMatcher matcher) {
-        Collection<ModuleRevisionId> mrids = new ArrayList<ModuleRevisionId>();
+        Collection<ModuleRevisionId> mrids = new ArrayList<>();
         String resolverName = resolver.getName();
 
         Message.verbose("looking for modules matching " + pattern + " using " + matcher.getName());
         Namespace fromNamespace = null;
         if (resolver instanceof AbstractResolver) {
-            fromNamespace = ((AbstractResolver) resolver).getNamespace();
+            fromNamespace = resolver.getNamespace();
         }
 
-        Collection<ModuleEntry> modules = new ArrayList<ModuleEntry>();
+        Collection<ModuleEntry> modules = new ArrayList<>();
 
         OrganisationEntry[] orgs = resolver.listOrganisations();
         if (orgs == null || orgs.length == 0) {
@@ -358,13 +354,11 @@ public class SearchEngine {
             modules.addAll(Arrays.asList(resolver.listModules(new OrganisationEntry(resolver, org))));
         } else {
             Matcher orgMatcher = matcher.getMatcher(pattern.getOrganisation());
-            for (int i = 0; i < orgs.length; i++) {
-                String org = orgs[i].getOrganisation();
-                String systemOrg = org;
-                if (fromNamespace != null) {
-                    systemOrg = NameSpaceHelper.transformOrganisation(org,
+            for (OrganisationEntry oe : orgs) {
+                String org = oe.getOrganisation();
+                String systemOrg = (fromNamespace == null) ? org
+                    : NameSpaceHelper.transformOrganisation(org,
                         fromNamespace.getToSystemTransformer());
-                }
                 if (orgMatcher.matches(systemOrg)) {
                     modules.addAll(Arrays.asList(resolver.listModules(new OrganisationEntry(
                             resolver, org))));
@@ -392,9 +386,7 @@ public class SearchEngine {
                         + resolverName);
 
                 boolean foundRevision = false;
-                for (int j = 0; j < rEntries.length; j++) {
-                    RevisionEntry rEntry = rEntries[j];
-
+                for (RevisionEntry rEntry : rEntries) {
                     ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(
                         mEntry.getOrganisation(), mEntry.getModule(), rEntry.getRevision());
                     ModuleRevisionId systemMrid = foundMrid;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/settings/IvySettings.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/settings/IvySettings.java b/src/java/org/apache/ivy/core/settings/IvySettings.java
index 342079d..adaa188 100644
--- a/src/java/org/apache/ivy/core/settings/IvySettings.java
+++ b/src/java/org/apache/ivy/core/settings/IvySettings.java
@@ -118,9 +118,9 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
         ResolveEngineSettings, RetrieveEngineSettings, RepositoryManagementEngineSettings {
     private static final long INTERRUPT_TIMEOUT = 2000;
 
-    private Map<String, Class<?>> typeDefs = new HashMap<String, Class<?>>();
+    private Map<String, Class<?>> typeDefs = new HashMap<>();
 
-    private Map<String, DependencyResolver> resolversMap = new HashMap<String, DependencyResolver>();
+    private Map<String, DependencyResolver> resolversMap = new HashMap<>();
 
     private DependencyResolver defaultResolver;
 
@@ -134,29 +134,29 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
 
     private boolean checkUpToDate = true;
 
-    private ModuleRules<ModuleSettings> moduleSettings = new ModuleRules<ModuleSettings>();
+    private ModuleRules<ModuleSettings> moduleSettings = new ModuleRules<>();
 
-    private Map<String, ConflictManager> conflictsManager = new HashMap<String, ConflictManager>();
+    private Map<String, ConflictManager> conflictsManager = new HashMap<>();
 
-    private Map<String, LatestStrategy> latestStrategies = new HashMap<String, LatestStrategy>();
+    private Map<String, LatestStrategy> latestStrategies = new HashMap<>();
 
-    private Map<String, LockStrategy> lockStrategies = new HashMap<String, LockStrategy>();
+    private Map<String, LockStrategy> lockStrategies = new HashMap<>();
 
-    private Map<String, Namespace> namespaces = new HashMap<String, Namespace>();
+    private Map<String, Namespace> namespaces = new HashMap<>();
 
-    private Map<String, PatternMatcher> matchers = new HashMap<String, PatternMatcher>();
+    private Map<String, PatternMatcher> matchers = new HashMap<>();
 
-    private Map<String, ReportOutputter> reportOutputters = new HashMap<String, ReportOutputter>();
+    private Map<String, ReportOutputter> reportOutputters = new HashMap<>();
 
-    private Map<String, VersionMatcher> versionMatchers = new HashMap<String, VersionMatcher>();
+    private Map<String, VersionMatcher> versionMatchers = new HashMap<>();
 
-    private Map<String, CircularDependencyStrategy> circularDependencyStrategies = new HashMap<String, CircularDependencyStrategy>();
+    private Map<String, CircularDependencyStrategy> circularDependencyStrategies = new HashMap<>();
 
-    private Map<String, RepositoryCacheManager> repositoryCacheManagers = new HashMap<String, RepositoryCacheManager>();
+    private Map<String, RepositoryCacheManager> repositoryCacheManagers = new HashMap<>();
 
-    private Map<String, SignatureGenerator> signatureGenerators = new HashMap<String, SignatureGenerator>();
+    private Map<String, SignatureGenerator> signatureGenerators = new HashMap<>();
 
-    private List<Trigger> triggers = new ArrayList<Trigger>();
+    private List<Trigger> triggers = new ArrayList<>();
 
     private IvyVariableContainer variableContainer = new IvyVariableContainerImpl();
 
@@ -174,7 +174,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
 
     private ResolutionCacheManager resolutionCacheManager = null;
 
-    private List<String> listingIgnore = new ArrayList<String>();
+    private List<String> listingIgnore = new ArrayList<>();
 
     private boolean repositoriesConfigured;
 
@@ -184,7 +184,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
 
     private File baseDir = new File(".").getAbsoluteFile();
 
-    private List<URL> classpathURLs = new ArrayList<URL>();
+    private List<URL> classpathURLs = new ArrayList<>();
 
     private ClassLoader classloader;
 
@@ -224,16 +224,14 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
 
         String ivyTypeDefs = System.getProperty("ivy.typedef.files");
         if (ivyTypeDefs != null) {
-            String[] files = ivyTypeDefs.split("\\,");
-            for (int i = 0; i < files.length; i++) {
+            for (String file : ivyTypeDefs.split("\\,")) {
                 try {
-                    typeDefs(
-                        new FileInputStream(Checks.checkAbsolute(files[i].trim(),
+                    typeDefs(new FileInputStream(Checks.checkAbsolute(file.trim(),
                             "ivy.typedef.files")), true);
                 } catch (FileNotFoundException e) {
-                    Message.warn("typedefs file not found: " + files[i].trim());
+                    Message.warn("typedefs file not found: " + file.trim());
                 } catch (IOException e) {
-                    Message.warn("problem with typedef file: " + files[i].trim(), e);
+                    Message.warn("problem with typedef file: " + file.trim(), e);
                 }
             }
         } else {
@@ -390,10 +388,8 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
         try {
             new XmlSettingsParser(this).parse(settingsFile.toURI().toURL());
         } catch (MalformedURLException e) {
-            IllegalArgumentException iae = new IllegalArgumentException(
-                    "given file cannot be transformed to url: " + settingsFile);
-            iae.initCause(e);
-            throw iae;
+            throw new IllegalArgumentException(
+                    "given file cannot be transformed to url: " + settingsFile, e);
         }
         setVariable("ivy.default.ivy.user.dir", getDefaultIvyUserDir().getAbsolutePath(), false);
         Message.verbose("settings loaded (" + (System.currentTimeMillis() - start) + "ms)");
@@ -484,10 +480,8 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
             setVariable("ivy.settings.dir.url", new File(settingsFile.getAbsolutePath())
                     .getParentFile().toURI().toURL().toExternalForm());
         } catch (MalformedURLException e) {
-            IllegalArgumentException iae = new IllegalArgumentException(
-                    "given file cannot be transformed to url: " + settingsFile);
-            iae.initCause(e);
-            throw iae;
+            throw new IllegalArgumentException(
+                    "given file cannot be transformed to url: " + settingsFile, e);
         }
     }
 
@@ -633,7 +627,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
      *         substituted by their value
      */
     public synchronized Map<String, String> substitute(Map<String, String> strings) {
-        Map<String, String> substituted = new LinkedHashMap<String, String>();
+        Map<String, String> substituted = new LinkedHashMap<>();
         for (Entry<String, String> entry : strings.entrySet()) {
             substituted.put(entry.getKey(), substitute(entry.getValue()));
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java b/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
index 81d0f9a..f245b49 100644
--- a/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
+++ b/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
@@ -29,7 +29,6 @@ import java.text.ParseException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -64,13 +63,13 @@ public class XmlSettingsParser extends DefaultHandler {
      * propagated to the wrapped instance.
      */
     private static final class IvyVariableContainerWrapper implements IvyVariableContainer {
-        private static final Collection SETTINGS_VARIABLES = Arrays.asList(new String[] {
-                "ivy.settings.dir", "ivy.settings.url", "ivy.settings.file", "ivy.conf.dir",
-                "ivy.conf.url", "ivy.conf.file"});
+        private static final Collection<String> SETTINGS_VARIABLES = Arrays.asList(
+            "ivy.settings.dir", "ivy.settings.url", "ivy.settings.file", "ivy.conf.dir",
+            "ivy.conf.url", "ivy.conf.file");
 
         private final IvyVariableContainer variables;
 
-        private Map localVariables = new HashMap();
+        private Map<String, String> localVariables = new HashMap<>();
 
         private IvyVariableContainerWrapper(IvyVariableContainer variables) {
             this.variables = variables;
@@ -92,7 +91,7 @@ public class XmlSettingsParser extends DefaultHandler {
 
         public String getVariable(String name) {
             if (localVariables.containsKey(name)) {
-                return (String) localVariables.get(name);
+                return localVariables.get(name);
             }
             return variables.getVariable(name);
         }
@@ -104,10 +103,9 @@ public class XmlSettingsParser extends DefaultHandler {
 
     private Configurator configurator;
 
-    private List configuratorTags = Arrays.asList(new String[] {"resolvers", "namespaces",
-            "parsers", "latest-strategies", "conflict-managers", "outputters", "version-matchers",
-            "statuses", "circular-dependency-strategies", "triggers", "lock-strategies", "caches",
-            "signers"});
+    private List<String> configuratorTags = Arrays.asList("resolvers", "namespaces", "parsers",
+        "latest-strategies", "conflict-managers", "outputters", "version-matchers", "statuses",
+        "circular-dependency-strategies", "triggers", "lock-strategies", "caches", "signers");
 
     private IvySettings ivy;
 
@@ -141,10 +139,9 @@ public class XmlSettingsParser extends DefaultHandler {
             }
         });
         // put every type definition from ivy to configurator
-        Map typeDefs = ivy.getTypeDefs();
-        for (Iterator iter = typeDefs.keySet().iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
-            configurator.typeDef(name, (Class) typeDefs.get(name));
+        Map<String, Class<?>> typeDefs = ivy.getTypeDefs();
+        for (String name : typeDefs.keySet()) {
+            configurator.typeDef(name, typeDefs.get(name));
         }
 
         doParse(settings);
@@ -186,7 +183,7 @@ public class XmlSettingsParser extends DefaultHandler {
     public void startElement(String uri, String localName, String qName, Attributes att)
             throws SAXException {
         // we first copy attributes in a Map to be able to modify them
-        Map attributes = new HashMap();
+        Map<String, String> attributes = new HashMap<>();
         for (int i = 0; i < att.getLength(); i++) {
             attributes.put(att.getQName(i), ivy.substitute(att.getValue(i)));
         }
@@ -227,41 +224,35 @@ public class XmlSettingsParser extends DefaultHandler {
                 credentialsStarted(attributes);
             }
         } catch (ParseException ex) {
-            SAXException sax = new SAXException("problem in config file: " + ex.getMessage(), ex);
-            sax.initCause(ex);
-            throw sax;
+            throw new SAXException("problem in config file: " + ex.getMessage(), ex);
         } catch (IOException ex) {
-            SAXException sax = new SAXException("io problem while parsing config file: "
-                    + ex.getMessage(), ex);
-            sax.initCause(ex);
-            throw sax;
+            throw new SAXException("io problem while parsing config file: " + ex.getMessage(), ex);
         }
     }
 
-    private void credentialsStarted(Map attributes) {
-        String realm = (String) attributes.remove("realm");
-        String host = (String) attributes.remove("host");
-        String userName = (String) attributes.remove("username");
-        String passwd = (String) attributes.remove("passwd");
+    private void credentialsStarted(Map<String, String> attributes) {
+        String realm = attributes.remove("realm");
+        String host = attributes.remove("host");
+        String userName = attributes.remove("username");
+        String passwd = attributes.remove("passwd");
         CredentialsStore.INSTANCE.addCredentials(realm, host, userName, passwd);
     }
 
-    private void moduleStarted(Map attributes) {
+    private void moduleStarted(Map<String, String> attributes) {
         attributes.put(IvyPatternHelper.MODULE_KEY, attributes.remove("name"));
-        String resolver = (String) attributes.remove("resolver");
-        String branch = (String) attributes.remove("branch");
-        String cm = (String) attributes.remove("conflict-manager");
-        String resolveMode = (String) attributes.remove("resolveMode");
-        String matcher = (String) attributes.remove("matcher");
-        matcher = matcher == null ? PatternMatcher.EXACT_OR_REGEXP : matcher;
+        String resolver = attributes.remove("resolver");
+        String branch = attributes.remove("branch");
+        String cm = attributes.remove("conflict-manager");
+        String resolveMode = attributes.remove("resolveMode");
+        String matcher = attributes.remove("matcher");
+        matcher = (matcher == null) ? PatternMatcher.EXACT_OR_REGEXP : matcher;
         ivy.addModuleConfiguration(attributes, ivy.getMatcher(matcher), resolver, branch, cm,
             resolveMode);
     }
 
-    private void macrodefStarted(String qName, Map attributes) {
+    private void macrodefStarted(String qName, Map<String, String> attributes) {
         currentConfiguratorTag = qName;
-        Configurator.MacroDef macrodef = configurator
-                .startMacroDef((String) attributes.get("name"));
+        Configurator.MacroDef macrodef = configurator.startMacroDef(attributes.get("name"));
         macrodef.addAttribute("name", null);
     }
 
@@ -270,10 +261,10 @@ public class XmlSettingsParser extends DefaultHandler {
         configurator.setRoot(ivy);
     }
 
-    private void statusesStarted(String qName, Map attributes) {
+    private void statusesStarted(String qName, Map<String, String> attributes) {
         currentConfiguratorTag = qName;
         StatusManager m = new StatusManager();
-        String defaultStatus = (String) attributes.get("default");
+        String defaultStatus = attributes.get("default");
         if (defaultStatus != null) {
             m.setDefaultStatus(defaultStatus);
         }
@@ -281,91 +272,91 @@ public class XmlSettingsParser extends DefaultHandler {
         configurator.setRoot(m);
     }
 
-    private void versionMatchersStarted(String qName, Map attributes) {
+    private void versionMatchersStarted(String qName, Map<String, String> attributes) {
         anyConfiguratorStarted(qName);
         if ("true".equals(attributes.get("usedefaults"))) {
             ivy.configureDefaultVersionMatcher();
         }
     }
 
-    private void cachesStarted(String qName, Map attributes) {
+    private void cachesStarted(String qName, Map<String, String> attributes) {
         anyConfiguratorStarted(qName);
-        defaultLock = (String) attributes.get("lockStrategy");
-        defaultCacheManager = (String) attributes.get("default");
+        defaultLock = attributes.get("lockStrategy");
+        defaultCacheManager = attributes.get("default");
 
-        String cache = (String) attributes.get("defaultCacheDir");
+        String cache = attributes.get("defaultCacheDir");
         if (cache != null) {
             ivy.setDefaultCache(Checks.checkAbsolute(cache, "defaultCacheDir"));
         }
-        String up2d = (String) attributes.get("checkUpToDate");
+        String up2d = attributes.get("checkUpToDate");
         if (up2d != null) {
             Message.deprecated("'checkUpToDate' is deprecated, "
                     + "use the 'overwriteMode' on the 'ivy:retrieve' task instead (" + settings
                     + ")");
             ivy.setCheckUpToDate(Boolean.valueOf(up2d));
         }
-        String resolutionDir = (String) attributes.get("resolutionCacheDir");
+        String resolutionDir = attributes.get("resolutionCacheDir");
         if (resolutionDir != null) {
             ivy.setDefaultResolutionCacheBasedir(resolutionDir);
         }
-        String useOrigin = (String) attributes.get("useOrigin");
+        String useOrigin = attributes.get("useOrigin");
         if (useOrigin != null) {
             ivy.setDefaultUseOrigin(Boolean.valueOf(useOrigin));
         }
-        String cacheIvyPattern = (String) attributes.get("ivyPattern");
+        String cacheIvyPattern = attributes.get("ivyPattern");
         if (cacheIvyPattern != null) {
             ivy.setDefaultCacheIvyPattern(cacheIvyPattern);
         }
-        String cacheArtPattern = (String) attributes.get("artifactPattern");
+        String cacheArtPattern = attributes.get("artifactPattern");
         if (cacheArtPattern != null) {
             ivy.setDefaultCacheArtifactPattern(cacheArtPattern);
         }
-        String repositoryDir = (String) attributes.get("repositoryCacheDir");
+        String repositoryDir = attributes.get("repositoryCacheDir");
         if (repositoryDir != null) {
             ivy.setDefaultRepositoryCacheBasedir(repositoryDir);
         }
     }
 
-    private void settingsStarted(String qName, Map attributes) {
+    private void settingsStarted(String qName, Map<String, String> attributes) {
         if ("conf".equals(qName) && !deprecatedMessagePrinted) {
             Message.deprecated("'conf' is deprecated, use 'settings' instead (" + settings + ")");
         }
-        String cache = (String) attributes.get("defaultCache");
+        String cache = attributes.get("defaultCache");
         if (cache != null) {
             Message.deprecated("'defaultCache' is deprecated, "
                     + "use 'caches[@defaultCacheDir]' instead (" + settings + ")");
             ivy.setDefaultCache(Checks.checkAbsolute(cache, "defaultCache"));
         }
-        String defaultBranch = (String) attributes.get("defaultBranch");
+        String defaultBranch = attributes.get("defaultBranch");
         if (defaultBranch != null) {
             ivy.setDefaultBranch(defaultBranch);
         }
-        String defaultResolveMode = (String) attributes.get("defaultResolveMode");
+        String defaultResolveMode = attributes.get("defaultResolveMode");
         if (defaultResolveMode != null) {
             ivy.setDefaultResolveMode(defaultResolveMode);
         }
-        String validate = (String) attributes.get("validate");
+        String validate = attributes.get("validate");
         if (validate != null) {
             ivy.setValidate(Boolean.valueOf(validate));
         }
-        String up2d = (String) attributes.get("checkUpToDate");
+        String up2d = attributes.get("checkUpToDate");
         if (up2d != null) {
             Message.deprecated("'checkUpToDate' is deprecated, "
                     + "use the 'overwriteMode' on the 'ivy:retrieve' task instead (" + settings
                     + ")");
             ivy.setCheckUpToDate(Boolean.valueOf(up2d));
         }
-        String useRemoteConfig = (String) attributes.get("useRemoteConfig");
+        String useRemoteConfig = attributes.get("useRemoteConfig");
         if (useRemoteConfig != null) {
             ivy.setUseRemoteConfig(Boolean.valueOf(useRemoteConfig));
         }
-        String cacheIvyPattern = (String) attributes.get("cacheIvyPattern");
+        String cacheIvyPattern = attributes.get("cacheIvyPattern");
         if (cacheIvyPattern != null) {
             Message.deprecated("'cacheIvyPattern' is deprecated, use 'caches[@ivyPattern]' instead"
                     + " (" + settings + ")");
             ivy.setDefaultCacheIvyPattern(cacheIvyPattern);
         }
-        String cacheArtPattern = (String) attributes.get("cacheArtifactPattern");
+        String cacheArtPattern = attributes.get("cacheArtifactPattern");
         if (cacheArtPattern != null) {
             Message.deprecated("'cacheArtifactPattern' is deprecated, "
                     + "use 'caches[@artifactPattern]' instead (" + settings + ")");
@@ -373,31 +364,31 @@ public class XmlSettingsParser extends DefaultHandler {
         }
 
         // we do not set following defaults here since no instances has been registered yet
-        defaultResolver = (String) attributes.get("defaultResolver");
-        defaultCM = (String) attributes.get("defaultConflictManager");
-        defaultLatest = (String) attributes.get("defaultLatestStrategy");
-        defaultCircular = (String) attributes.get("circularDependencyStrategy");
+        defaultResolver = attributes.get("defaultResolver");
+        defaultCM = attributes.get("defaultConflictManager");
+        defaultLatest = attributes.get("defaultLatestStrategy");
+        defaultCircular = attributes.get("circularDependencyStrategy");
 
-        String requestMethod = (String) attributes.get("httpRequestMethod");
+        String requestMethod = attributes.get("httpRequestMethod");
         if ("head".equalsIgnoreCase(requestMethod)) {
             URLHandlerRegistry.getHttp().setRequestMethod(URLHandler.REQUEST_METHOD_HEAD);
         } else if ("get".equalsIgnoreCase(requestMethod)) {
             URLHandlerRegistry.getHttp().setRequestMethod(URLHandler.REQUEST_METHOD_GET);
         } else if ((requestMethod != null) && (requestMethod.trim().length() > 0)) {
-            throw new IllegalArgumentException("Invalid httpRequestMethod specified, must be "
-                    + "one of {'HEAD', 'GET'}");
+            throw new IllegalArgumentException(
+                    "Invalid httpRequestMethod specified, must be one of {'HEAD', 'GET'}");
         }
     }
 
-    private void includeStarted(Map attributes) throws IOException, ParseException {
+    private void includeStarted(Map<String, String> attributes) throws IOException, ParseException {
         final IvyVariableContainer variables = ivy.getVariableContainer();
         ivy.setVariableContainer(new IvyVariableContainerWrapper(variables));
         final boolean optionalInclude = "true".equals(attributes.get("optional"));
         try {
-            String propFilePath = (String) attributes.get("file");
+            String propFilePath = attributes.get("file");
             URL settingsURL = null;
             if (propFilePath == null) {
-                propFilePath = (String) attributes.get("url");
+                propFilePath = attributes.get("url");
                 if (propFilePath == null) {
                     throw new IllegalArgumentException(
                             "bad include tag: specify file or url to include");
@@ -495,11 +486,11 @@ public class XmlSettingsParser extends DefaultHandler {
         }
     }
 
-    private void propertiesStarted(Map attributes) throws IOException {
-        String propFilePath = (String) attributes.get("file");
-        String environmentPrefix = (String) attributes.get("environment");
+    private void propertiesStarted(Map<String, String> attributes) throws IOException {
+        String propFilePath = attributes.get("file");
+        String environmentPrefix = attributes.get("environment");
         if (propFilePath != null) {
-            String overrideStr = (String) attributes.get("override");
+            String overrideStr = attributes.get("override");
             boolean override = (overrideStr == null) || Boolean.valueOf(overrideStr);
             Message.verbose("loading properties: " + propFilePath);
             try {
@@ -516,12 +507,12 @@ public class XmlSettingsParser extends DefaultHandler {
         }
     }
 
-    private void propertyStarted(Map attributes) {
-        String name = (String) attributes.get("name");
-        String value = (String) attributes.get("value");
-        String override = (String) attributes.get("override");
-        String isSetVar = (String) attributes.get("ifset");
-        String unlessSetVar = (String) attributes.get("unlessset");
+    private void propertyStarted(Map<String, String> attributes) {
+        String name = attributes.get("name");
+        String value = attributes.get("value");
+        String override = attributes.get("override");
+        String isSetVar = attributes.get("ifset");
+        String unlessSetVar = attributes.get("unlessset");
         if (name == null) {
             throw new IllegalArgumentException("missing attribute name on property tag");
         }
@@ -532,18 +523,18 @@ public class XmlSettingsParser extends DefaultHandler {
             unlessSetVar);
     }
 
-    private void typedefStarted(Map attributes) {
-        String name = (String) attributes.get("name");
-        String className = (String) attributes.get("classname");
-        Class clazz = ivy.typeDef(name, className);
+    private void typedefStarted(Map<String, String> attributes) {
+        String name = attributes.get("name");
+        String className = attributes.get("classname");
+        Class<?> clazz = ivy.typeDef(name, className);
         configurator.typeDef(name, clazz);
     }
 
-    private void classpathStarted(Map attributes) throws IOException {
-        String urlStr = (String) attributes.get("url");
+    private void classpathStarted(Map<String, String> attributes) throws IOException {
+        String urlStr = attributes.get("url");
         URL url = null;
         if (urlStr == null) {
-            String file = (String) attributes.get("file");
+            String file = attributes.get("file");
             if (file == null) {
                 throw new IllegalArgumentException(
                         "either url or file should be given for classpath element");
@@ -556,12 +547,12 @@ public class XmlSettingsParser extends DefaultHandler {
         ivy.addClasspathURL(url);
     }
 
-    private void inConfiguratorStarted(String qName, Map attributes) {
+    private void inConfiguratorStarted(String qName, Map<String, String> attributes) {
         if ("macrodef".equals(currentConfiguratorTag) && configurator.getTypeDef(qName) != null) {
-            String name = (String) attributes.get("name");
+            String name = attributes.get("name");
             if (name == null) {
                 attributes.put("name", "@{name}");
-            } else if (name.indexOf("@{name}") != -1) {
+            } else if (name.contains("@{name}")) {
                 attributes.put("name", name);
             } else {
                 attributes.put("name", "@{name}-" + name);
@@ -572,7 +563,7 @@ public class XmlSettingsParser extends DefaultHandler {
                 throw new IllegalArgumentException("ref attribute should be the only one ! found "
                         + attributes.size() + " in " + qName);
             }
-            String name = (String) attributes.get("ref");
+            String name = attributes.get("ref");
             Object child = null;
             if ("resolvers".equals(currentConfiguratorTag) || "resolver".equals(qName)) {
                 child = ivy.getResolver(name);
@@ -599,9 +590,8 @@ public class XmlSettingsParser extends DefaultHandler {
             configurator.addChild(qName, child);
         } else {
             configurator.startCreateChild(qName);
-            for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
-                String attName = (String) iter.next();
-                configurator.setAttribute(attName, (String) attributes.get(attName));
+            for (String attName : attributes.keySet()) {
+                configurator.setAttribute(attName, attributes.get(attName));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/sort/CollectionOfModulesToSort.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/sort/CollectionOfModulesToSort.java b/src/java/org/apache/ivy/core/sort/CollectionOfModulesToSort.java
index 93e228b..91e6249 100644
--- a/src/java/org/apache/ivy/core/sort/CollectionOfModulesToSort.java
+++ b/src/java/org/apache/ivy/core/sort/CollectionOfModulesToSort.java
@@ -59,8 +59,8 @@ class CollectionOfModulesToSort implements Iterable<ModuleInSort> {
             VersionMatcher matcher, NonMatchingVersionReporter nonMatchingVersionReporter) {
         this.versionMatcher = matcher;
         this.nonMatchingVersionReporter = nonMatchingVersionReporter;
-        this.modulesByModuleId = new HashMap<ModuleId, Collection<ModuleInSort>>();
-        moduleDescriptors = new ArrayList<ModuleInSort>(modulesToSort.size());
+        this.modulesByModuleId = new HashMap<>();
+        moduleDescriptors = new ArrayList<>(modulesToSort.size());
         for (ModuleDescriptor md : modulesToSort) {
             ModuleInSort mdInSort = new ModuleInSort(md);
             moduleDescriptors.add(mdInSort);
@@ -70,7 +70,7 @@ class CollectionOfModulesToSort implements Iterable<ModuleInSort> {
 
     private void addToModulesByModuleId(ModuleDescriptor md, ModuleInSort mdInSort) {
         ModuleId mdId = md.getModuleRevisionId().getModuleId();
-        List<ModuleInSort> mdInSortAsList = new LinkedList<ModuleInSort>();
+        List<ModuleInSort> mdInSortAsList = new LinkedList<>();
         mdInSortAsList.add(mdInSort);
         Collection<ModuleInSort> previousList = modulesByModuleId.put(mdId, mdInSortAsList);
         if (previousList != null) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/sort/ModuleDescriptorSorter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/sort/ModuleDescriptorSorter.java b/src/java/org/apache/ivy/core/sort/ModuleDescriptorSorter.java
index 330f302..be85820 100644
--- a/src/java/org/apache/ivy/core/sort/ModuleDescriptorSorter.java
+++ b/src/java/org/apache/ivy/core/sort/ModuleDescriptorSorter.java
@@ -42,7 +42,7 @@ public class ModuleDescriptorSorter {
 
     private final CollectionOfModulesToSort moduleDescriptors;
 
-    private final List<ModuleDescriptor> sorted = new LinkedList<ModuleDescriptor>();
+    private final List<ModuleDescriptor> sorted = new LinkedList<>();
 
     private final CircularDependencyStrategy circularDepStrategy;
 
@@ -93,8 +93,8 @@ public class ModuleDescriptorSorter {
         Message.debug("Sort dependencies of : " + current.toString()
                 + " / Number of dependencies = " + descriptors.length);
         current.setCaller(caller);
-        for (int i = 0; i < descriptors.length; i++) {
-            ModuleInSort child = moduleDescriptors.getModuleDescriptorDependency(descriptors[i]);
+        for (DependencyDescriptor descriptor : descriptors) {
+            ModuleInSort child = moduleDescriptors.getModuleDescriptorDependency(descriptor);
             if (child != null) {
                 sortModuleDescriptorsHelp(child, current);
             }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/sort/ModuleInSort.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/sort/ModuleInSort.java b/src/java/org/apache/ivy/core/sort/ModuleInSort.java
index 6e30b25..2ac1a20 100644
--- a/src/java/org/apache/ivy/core/sort/ModuleInSort.java
+++ b/src/java/org/apache/ivy/core/sort/ModuleInSort.java
@@ -53,7 +53,7 @@ class ModuleInSort {
 
     private boolean isSorted = false;
 
-    private List<ModuleInSort> loopElements = new LinkedList<ModuleInSort>();
+    private List<ModuleInSort> loopElements = new LinkedList<>();
 
     private boolean isLoopIntermediateElement = false;
 
@@ -113,12 +113,14 @@ class ModuleInSort {
      */
     public boolean checkLoop(ModuleInSort futurCaller, CircularDependencyStrategy depStrategy) {
         if (caller != null) {
-            LinkedList<ModuleRevisionId> elemOfLoop = new LinkedList<ModuleRevisionId>();
+            LinkedList<ModuleRevisionId> elemOfLoop = new LinkedList<>();
             elemOfLoop.add(this.module.getModuleRevisionId());
-            for (ModuleInSort stackEl = futurCaller; stackEl != this; stackEl = stackEl.caller) {
+            ModuleInSort stackEl = futurCaller;
+            while (stackEl != this) {
                 elemOfLoop.add(stackEl.module.getModuleRevisionId());
                 stackEl.isLoopIntermediateElement = true;
                 loopElements.add(stackEl);
+                stackEl = stackEl.caller;
             }
             elemOfLoop.add(this.module.getModuleRevisionId());
             ModuleRevisionId[] mrids = elemOfLoop.toArray(new ModuleRevisionId[elemOfLoop.size()]);
@@ -166,7 +168,7 @@ class ModuleInSort {
     }
 
     /** Log a warning saying that a loop is detected */
-    public static void logLoopWarning(List loopElement) {
+    public static void logLoopWarning(List<ModuleDescriptor> loopElement) {
         Message.warn("circular dependency detected during sort: "
                 + CircularDependencyHelper.formatMessageFromDescriptors(loopElement));
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/core/sort/SortEngine.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/sort/SortEngine.java b/src/java/org/apache/ivy/core/sort/SortEngine.java
index d4ddbbc..4aa547f 100644
--- a/src/java/org/apache/ivy/core/sort/SortEngine.java
+++ b/src/java/org/apache/ivy/core/sort/SortEngine.java
@@ -63,15 +63,15 @@ public class SortEngine {
          * corresponding dependency
          */
 
-        Map<ModuleDescriptor, List<IvyNode>> dependenciesMap = new LinkedHashMap<ModuleDescriptor, List<IvyNode>>();
-        List<IvyNode> nulls = new ArrayList<IvyNode>();
+        Map<ModuleDescriptor, List<IvyNode>> dependenciesMap = new LinkedHashMap<>();
+        List<IvyNode> nulls = new ArrayList<>();
         for (IvyNode node : nodes) {
             if (node.getDescriptor() == null) {
                 nulls.add(node);
             } else {
                 List<IvyNode> n = dependenciesMap.get(node.getDescriptor());
                 if (n == null) {
-                    n = new ArrayList<IvyNode>();
+                    n = new ArrayList<>();
                     dependenciesMap.put(node.getDescriptor(), n);
                 }
                 n.add(node);
@@ -79,11 +79,10 @@ public class SortEngine {
         }
         List<ModuleDescriptor> list = sortModuleDescriptors(dependenciesMap.keySet(), options);
         final double adjustFactor = 1.3;
-        List<IvyNode> ret = new ArrayList<IvyNode>(
+        List<IvyNode> ret = new ArrayList<>(
                 (int) (list.size() * adjustFactor + nulls.size()));
         // attempt to adjust the size to avoid too much list resizing
-        for (int i = 0; i < list.size(); i++) {
-            ModuleDescriptor md = list.get(i);
+        for (ModuleDescriptor md : list) {
             List<IvyNode> n = dependenciesMap.get(md);
             ret.addAll(n);
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/core/ManifestHeaderValue.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/core/ManifestHeaderValue.java b/src/java/org/apache/ivy/osgi/core/ManifestHeaderValue.java
index 08af4c6..5bff0e0 100644
--- a/src/java/org/apache/ivy/osgi/core/ManifestHeaderValue.java
+++ b/src/java/org/apache/ivy/osgi/core/ManifestHeaderValue.java
@@ -143,7 +143,7 @@ public class ManifestHeaderValue {
         /**
          * Do the parsing
          *
-         * @throws ParseException
+         * @throws ParseException if something goes wrong
          */
         void parse() throws ParseException {
             do {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/core/ManifestParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/core/ManifestParser.java b/src/java/org/apache/ivy/osgi/core/ManifestParser.java
index 4806f33..5ccf3d7 100644
--- a/src/java/org/apache/ivy/osgi/core/ManifestParser.java
+++ b/src/java/org/apache/ivy/osgi/core/ManifestParser.java
@@ -257,7 +257,7 @@ public class ManifestParser {
         return new VersionRange(v);
     }
 
-    private static Version versionOf(String v) throws ParseException {
+    private static Version versionOf(String v) {
         if (v == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java b/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java
index 5221752..0123bcb 100644
--- a/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java
+++ b/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java
@@ -65,7 +65,7 @@ public class OSGiFilterParser {
          *
          * @return OSGiFilter
          *
-         * @throws ParseException
+         * @throws ParseException if something goes wrong
          */
         OSGiFilter parse() throws ParseException {
             return parseFilter();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java b/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
index 0c20f1f..f453cf2 100644
--- a/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
+++ b/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
@@ -50,7 +50,7 @@ public class RequirementAdapter {
         adapter.adapt(info, requirement.isOptional());
     }
 
-    private void extractFilter(OSGiFilter filter) throws UnsupportedFilterException, ParseException {
+    private void extractFilter(OSGiFilter filter) throws UnsupportedFilterException {
         if (filter instanceof AndFilter) {
             AndFilter andFilter = (AndFilter) filter;
             for (OSGiFilter subFilter : andFilter.getSubFilters()) {
@@ -93,7 +93,7 @@ public class RequirementAdapter {
     }
 
     private void parseCompareFilter(CompareFilter compareFilter, boolean not)
-            throws UnsupportedFilterException, ParseException {
+            throws UnsupportedFilterException {
         String att = compareFilter.getLeftValue();
         if (BundleInfo.PACKAGE_TYPE.equals(att) || BundleInfo.BUNDLE_TYPE.equals(att)
                 || BundleInfo.EXECUTION_ENVIRONMENT_TYPE.equals(att) || "symbolicname".equals(att)

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java b/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
index c027989..9e037f3 100644
--- a/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
+++ b/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
@@ -52,7 +52,7 @@ public class P2ArtifactParser implements XMLInputParser {
         this.repoUrl = repoUrl;
     }
 
-    public void parse(InputStream in) throws ParseException, IOException, SAXException {
+    public void parse(InputStream in) throws IOException, ParseException, SAXException {
         RepositoryHandler handler = new RepositoryHandler(p2Descriptor, repoUrl);
         try {
             XMLHelper.parse(in, null, handler, null);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/p2/P2CompositeParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/p2/P2CompositeParser.java b/src/java/org/apache/ivy/osgi/p2/P2CompositeParser.java
index 3819d6c..dfac018 100644
--- a/src/java/org/apache/ivy/osgi/p2/P2CompositeParser.java
+++ b/src/java/org/apache/ivy/osgi/p2/P2CompositeParser.java
@@ -41,7 +41,7 @@ public class P2CompositeParser implements XMLInputParser {
         return childLocations;
     }
 
-    public void parse(InputStream in) throws ParseException, IOException, SAXException {
+    public void parse(InputStream in) throws IOException, ParseException, SAXException {
         RepositoryHandler handler = new RepositoryHandler();
         try {
             XMLHelper.parse(in, null, handler, null);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java b/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
index eedb4aa..44b7a2a 100644
--- a/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
+++ b/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
@@ -56,7 +56,7 @@ public class P2MetadataParser implements XMLInputParser {
         this.logLevel = logLevel;
     }
 
-    public void parse(InputStream in) throws ParseException, IOException, SAXException {
+    public void parse(InputStream in) throws IOException, ParseException, SAXException {
         RepositoryHandler handler = new RepositoryHandler(p2Descriptor);
         try {
             XMLHelper.parse(in, null, handler, null);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java b/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
index 6170726..dfe16df 100644
--- a/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
+++ b/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
@@ -25,6 +25,6 @@ import org.xml.sax.SAXException;
 
 public interface XMLInputParser {
 
-    void parse(InputStream in) throws ParseException, IOException, SAXException;
+    void parse(InputStream in) throws IOException, ParseException, SAXException;
 
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
index 02589b5..08e762c 100644
--- a/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
+++ b/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
@@ -27,7 +27,6 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -389,11 +388,12 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
             capabilityValues.addAll(moduleByCapabilityValue.keySet());
         } else {
             for (Entry<String, Set<ModuleDescriptor>> entry : moduleByCapabilityValue.entrySet()) {
-                Iterator<ModuleDescriptor> itModules = entry.getValue().iterator();
                 boolean moduleMatchRev = false;
-                while (!moduleMatchRev && itModules.hasNext()) {
-                    ModuleDescriptor md = itModules.next();
+                for (ModuleDescriptor md : entry.getValue()) {
                     moduleMatchRev = rev.equals(md.getRevision());
+                    if (moduleMatchRev) {
+                        break;
+                    }
                 }
                 if (moduleMatchRev) {
                     // at least one module matched, the capability value is ok to add
@@ -403,6 +403,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
         }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Map<String, String>[] listTokenValues(String[] tokens, Map<String, Object> criteria) {
         Set<String> tokenSet = new HashSet<>(Arrays.asList(tokens));

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java b/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java
index 7889a1e..8890a90 100644
--- a/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java
+++ b/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java
@@ -150,14 +150,11 @@ public class EditableRepoDescriptor extends RepoDescriptor {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
+        if (!(obj instanceof EditableRepoDescriptor)) {
             return false;
         }
-        if (getClass() != obj.getClass()) {
-            return false;
+        if (this == obj) {
+            return true;
         }
         EditableRepoDescriptor other = (EditableRepoDescriptor) obj;
         if (modules == null) {

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/repo/ModuleDescriptorWrapper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/repo/ModuleDescriptorWrapper.java b/src/java/org/apache/ivy/osgi/repo/ModuleDescriptorWrapper.java
index 7efcb03..c6e42ab 100644
--- a/src/java/org/apache/ivy/osgi/repo/ModuleDescriptorWrapper.java
+++ b/src/java/org/apache/ivy/osgi/repo/ModuleDescriptorWrapper.java
@@ -85,7 +85,7 @@ public class ModuleDescriptorWrapper {
 
     @Override
     public boolean equals(Object obj) {
-        return !(obj == null || !(obj instanceof ModuleDescriptorWrapper))
+        return obj instanceof ModuleDescriptorWrapper
                 && bundleInfo.equals(((ModuleDescriptorWrapper) obj).bundleInfo);
     }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java b/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
index c63b437..dd0c227 100644
--- a/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
+++ b/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
@@ -222,7 +222,7 @@ public class UpdateSiteLoader {
         return true;
     }
 
-    private UpdateSite loadSite(URI repoUri) throws IOException, ParseException, SAXException {
+    private UpdateSite loadSite(URI repoUri) throws IOException, SAXException {
         URI siteUri = normalizeSiteUri(repoUri, null);
         URL u = siteUri.resolve("site.xml").toURL();
 
@@ -262,7 +262,7 @@ public class UpdateSiteLoader {
     }
 
     private UpdateSiteDescriptor loadFromDigest(UpdateSite site) throws IOException,
-            ParseException, SAXException {
+            SAXException {
         URI digestBaseUri = site.getDigestUri();
         if (digestBaseUri == null) {
             digestBaseUri = site.getUri();
@@ -287,8 +287,7 @@ public class UpdateSiteLoader {
         }
     }
 
-    private UpdateSiteDescriptor loadFromSite(UpdateSite site) throws IOException, ParseException,
-            SAXException {
+    private UpdateSiteDescriptor loadFromSite(UpdateSite site) throws IOException, SAXException {
         UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(site.getUri(),
                 ExecutionEnvironmentProfileProvider.getInstance());
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/util/ParseUtil.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/util/ParseUtil.java b/src/java/org/apache/ivy/osgi/util/ParseUtil.java
index 62a0a1c..7839906 100644
--- a/src/java/org/apache/ivy/osgi/util/ParseUtil.java
+++ b/src/java/org/apache/ivy/osgi/util/ParseUtil.java
@@ -50,9 +50,7 @@ public class ParseUtil {
 
         int expecting = (CHAR | DELIMITER | STARTQUOTE);
 
-        for (int i = 0; i < value.length(); i++) {
-            final char c = value.charAt(i);
-
+        for (final char c : value.toCharArray()) {
             final boolean isDelimiter = (delim.indexOf(c) >= 0);
             final boolean isQuote = (c == '"');
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/osgi/util/VersionComparator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/osgi/util/VersionComparator.java b/src/java/org/apache/ivy/osgi/util/VersionComparator.java
index 8872431..c3559b0 100644
--- a/src/java/org/apache/ivy/osgi/util/VersionComparator.java
+++ b/src/java/org/apache/ivy/osgi/util/VersionComparator.java
@@ -33,7 +33,7 @@ public class VersionComparator implements Comparator<Version> {
 
     public int compare(Version objA, Version objB) {
         final int val = objA.compareTo(objB);
-        return (reverse ? -val : val);
+        return reverse ? -val : val;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/circular/CircularDependencyHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/circular/CircularDependencyHelper.java b/src/java/org/apache/ivy/plugins/circular/CircularDependencyHelper.java
index 0c99d98..634ab92 100644
--- a/src/java/org/apache/ivy/plugins/circular/CircularDependencyHelper.java
+++ b/src/java/org/apache/ivy/plugins/circular/CircularDependencyHelper.java
@@ -17,7 +17,9 @@
  */
 package org.apache.ivy.plugins.circular;
 
+import java.util.Arrays;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
@@ -28,7 +30,6 @@ public final class CircularDependencyHelper {
 
     /** CircularDependencyHelper is not designed to be an instance */
     private CircularDependencyHelper() {
-
     }
 
     /**
@@ -56,7 +57,7 @@ public final class CircularDependencyHelper {
     }
 
     public static String formatMessage(final ModuleDescriptor[] descriptors) {
-        return formatMessage(toMrids(descriptors));
+        return formatMessageFromDescriptors(Arrays.asList(descriptors));
     }
 
     /**
@@ -65,21 +66,11 @@ public final class CircularDependencyHelper {
      * @return String
      */
     public static String formatMessageFromDescriptors(List<ModuleDescriptor> loopElements) {
-        ModuleRevisionId[] mrids = new ModuleRevisionId[loopElements.size()];
-        int pos = 0;
-        for (ModuleDescriptor descriptor: loopElements) {
-            mrids[pos] = descriptor.getModuleRevisionId();
-            pos++;
-        }
-        return formatMessage(mrids);
-    }
-
-    public static ModuleRevisionId[] toMrids(ModuleDescriptor[] descriptors) {
-        ModuleRevisionId[] mrids = new ModuleRevisionId[descriptors.length];
-        for (int i = 0; i < descriptors.length; i++) {
-            mrids[i] = descriptors[i].getModuleRevisionId();
+        List<ModuleRevisionId> mrids = new LinkedList<>();
+        for (ModuleDescriptor descriptor : loopElements) {
+            mrids.add(descriptor.getModuleRevisionId());
         }
-        return mrids;
+        return formatMessage(mrids.toArray(new ModuleRevisionId[mrids.size()]));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java b/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
index 73f4951..f0676d6 100644
--- a/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
+++ b/src/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.java
@@ -191,13 +191,13 @@ public class LatestCompatibleConflictManager extends LatestConflictManager {
             settings.getVersionMatcher(), parent, selected, evicted, callerStack);
         if (toBlacklist != null) {
             final StringBuilder blacklisted = new StringBuilder();
-            for (Iterator<IvyNodeBlacklist> iterator = toBlacklist.iterator(); iterator.hasNext();) {
-                IvyNodeBlacklist blacklist = iterator.next();
-                blacklist.getBlacklistedNode().blacklist(blacklist);
-                blacklisted.append(blacklist.getBlacklistedNode());
-                if (iterator.hasNext()) {
+            for (IvyNodeBlacklist blacklist : toBlacklist) {
+                if (blacklisted.length() > 0) {
                     blacklisted.append(" ");
                 }
+                IvyNode blacklistedNode = blacklist.getBlacklistedNode();
+                blacklistedNode.blacklist(blacklist);
+                blacklisted.append(blacklistedNode);
             }
 
             String rootModuleConf = parent.getData().getReport().getConfiguration();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java b/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
index 2237acf..143d92a 100644
--- a/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
+++ b/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
@@ -101,7 +101,7 @@ public class LatestConflictManager extends AbstractConflictManager {
             }
         }
 
-        ArrayList<IvyNode> unevicted = new ArrayList<>();
+        List<IvyNode> unevicted = new ArrayList<>();
         for (IvyNode node : conflicts) {
             if (!node.isCompletelyEvicted()) {
                 unevicted.add(node);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/latest/AbstractLatestStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/latest/AbstractLatestStrategy.java b/src/java/org/apache/ivy/plugins/latest/AbstractLatestStrategy.java
index dbd24dc..0812b56 100644
--- a/src/java/org/apache/ivy/plugins/latest/AbstractLatestStrategy.java
+++ b/src/java/org/apache/ivy/plugins/latest/AbstractLatestStrategy.java
@@ -42,7 +42,8 @@ public abstract class AbstractLatestStrategy implements LatestStrategy {
 
         // the latest revision comes last, use a ListIterator to iterate the
         // sorted list in the reverse direction.
-        for (ListIterator<ArtifactInfo> iter = l.listIterator(l.size()); iter.hasPrevious();) {
+        ListIterator<ArtifactInfo> iter = l.listIterator(l.size());
+        while (iter.hasPrevious()) {
             ArtifactInfo info = iter.previous();
             if (date == null || info.getLastModified() < date.getTime()) {
                 return info;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/lock/DeleteOnExitHook.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/lock/DeleteOnExitHook.java b/src/java/org/apache/ivy/plugins/lock/DeleteOnExitHook.java
index c77d536..5f6c18a 100644
--- a/src/java/org/apache/ivy/plugins/lock/DeleteOnExitHook.java
+++ b/src/java/org/apache/ivy/plugins/lock/DeleteOnExitHook.java
@@ -20,6 +20,7 @@ package org.apache.ivy.plugins.lock;
 import java.io.File;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
+import java.util.Set;
 
 final class DeleteOnExitHook {
 
@@ -31,7 +32,7 @@ final class DeleteOnExitHook {
         });
     }
 
-    private static final LinkedHashSet<File> files = new LinkedHashSet<>();
+    private static final Set<File> files = new LinkedHashSet<>();
 
     private DeleteOnExitHook() {
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java b/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
index 91f721b..3d6fbb3 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
@@ -401,7 +401,7 @@ public class PomReader {
             if (exclusionsElement == null) {
                 return Collections.emptyList();
             }
-            LinkedList<ModuleId> exclusions = new LinkedList<>();
+            List<ModuleId> exclusions = new LinkedList<>();
             NodeList children = exclusionsElement.getChildNodes();
             for (int i = 0, sz = children.getLength(); i < sz; i++) {
                 Node node = children.item(i);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
index cc640a8..4911c99 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
@@ -167,9 +167,9 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                         .setPubdate(md.getResolvedPublicationDate()).setUpdateBranch(false)
                         .setNamespace(ns));
         } catch (SAXException e) {
-            ParseException ex = new ParseException("exception occurred while parsing " + res, 0);
-            ex.initCause(e);
-            throw ex;
+            ParseException pe = new ParseException("exception occurred while parsing " + res, 0);
+            pe.initCause(e);
+            throw pe;
         } finally {
             if (is != null) {
                 is.close();
@@ -381,10 +381,8 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
                 if (ex instanceof SAXException) {
                     throw (SAXException) ex;
                 }
-                SAXException sax = new SAXException("Problem occurred while parsing ivy file: "
+                throw new SAXException("Problem occurred while parsing ivy file: "
                         + ex.getMessage(), ex);
-                sax.initCause(ex);
-                throw sax;
             }
         }
 
@@ -574,7 +572,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
 
         private static Map<String, String> mergeValues(Map<String, String> inherited,
                 Map<String, String> overrides) {
-            LinkedHashMap<String, String> dup = new LinkedHashMap<>(inherited.size()
+            Map<String, String> dup = new LinkedHashMap<>(inherited.size()
                     + overrides.size());
             dup.putAll(inherited);
             dup.putAll(overrides);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/69207179/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 c3ea1dd..7d09011 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
@@ -412,11 +412,13 @@ public final class XmlModuleDescriptorUpdater {
                     // replace inline revision with resolved parent revision
                     ModuleDescriptor merged = options.getMergedDescriptor();
                     if (merged != null) {
-                        ExtendsDescriptor[] parents = merged.getInheritedDescriptors();
-                        for (int j = 0; value == null && j < parents.length; ++j) {
-                            ModuleRevisionId resolvedId = parents[j].getResolvedParentRevisionId();
+                        for (ExtendsDescriptor parent : merged.getInheritedDescriptors()) {
+                            ModuleRevisionId resolvedId = parent.getResolvedParentRevisionId();
                             if (parentId.equals(resolvedId.getModuleId())) {
                                 value = resolvedId.getRevision();
+                                if (value != null) {
+                                    break;
+                                }
                             }
                         }
                     }
@@ -441,10 +443,9 @@ public final class XmlModuleDescriptorUpdater {
                 buffers.peek().setPrint(true);
                 String extend = substitute(settings, attributes.getValue("extends"));
                 if (extend != null) {
-                    for (StringTokenizer tok = new StringTokenizer(extend, ", "); tok
-                            .hasMoreTokens();) {
-                        String current = tok.nextToken();
-                        if (confs.contains(current)) {
+                    StringTokenizer tok = new StringTokenizer(extend, ", ");
+                    while (tok.hasMoreTokens()) {
+                        if (confs.contains(tok.nextToken())) {
                             throw new IllegalArgumentException(
                                     "Cannot exclude a configuration which is extended.");
                         }
@@ -618,7 +619,7 @@ public final class XmlModuleDescriptorUpdater {
                         settings.substitute(attributes.getValue("url")));
                 } else {
                     // TODO : settings can be null, but I don't why.
-                    // Check if the next code is correct in that case
+                    // Check if the following code is correct in that case
                     String fileName = attributes.getValue("file");
                     if (fileName == null) {
                         String urlStr = attributes.getValue("url");
@@ -655,10 +656,9 @@ public final class XmlModuleDescriptorUpdater {
                                 }
                                 String extend = substitute(settings, attributes.getValue("extends"));
                                 if (extend != null) {
-                                    for (StringTokenizer tok = new StringTokenizer(extend, ", "); tok
-                                            .hasMoreTokens();) {
-                                        String current = tok.nextToken();
-                                        if (confs.contains(current)) {
+                                    StringTokenizer tok = new StringTokenizer(extend, ", ");
+                                    while (tok.hasMoreTokens()) {
+                                        if (confs.contains(tok.nextToken())) {
                                             throw new IllegalArgumentException("Cannot exclude a "
                                                     + "configuration which is extended.");
                                         }
@@ -806,13 +806,12 @@ public final class XmlModuleDescriptorUpdater {
             return XMLHelper.escape(result);
         }
 
-        private String removeConfigurationsFromMapping(String mapping, List confsToRemove) {
+        private String removeConfigurationsFromMapping(String mapping, List<String> confsToRemove) {
             StringBuilder newMapping = new StringBuilder();
             String mappingSep = "";
-            for (StringTokenizer tokenizer = new StringTokenizer(mapping, ";"); tokenizer
-                    .hasMoreTokens();) {
-                String current = tokenizer.nextToken();
-                String[] ops = current.split("->");
+            StringTokenizer tokenizer = new StringTokenizer(mapping, ";");
+            while (tokenizer.hasMoreTokens()) {
+                String[] ops = tokenizer.nextToken().split("->");
                 List<String> confsToWrite = new ArrayList<>();
                 for (String lh : ops[0].split(",")) {
                     if (!confs.contains(lh.trim())) {
@@ -821,37 +820,31 @@ public final class XmlModuleDescriptorUpdater {
                 }
                 if (!confsToWrite.isEmpty()) {
                     newMapping.append(mappingSep);
-
                     String sep = "";
                     for (String confToWrite : confsToWrite) {
-                        newMapping.append(sep);
-                        newMapping.append(confToWrite);
+                        newMapping.append(sep).append(confToWrite);
                         sep = ",";
                     }
                     if (ops.length == 2) {
-                        newMapping.append("->");
-                        newMapping.append(ops[1]);
+                        newMapping.append("->").append(ops[1]);
                     }
                     mappingSep = ";";
                 }
             }
-
             return newMapping.toString();
         }
 
-        private String removeConfigurationsFromList(String list, List confsToRemove) {
+        private String removeConfigurationsFromList(String list, List<String> confsToRemove) {
             StringBuilder newList = new StringBuilder();
             String listSep = "";
-            for (StringTokenizer tokenizer = new StringTokenizer(list, ","); tokenizer
-                    .hasMoreTokens();) {
+            StringTokenizer tokenizer = new StringTokenizer(list, ",");
+            while (tokenizer.hasMoreTokens()) {
                 String current = tokenizer.nextToken();
                 if (!confsToRemove.contains(current.trim())) {
-                    newList.append(listSep);
-                    newList.append(current);
+                    newList.append(listSep).append(current);
                     listSep = ",";
                 }
             }
-
             return newList.toString();
         }
 
@@ -966,15 +959,12 @@ public final class XmlModuleDescriptorUpdater {
 
             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 (InheritableItem item : list) {
+                writeInheritanceComment(itemName, entry.getKey());
+                for (InheritableItem item : entry.getValue()) {
                     out.print(getIndent());
                     printer.print(merged, item, out);
                 }
@@ -1091,8 +1081,8 @@ public final class XmlModuleDescriptorUpdater {
                     && !(mergedConfigurations && mergedDependencies)) {
 
                 // calculate the position of the element in ivy-module
-                int position = moduleElement == null ? MODULE_ELEMENTS.size() : MODULE_ELEMENTS
-                        .indexOf(moduleElement);
+                int position = (moduleElement == null) ? MODULE_ELEMENTS.size()
+                        : MODULE_ELEMENTS.indexOf(moduleElement);
 
                 ModuleDescriptor merged = options.getMergedDescriptor();